【发布时间】:2018-04-15 12:25:23
【问题描述】:
我正在尝试使用 selenium2Library 在 Robot 中打开我们的 Windows Chrome exe。我尝试使用带有此代码的 Create Webdriver 创建一个 webdriver,但它不起作用。
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver.chrome.options
${options.add_extension}= Set_Variable path/to/extension
Create WebDriver Chrome chrome_options=${options}
在 Python 中我这样做......它会在 selenium 中启动我的应用程序。
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains
def chromedr():
chrome_options = Options()
chrome_options.binary_location = 'C:/Program Files (x86)/InTouch Health/Carestation/Carestation.exe'
driver = webdriver.Chrome('C:/Program Files (x86)/InTouch Health/Carestation/chromedriver.exe', chrome_options=chrome_options)
return driver
如何在 Robot/selenium2Library 中执行此操作?
我能够使用以下代码启动应用程序: ${options}= 评估 sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver 创建 WebDriver Chrome my_alias chrome_options=${options} executable_path=C:/Program Files (x86)/Myapp.exe
【问题讨论】:
-
“不工作”是什么意思?你有任何错误吗?它是否打开了错误的浏览器?机器人会崩溃吗?
-
我能够使用 ... ${options}= 评估 sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver 创建 WebDriver Chrome my_alias chrome_options= ${options} executable_path=C:/Program Files (x86)/InTouch Health/Carestation/Carestation.exe 但是,我无法将该 webdriver 实例与其他调用(如关闭浏览器)一起使用。如何制作一个独特的网络驱动器(链接到应用程序)并将我的硒/机器人调用定向到它。有没有办法将此对象传递给其他调用或使其成为全局对象?
-
注意python/ selenium 我在上面的例子中使用了'驱动程序'。
-
请不要在评论区放代码,无法阅读。如果您需要为您的问题添加更多信息,您可以edit您的问题。你还没有回答我的第一个问题,即“'不工作'是什么意思?
-
不工作 - 它总是启动 Chrome 浏览器而不是我的 Chomium 应用程序。我想启动一个铬应用程序。我现在能够做到这一点,但现在我似乎无法将 Chomium 应用程序对象与其余的机器人/selenium2library 调用一起使用。这怎么行?
标签: python google-chrome selenium robotframework