I have an internal web application with a modal dialog. Unfortunately, I cannot post the actual location of the web application here, but let me describe it as best as possible.
- When the application starts, you get a window on the screen that tells you a bunch of text. You can click "Next" to get the next page of text.
- On the last page, the Next button is disabled, and the rest of the web application user interface is turned on.
- There is a variable number of pages, so I donโt know how many times I have to click Next.
I can click a fixed number of times (for example: if I know that there are two pages that I can double-click), but I'm not sure how to change this so that it works no matter how many pages I have. I would like a general solution; presumably this uses some kind of loop that would check if the button is on. If so, click on it. If it is disabled, exit the loop.
Question: How to set up a loop in Selenium that presses a button several times until it shuts down?
Here is the code I tried:
from selenium import webdriver from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui import WebDriverWait
Irwin
source share