How to run Espresso within the Appium?
As we all know that the espresso is specially designed for Android devices and it is much faster than others. Have you ever thought of integrating Espresso Test within the Appium itself to boost the test in Android devices? Things that need to be used before the @Test
Code Snippet:
private By loginScreen = MobileBy.AccessibilityId("Login Screen"); private By usr = MobileBy.AccessibilityId("username"); private By pass = MobileBy.AccessibilityId("password"); private By lgn = MobileBy.AccessibilityId("loginBtn"); private By verificationTextEspresso = By.xpath( "//Enter the path and the text to verify if you are validated or not."); private AndroidDriver getDriver(String automationName) throws MalformedURLException { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("automationName", automationName); return new AndroidDriver<>(new URL("https://device.pcloudy.com/api/"), capabilities); }You can write the test case as follows in the espresso- @Test
Code Snippet:
public void testLogin_Espresso() throws MalformedURLException { AndroidDriver driver = getDriver("Espresso"); WebDriverWait wait = new WebDriverWait(driver, 10); ExpectedConditionHope it will boost your test scripts.loginScreenReady = ExpectedConditions.presenceOfElementLocated(loginScreen); try { wait.until(loginScreenReady).click(); driver.findElement(usr).sendKeys("alice"); driver.findElement(pass).sendKeys("mypassword"); driver.findElement(lgn).click(); driver.findElement(verificationTextEspresso); } finally { driver.quit(); } }