How to verify if a light message box appears or no?


I habe a test case in which I have to click a button “Download Data” , whoch downloads data in xml format.
In case, when the device is in airplane mode, the service failed, I would like to verify whether a light message box is displayed or no indicating that " failed to download service document" for more details see this picture :

Thank you

I created a small method as below for you, pleas give a try a play around that idea.

public static boolean isDownloadFailure(WebDriver driver) {

    WebElement element = driver.findElement(YOUR_ELEMENT_LOCATOR_HERE);
    boolean isInAirMode = false;
	// In 60s, in every 500ms, it will check this element to make sure the element presented
	// IF it's true, isInAirMode = true;
    if ((new WebDriverWait(driver, 60)).until(ExpectedConditions.presenceOfElementLocated(element)) != null) {
        isInAirMode = true;
	return isInAirMode;

thank you for your reply , the problem is that there is no locator for my element because its not defined in the code. when I press a button for downloading the content (and I am in the airplane mode) , i have to get that pop up, it does not have any id or something else…
here the code used to switch on the airplane mode and its working fine :

    NetworkConnectionSetting connection = new NetworkConnectionSetting(true, false, false)
    driver.setNetworkConnection(connection);//here driver type is Android driver 

after it I need to verify whether that light box appears or no.

So, the problem you are asking is how to locate the element?

1 Like

yes thats one question or is there any other solution to verify that it appears

Is it a native app? If yes, can you give a try with UIAutomator to inspect the element?

1 Like

I have solved the problem, my case when there is netwok and I click on the button “Dowload Data” it displays to me an xml code (textview contain xml code) so I verified if the texview contains the “xml” or no …

wow, easy huh. But it’s not an overnight successful. Congrats!

1 Like