Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13891

Selenium Python || How to click on Toggle button based on its status

$
0
0

Could you please help me with below HTML and selenium?

HTML Code

I am trying to click on the toggle button by id "elm_guest_code_auto_generate" and here is my python code:

toggle_button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, "elm_guest_code_auto_generate")))# Check if the toggle button is inactiveif "checked" not in toggle_button.get_attribute("outerHTML"):    # If the toggle button is inactive, click on it to activate it    toggle_button.click()    print("Toggle button activated.")else:    print("Toggle button is already active.")

and I am getting this error:

Traceback (most recent call last):  File "C:\Users\muraril\PycharmProjects\pythonProject\GuestProfileRules\GuestProfileRule.py", line 73, in <module>    toggle_button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, "elm_guest_code_auto_generate")))  File "C:\Users\muraril\PycharmProjects\pythonProject\.venv\lib\site-packages\selenium\webdriver\support\wait.py", line 105, in until    raise TimeoutException(message, screen, stacktrace)selenium.common.exceptions.TimeoutException: Message: 

Viewing all articles
Browse latest Browse all 13891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>