Nyní se podíváme na to, jak vyřešit chybu selenium.common.exceptions.ElementClickInterceptedException: Message: Element is not clickable at point because another element <html> obscures it při použití frameworku Selenium v pythonu.
Celá chyba:
Traceback (most recent call last): File "/var/robot-jox/robot-jox.py", line 655, in <module> object.fillerLoop(exekutor_id) File "/var/robot-jox/robot-jox.py", line 419, in fillerLoop b.checkElement(exResultPosition1).click() File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webelement.py", line 80, in click self._execute(Command.CLICK_ELEMENT) File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute return self._parent.execute(command, params) File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementClickInterceptedException: Message: Element <a id="t150" class="nowrap " href="#"> is not clickable at point (92,571) because another element <html> obscures it
Řešení
Jako první udělat update geckodriver + selenium. Následně je více řešení.
Ověřené řešení:
elPosi1 = driver.find_element('xpath', exResultPosition1)
driver.execute_script("arguments[0].click();", elPosi1)
Ideální řešení: Odchytávání vyjímek - když selže element.click(), tak se provede driver.execute_script()
try:
element.click()
except WebDriverException:
elPosi1 = driver.find_element('xpath', exResultPosition1)
driver.execute_script("arguments[0].click();", elPosi1)
Toto nepomohlo
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, exResultPosition1))) WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, exResultPosition1))).click()
Komentáře (0)
Přidat komentář