I'm stuck a bit with that issue. I need to stop my test scenario execution until progress bar is visible. Progress bar is handled by nprogress.js

I was thinking about to catch it (progress bar) as WebElement but i assume that i won't be able to find it in time because progress bar can be visible from 1 to 6 seconds and selenium will search the element longer that execution itself.

Is there any possible way how i can check nprogress.js execution status?

1 Answer 1


The simple option would be to ask the devs to add a status variable in the javascript that you can call via javascript executor class. I wouldn't like that since it introduces code in the product that has no obvious reason and violates clean code guidelines but it would work. The other way would be a spin lock, just something along the lines of
float EmergencyBreak = 0; while(!driver.findElement(ProgBar).isDisplayed()&& EmergencyBreak<7){EmergencyBreak +=(1/5); Thread.sleep(200);}.

This would wait at most 7 seconds (35 iterations of 1/5th of a second) but break out as soon as the progress bar appears. In the end it really depends on the specific application though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.