javascriptprotractore2e-testingangularjs-e2e

How to wait browser on protractor e2e test?


I have a flaky test. Its about my loading screen. I use

await browser.wait(EC.invisibilityOf(...)); // It contains parameters.

await browser.sleep(2000);

But still sometimes it is work , it is not. I have a button. My test try button click on Loading screen therefore it fail. It must wait when loading screen was gone.(I tried using wait and sleep )

How I do resolve the problem. I need help.


Solution

  • It must wait when loading screen was gone

    1. Create a while loop.
    2. Check if the loading screen is gone
      • if true then do your thing
      • else wait
    3. Let the loop gets executed until the condition returns true

    and by

    if the loading screen is gone

    You can check the CSS of the element of the loading screen. It can be

    display: none;
    

    or

    visibility: hidden;
    

    depends on how it is hidden.