【发布时间】:2020-01-08 04:46:15
【问题描述】:
我该如何解决这个错误:
selenium.common.exceptions.ElementNotInteractableException: Message: Element <> could not be scrolled into view
通过 Selenium 使用 Firefox 时出错?
网站上的所有提示都没有帮助我。我尝试了所有我能找到的解决方案,包括通过 WebDriverWait 和 JS。其中一种解决方案给出了:
selenium.common.exceptions.MoveTargetOutOfBoundsException: Message: (568, 1215) is out of bounds of viewport width (1283) and height (699)
我尝试调整浏览器窗口的大小,但也没有用。
我的代码:
webdriverDir = "/Users/Admin/Desktop/MyVersion/geckodriver.exe"
home_url = 'https://appleid.apple.com/account/'
browser = webdriver.Firefox(executable_path=webdriverDir)
browser.get(home_url)
browser.find_element_by_css_selector("captcha-input").click()
引发窗口大小错误的解决方案:
actions = ActionChains(browser)
wait = WebDriverWait(browser, 10)
element = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "captcha-input")))
actions.move_to_element(element).perform()
element.click()
顺便说一句,同样的代码在 Chrome 中也能完美运行。但这已经足够明显了。
【问题讨论】:
标签: python-3.x selenium-webdriver xpath css-selectors webdriverwait