How to run Espresso within the Appium? – pCloudy – Question and Answers
Home >> Appium Tricks and Tricks >> How to run Espresso within the Appium? ...

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(""), 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);
ExpectedCondition loginScreenReady =

try {
} finally {
Hope it will boost your test scripts.

Leave a Reply

Your email address will not be published. Required fields are marked *