import io.appium.java_client.MobileBy; import io.appium.java_client.MobileElement; import io.appium.java_client.android.Activity; import io.appium.java_client.android.AndroidDriver; import org.openqa.selenium.remote.DesiredCapabilities; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit; public class LoginTest { public static AndroidDriver _driver; @BeforeMethod public void setUpAppium() throws Exception { startApp("emulator-5554", "Android", "9", "ca.slava.tv.google.dev", "com.slava.box.rich.com.slava.tv.activities.SplashScreen", "1", "2", "UiAutomator2"); } @Test private void testLogin() { Activity activity = new Activity ("ca.slava.tv.google.dev","com.slava.box.configurator.AppConfiguratorActivity"); ((AndroidDriver) _driver).startActivity(activity); _driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); MobileElement el1 = (MobileElement) _driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().resourceIdMatches(\".*guidedactions_item_title\").text(\"Next\")")); _driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); } private void startApp(String DeviceName, String PlatformName, String PlatformVersion, String AppPackage, String AppActivity, String password, String username, String AutomationName) throws MalformedURLException { DesiredCapabilities cap = new DesiredCapabilities(); cap.setCapability("automationName", AutomationName); cap.setCapability("deviceName", DeviceName); cap.setCapability("platformName", PlatformName); cap.setCapability("platformVersion", PlatformVersion); cap.setCapability("appPackage", AppPackage); cap.setCapability("appActivity", AppActivity); URL url= new URL("http://127.0.0.1:4723/wd/hub"); _driver = new AndroidDriver(url,cap); } /* @AfterMethod public void teardown(){ _driver.quit(); } */ }