我的代码中的显式等待在SafariDriver 2.48.0中不起作用。它在Windows和MAC中使用chrome。当等待到达时,它的驱动程序抛出异常
文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/support/wait.py”,第71行,直到 value =方法(self._driver) 文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/support/expected_conditions.py”,第78行,致电 return _element_if_visible(_find_element(driver,self.locator)) 在_element_if_visible中输入文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/support/expected_conditions.py”,第98行 如果element.is_displayed()== visibility else False返回元素 文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py”,第358行,in_displayed return self._execute(Command.IS_ELEMENT_DISPLAYED)['value'] 在_execute中输入文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py”,第494行 return self._parent.execute(command,params) 文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py”,第236行,执行 self.error_handler.check_response(响应) 在check_response中输入文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py”,第163行 提出exception_class(value)
我的代码是:
self.driver = webdriver.Safari()
self.driver.wait = WebDriverWait(self.driver, 60)
self.driver.get("http://example.com")
# Click Sign in button and wait for sign in page
self.driver.find_element_by_xpath(XMLDict['SignIn'].Xpath).click()
self.driver.wait.until(EC.visibility_of_element_located((By.ID, XMLDict['User'].ID)))
self.driver.maximize_window()
配置:
OS - macOS Sierra
Selenium 3.0.1
Safari - 10.0.1
SafariDriver - 2.48.0
Python 3.5
答案 0 :(得分:0)