<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Android Automation Basic to Advance]]></title><description><![CDATA[Android Automation Basic to Advance]]></description><link>https://sumitsmewal.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 14 Nov 2026 21:31:15 GMT</lastBuildDate><atom:link href="https://sumitsmewal.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to set the capabilities to open the app or execute the test on the app using the real device ?]]></title><description><![CDATA[For that we can use UiAutomator2Options class or using DesiredCapabilities class Step1: Need to set capabilities using the method setCapability () and need…]]></description><link>https://sumitsmewal.hashnode.dev/how-to-set-the-capabilities-to-open-the-app-or-execute-the-test-on-the-app-using-the-real-device</link><guid isPermaLink="true">https://sumitsmewal.hashnode.dev/how-to-set-the-capabilities-to-open-the-app-or-execute-the-test-on-the-app-using-the-real-device</guid><category><![CDATA[Appium testing]]></category><category><![CDATA[automation]]></category><category><![CDATA[android test automation]]></category><dc:creator><![CDATA[sumit singh]]></dc:creator><pubDate>Sat, 09 Nov 2024 14:49:28 GMT</pubDate><content:encoded><![CDATA[<p>For that we can use UiAutomator2Options class or using DesiredCapabilities class</p>
<h3 id="heading-steps">Steps:</h3>
<p><strong>Step1:</strong></p>
<p>Need to set capabilities using the method setCapability () and need to give the values in the key value pair</p>
<p>Ex:</p>
<p>UiAutomator2Options cap = new UiAutomator2Options();</p>
<p>DesiredCapabilities cap = new DesiredCapabilities();</p>
<p>cap.SetCapability ("deviceName", "realme C33"); // Mobile name cap.setCapability("platformVersion", "13"); // Android version of your phone</p>
<p>cap.setCapability("app", "path of the Apk in your project");</p>
<p><strong>Step2:</strong></p>
<p>After setting the capabilities we need to give these details to the object of AndroidDriver</p>
<p>Android driver = new AndroidDriver(new URL("<a target="_blank" href="http://127.0.0.1:4723&quot;\),cap">http://127.0.0.1:4723"),cap</a>);</p>
<p><strong>*****for the above code we need to manually start the appium server using the appium command from the cmd using the command “appium”*****</strong></p>
<h1 id="heading-how-to-start-appium-server-automatically-before-the-test-starts">How to start appium server automatically before the test starts ?</h1>
<h3 id="heading-to-start-the-appium-sever-from-the-code-automatically-we-have-to-use-object-of-appiumservicebuilder-class">To start the appium sever from the code (automatically) we have to use object of AppiumServiceBuilder class</h3>
<h3 id="heading-steps-1"><strong>Steps:</strong></h3>
<p>Step1:</p>
<p>create an object of AppiumServiceBuilder class and use the method withAppiumJS() and pass the path of the main.js file as the argument in the new file object</p>
<p>service = new AppiumServiceBuilder().withAppiumJS(new File("C://Users//Admin//AppData//Roaming//npm//node_modules//appium//build//lib//main.js"))</p>
<p>Step2:</p>
<p>give the ip address and port and build() the method.</p>
<p>service = new AppiumServiceBuilder().withAppiumJS(new File("C://Users//Admin//AppData//Roaming//npm//node_modules//appium//build//lib//main.js")).withIPAddress("127.0.0.1").usingPort(4723).build();</p>
<p>Step3:</p>
<p>use service.start() method to st<strong>art the server and sevice.close() to close the server</strong></p>
<p><strong>*****use start() in beforemehtod annotation and sevice.close() in aftermethod annotation after driver.quit*****</strong></p>
]]></content:encoded></item></channel></rss>