I am trying to click in call loop toggle with Selenium with the WebDriver on Python.
the html code:
this is the button:
I have tried few options:
button_element = driver.find_element_by_class_name("iPhoneCheckContainer")
button_element.click()
the filed message:
Traceback (most recent call last):
File "C:UserskostiPycharmProjectstest1main.py", line 50, in <module>
element = driver.find_element_by_xpath("//input[@id='on_off_on']").click()
File "C:UserskostiAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverremotewebelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:UserskostiAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverremotewebelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "C:UserskostiAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverremotewebdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:UserskostiAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverremoteerrorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <input type="checkbox" id="on_off_on" value="1" name="AllowReset" checked=""> is not clickable at point (171, 261). Other element would receive the click: <div class="iPhoneCheckHandle" style="width: 30px; left: 30px;">...</div>
(Session info: chrome=88.0.4324.150)
Advertisement
Answer
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
elem=WebDriverWait(driver,5000).until(EC.visibility_of_element_located(
(By.XPATH, "//input[@id='on_off_on']")))
driver.execute_script("arguments[0].scrollIntoView();",elem)
element.click()
Try using webdriver wait

