1

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).

1 Answer 1

1

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']
Sign up to request clarification or add additional context in comments.

2 Comments

update: When I remove the class and just have the static attributes it doesn't seem to recognize it
Try any other static attribute or the parent element with unique attribute.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.