I am learning automation testing with Appium(Lastest 1.8.2)-Mobile Automation
Testing from Scratch course on Udemy . I am trying with real and virtual devices and I can launch the application, but my operation( .click
) is not working.
I am working on IntelliJ
IDEA Community 2019.2.
Appium version: v1.14.1
I created Java Project with Maven Module JAR: commons-lang3-3.0, client-combined-3.141.59, java-client, selenium-java
BASE CLASS:
public class base {
public static AndroidDriver Capabilities() throws MalformedURLException {
File f = new File("src");
File fs = new File(f, "ApiDemos-debug.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Galaxy Tab S2");
cap.setCapability(MobileCapabilityType.AUTOMATION_NAME,"UiAutomator2");
cap.setCapability(MobileCapabilityType.APP, fs.getAbsolutePath());
AndroidDriver<AndroidElement> driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), cap);
return driver;
}
}
BASICS CLASS:
public class basics extends base {
public static void main(String[] args) throws MalformedURLException {
AndroidDriver<AndroidElement> driver = Capabilities();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.xpath("//android.widget.TextView[@text='Preference']")).click();
driver.findElementByXPath("//android.widget.TextView[@text='3. Preference dependencies']").click();
driver.findElementById("android:id/checkbox").click();
}
}
The problem is that I am receiving (probably) good exit code in Appium:
Got response with status 200
But I cannot see that test is performed on my device with Android.
Did I omit something?
You don't need that many dependencies, it is quite enough to have io.appium.java-client
only, Appium Java Client includes Selenium libraries and guaranteed to work only with the version which it's linked with
So
Explicitly set up the following Desired Capabilities :
MobileCapabilityType.PLATFORM_NAME
with the value of android
AndroidMobileCapabilityType.APP_PACKAGE
with the value of your application package AndroidMobileCapabilityType.APP_ACTIVITY
with the value of your application activity
MobileCapabilityType.AUTOMATION_NAME
should be uiautomator2
You can check out Appium -> Code Examples -> Java for comprehensive information and sample code repository which you can use as the "skeleton" for your test
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.