<dependencies>
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.6.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>
AndroidDriver<AndroidElement> driver = null;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Redmi Note 9 Pro");
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,"com.miui.calculator");
capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,"cal.CalculatorActivity");
capabilities.setCapability(MobileCapabilityType.NO_RESET,true);
capabilities.setCapability(MobileCapabilityType.APP,"<полный_путь_к_вашему_apk>");
try {
driver = new AndroidDriver<>(new URL("http://127.0.0.0:4723/wd/hub"),capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
} catch (MalformedURLException e) {
System.out.println(e.getMessage());
public void initialize() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Redmi Note 9 Pro");
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,"com.miui.calculator");
capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,"cal.CalculatorActivity");
capabilities.setCapability(MobileCapabilityType.NO_RESET,true);
try {
driver = new AndroidDriver<>(new URL("http://127.0.0.0:4723/wd/hub"),capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
} catch (MalformedURLException e) {
System.out.println(e.getMessage());
}
}
driver.findElementById("com.miui.calculator:id/btn_3_s").click();
driver.findElementByAndroidUIAutomator("new UISelector().packageName(\"com.miui.calculator\").text(\"3\")").click();
@Test
public void checkCalculate() {
initialize();
driver.findElementById("com.miui.calculator:id/btn_3_s").click();
driver.findElementById("com.miui.calculator:id/btn_plus_s").click();
driver.findElementById("com.miui.calculator:id/btn_9_s").click();
driver.findElementById("com.miui.calculator:id/btn_equal_s").click();
assert(driver.findElementByAndroidUIAutomator("new UiSelector().packageName(\"com.miui.calculator\").resourceId(\"com.miui.calculator:id/result\")").getText().equals("= 12"));