am在mac环境下使用了selenium和Python,在Safari浏览器中运行测试用例时遇到了问题。在
命令sudo easy_install selenium在终端中打印以下内容:Searching for selenium
Best match: selenium 3.5.0
Processing selenium-3.5.0-py2.7.egg
selenium 3.5.0 is already the active version in easy-install.pth
Using /Library/Python/2.7/site-packages/selenium-3.5.0-py2.7.egg
Processing dependencies for selenium
Finished processing dependencies for selenium
现在,当我想运行一个简单的Python脚本来打开一个网站时,我使用以下代码:from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Safari()
driver.get("https://www.google.co.in")
它在终端中显示此错误:Traceback (most recent call last):
File "a.py", line 5, in
driver = webdriver.Safari()
File "/Library/Python/2.7/site-packages/selenium-3.5.0-py2.7.egg/selenium/webdriver/safari/webdriver.py", line 52, in init
desired_capabilities=desired_capabilities)
File "/Library/Python/2.7/site-packages/selenium-3.5.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 140, in init
self.start_session(desired_capabilities, browser_profile)
File "/Library/Python/2.7/site-packages/selenium-3.5.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 229, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/Library/Python/2.7/site-packages/selenium-3.5.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 297, in execute
self.error_handler.check_response(response)
File "/Library/Python/2.7/site-packages/selenium-3.5.0-py2.7.egg/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Could not create a session: You must enable the 'Allow Remote Automation' option in Safari's Develop menu to control Safari via WebDriver
我找不到确切的问题。在
请提前帮忙和感谢。在