0

我的代码中的显式等待在 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 = method(self._driver) 文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/support/expected_conditions.py”,第 78 行,通话中 返回 _element_if_visible(_find_element(driver, self.locator)) 文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/support/expected_conditions.py”,第 98 行, 在 _element_if_visible 返回元素 if element.is_displayed() == visibility else False File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py ",第 358 行,在 is_displayed return self._execute(Command.IS_ELEMENT_DISPLAYED)['value'] File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/ remote/webelement.py”,第 494 行,在 _execute 中返回 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(response)文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5 /site-packages/selenium/webdriver/remote/errorhandler.py",第 163 行,在 check_response 中引发 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
4

1 回答 1

0

Xpath 不适用于 Safari,尝试使用 CSS_SELECTOR、ID 或 CLASS_NAME 解决您的问题

于 2017-07-10T08:21:38.507 回答