Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (120 points)

I have this code

driver.find_element_by_xpath("//button[@class='control-button']").click()

while True:

    driver.find_element_by_xpath("//button[@class='control-button']").click()

    time.sleep(randint(200, 300))


very often the button is not clickable.

is there a way to wait for it to be visible and click?

1 Answer

0 votes
by (50.2k points)

Remove the while loop and run this .click() function that will help you to click on the desired button present in that XPath. If you want to see the next page then import the package using:

import java.util.concurrent.TimeUnit;

then, inside the code try 

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

That will work for you.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...