I wanted to use headless mode in my python selenium project, and I get this error:
Exception has occurred: TimeoutException
The last traceback was on line 26, and it was also the first line after succesfully opening a website. Here is the line in question:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class=' css-1hy2vtq']"))).click()
What I've tried to solve it:
I've tried adding arguments to the chrome options, I've tried switching up the first line and so I found out that waiting for an element_to_be_clickable() does not work but find_element(By), does (well in this case at least).
CodePudding user response:
The classnames i.e. css-1hy2vtq
, etc are dynamically generated and is bound to change sooner/later. They may change next time you access the application afresh or even while next application startup. So can't be used in locators.
Solution
You need to consider any of the other attributes which is static in nature. Example:
//button[text()='Click Me']