"chromeOptions": {
"binary": "/Users/amar/Downloads/name-of-application-staging.app/Contents/MacOS/name-of-application-staging",
"args": ["--headless", "--no-sandbox"]
}
和test.robot:
*** Settings ***
Library Selenium2Library
Variables vars.py
*** Test Cases ***
Foo
Create Webdriver Remote desired_capabilities=${binary_location} command_executor=http://localhost:9515
click element hehe_element
首先我运行chromedriver,然后在test.robot所在的目录中继续,然后输入:
robot test.robot
桌面应用程序启动,大约30秒钟后出现此错误:
WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052), platform=Mac OS X 10.13.6 x86_64)
第二个关键字“点击元素”永远不会开始。 我正在使用macOS。
Chrome版本:Version 70.0.3538.67 (Official Build) (64-bit)
chromedriver版本:ChromeDriver 2.43
尝试通过.py开始后,出现此错误: 追溯(最近一次通话): 在第11行的文件“ start_application.py” 浏览器= webdriver.Chrome(options = chrome_options) init 中的文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py”,第81行 required_capabilities = desired_capabilities) init 中的文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py”,第157行 self.start_session(功能,浏览器配置文件) 在start_session的第252行中,文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py” 响应= self.execute(Command.NEW_SESSION,参数) 在执行的文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py”中,第321行 self.error_handler.check_response(响应) 文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py”,第242行,在check_response中 引发exception_class(消息,屏幕,堆栈跟踪) selenium.common.exceptions.WebDriverException:消息:未知错误:DevToolsActivePort文件不存在 (驱动程序信息:chromedriver = 2.40.565386(45a059dc425e08165f9a10324bd1380cc13ca363),platform = Mac OS X 10.13.6 x86_64)
答案 0 :(得分:0)
请尝试以下代码:
def build_chrome_options():
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--headless")
chromeOptions.binary_location='/Users/amar/Downloads/name-of-application-staging.app/Contents/MacOS/name-of-application-staging'
return chrome_options
如果此代码不能解决您的问题,请参阅here中的问题。