【发布时间】:2016-02-15 02:21:40
【问题描述】:
我遇到了How can I add an extension to my chromedriver at the Robot level with Selenium2Library 之类的场景,但我正在尝试在远程机器上启动浏览器。
上述问题的答案在本地机器上运行良好。但是如何向 chrome 浏览器添加扩展并在远程机器上启动。
使用python获取chrome选项
def launchbrowserwithextension():
options = webdriver.ChromeOptions()
options.add_argument('--load-and-launch-app=path_to_extension')
return chrome_options
我写的机器人测试用例如下
${options}= launchbrowserwithextension
${executor}= Evaluate str('http://xx.xx.xx.xx:5558/wd/hub')
${desired capabilities}= Evaluate { "browserName": "chrome", "version": "", "platform": "VISTA", "javascriptEnabled": True}
Create Webdriver Remote desired_capabilities=${desired capabilities} command_executor=${executor} chrome_options=${options}
得到异常“init() 得到了一个意外的关键字参数 'chrome_options'”
其次,我尝试了以下
def launchbrowserwithextension():
options = webdriver.ChromeOptions()
options.add_argument('--load-and-launch-app=path_to_extension')
driver = webdriver.Remote('http://xx.xx.xx.xx:5558/wd/hub', options.to_capabilities())
使用 python,我可以在带有扩展名的远程机器上添加扩展名并启动浏览器。 然后我使用机器人框架登录到使用 python 打开的扩展。所以我写了使用机器人框架关键字输入用户名和密码的步骤。
在这里,我最终也收到错误“没有打开浏览器”。但是浏览器和扩展程序都是在远程机器上打开的,机器人框架无法识别它
【问题讨论】:
-
Open Browser 关键字本身具有提供远程 URL 的选项。这个链接能回答你的问题吗?:robotframework.org/Selenium2Library/doc/…
标签: python selenium selenium-webdriver robotframework selenium-chromedriver