Pre requisites:
- Eclipse IDE
- Android SDK
- Java
- Appium Desktop
Refer: Appium Setup
Create Maven Project in eclipse:
Click on File -> New -> Other-> Maven
Enter Group Id, Artifact Id and Click Finish
Create package and java class to write test script to launch Android app.
Desired capabilities:
Desired Capabilities are keys and values encoded in a JSON object, sent by Appium clients to the server when a new automation session is requested. They tell the Appium drivers all kinds of important things about how you want your test to work
Refer: Appium Desired capabilities doc.
Refer: Appium Desired capabilities doc.
Required capabilities:
// To create an object of Desired CapabilitiesDesiredCapabilities dc = new DesiredCapabilities();
// Device name: – I am using Redmi6
dc.setCapability("deviceName", "Redmi");
// Name of the OS: Android, iOS or FirefoxOS
dc.setCapability("platformName", "Android");
// Mobile OS version – My device is running Android 9
dc.setCapability("platformVersion", "9");
// Java package of the tested Android app
dc.setCapability("appPackage", "com.android.settings");
// An activity name for the Android activity you want to run from your package.
dc.setCapability("appActivity", "com.android.settings.MainSettings");
dc.setCapability("noReset", true);
dc.setCapability("autoAcceptAlerts", true);
dc.setCapability("autoGrantPermissions", true);
dc.setCapability("automationName", "UiAutomator2");
// Constructor to initialize driver object with new Url and Capabilities
//URL url = new URL("http://127.0.0.1:4723/wd/hub");
driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), dc);
To find app package and Activity of installed app open cmd and type adb shell dumpsys window | find "mCurrentFocus"
Code snippet:
No comments:
Post a Comment