DEV Community

Ben Chukwuma
Ben Chukwuma

Posted on

UI testing safe checks on Appium

The User Interface (UI) of an app is the visual representation of your app and what the users largely interact with. A glitchy UI interpretation of your app can negatively impact your brand, this makes UI testing a necessity before an application can be released to production.

This article is aimed at exploring some automated UI testing safe checks we can use to ensure our UI implementation is predictable and more solid.

Note: All approaches will be focused with Appium (an open-source tool for automating native, mobile web, and hybrid applications on iOS mobile, Android mobile, and Windows desktop platforms ).

Check visibility of elements

Lets say you want to check for a visibility of a splash screen, you can check if the screen is displayed using isDisplayed() method.

List<MobileElement> element =
driver.findElementsByAccessibilityId("automation id here");
if(element.size()>0){
//screen is displayed
} else{
//screen is not displayed }
Keyboard visible

In Appium, we can use the isKeyboardShown keyword to ascertain whether or not the soft keyboard is shown.

driver = new AndroidDriver(appiumURL, capabilities);
boolean isDisplayed = driver.isKeyboardShown();

Element over element

Also, in case we want to check if an element is inside another element, we can use an approach like this.

private WebElement element=
driver.findElementByAccessibilityId("First element")
findElementByAccessibilityId("Second element");

Further Reading

Is Keyboard Shown — Appium

Testing your React Native app with Appium — LogRocket Blog

Appium mobile testing — test React Native apps | Codemagic Blog

Top comments (0)