[important]how to detect progressbar when traversing all pages


#1

I am using appium for android automation and want to get all information from every pages.
when i click element and change to anonther page there will be a progressbar running for seconds.
i do not know what will appare after the page show,so i can only wait untill the progressbar disappare and then get all the element.
so i want to know how to locate the progressbar or with what tools i can see it.
btn:the prgressbar has no name.
I’v try to locate it on the appium inspector,but can not see the element.


#2

Try to get the pageSource several times when the progress bar is visible.
Print the pageSourse in console then try to search for the element by copying the xml in a text file.

        String xml1 = driver.getPageSource();
	    u.wait(500);
        String xml2 = driver.getPageSource();
        u.wait(200);
        String xml3 = driver.getPageSource();
        u.wait(300);
        String xml4 = driver.getPageSource();
        u.wait(300);
        String xml5 = driver.getPageSource();
        u.wait(200);
        String xml6 = driver.getPageSource();
        log.info("1: "+xml1);
        log.info("2: "+xml2);
        log.info("3: "+xml3);
        log.info("4: "+xml4);
        log.info("5: "+xml5);
        log.info("6: "+xml6);

You will find it for sure. Once you know the ID if the element you can do like this with uiAutomator2

public boolean waitForProgressBarToDisappear() {
		WebDriverWait wait = new WebDriverWait(driver, BaseSetup.EXPLICIT_WAIT_TIME, 0);
		try {
			wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("progress_bar")));
			log.info("Progress bar no longer displayed, moving forward with the steps...");
			return true;

		} catch (NoSuchElementException e) {
			log.info(e);
			return true;
		}
	}

#3

Zuzeac,Thanks for your answer!
I’V try to get infomation in your way but can not find the element.
This day i found by chrome inspector that this is an html5 element like this:
<div data-v-8de08982="" data-v-7517201c="" class="pjf-spinner-snake pjf-spinner-snake-animation" style="border-color: rgb(204, 204, 204) rgb(22, 144, 255) rgb(204, 204, 204) rgb(204, 204, 204); height: 28px; width: 28px; transform: rotateZ(0deg);"></div>
without id but a class.
i try to locate the element by class just like this:
this.getWebDriver().findElements(By.xpath("//*[contains(@class,'spinner-snake')]"));
also failed.
can i have another way to find it?


#4

Try to put this class
this.getWebDriver().findElements(By.xpath("//*[contains(@class,‘pjf-spinner-snake’)]"));

or put this: pjf-spinner-snake pjf-spinner-snake-animation

Ask your devs do give you the exact resource ID for that progress bar. They should be able to give you this.
Also make sure you are using uiAutomator2, latest appium version and java client.

You are automating a native or hybrid app?


#5

i am using uiAutomator2,also not working.
whether appium can not regonise this element.
now i use another way to resolve it that i find that when the progressbar appear there will be an element cover the page,after progressbar disappear it will disappare too.this kind of element can be found by appium.
thank you,Zuzeac.