pythonseleniumwhile-loophelium

Logic to adopt when an webelement is showing and desapearring two times


I'm struggling with something right now and I don't know how to solve this.

Using Selenium and Helium, I'm running some test on a web app.

At some point, the web app print a screen blocker. This screen locker appears and disappears two times.

I have to wait for the second one to disappear to move on to other stuff.

How can I do this?

Code I've tried :

while S(".loadingHeader").exists:
    print ("loading")

This piece of code is working for the first time the screen blocker is appearing

I'm taking any idea you have.

Thank you and have a nice day


Solution

  • Thank you for your answer.

    I ended up doing this :

    wait_until (S(".loadingHeader").exists)
    time_open = time.time()
    while S(".loadingHeader").exists():
        time.sleep(0.5)
        print ("Loading")
    if (lambda : not S(".loadingHeader").exists):
        wait_until (S(".loadingHeader").exists)
        print ("Loading Again")
        while S(".loadingHeader").exists():
            print ("Loading")
            time.sleep(0.5)
    tmp_time_open = (time.time() - time_open)
    print ("Not Loading Anymore !!!")
    print ("Opening in : " + str(tmp_time_open))
    

    It's working that way. Hope it will be usefull to someone else