![](/img/trans.png)
[英]Unable to use Selenium2Library in Robot Framework. ImportError: No module named Selenium2Library error
[英]How to open a Chrome application into Robot using selenium2Library
我正在尝试使用selenium2Library在Robot中打开Windows Chrome exe。 我尝试使用带有此代码的“创建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} execute_path = C: /程序文件(x86)/Myapp.exe
使用robotframework selenium2library打开Chrome
1)通过pip安装selenium2Library
2)下载并解压缩Chrome驱动程序exe,将其添加到环境变量中
3)您可以像下面这样调用chrome
*** Settings ***
Library Selenium2Library
*** Variables ***
${SiteUrl} https://stackoverflow.com
${Browser} Chrome
*** Test Cases ***
Test
Open Browser and login
*** Keywords ***
Open Browser and login
open browser ${SiteUrl} ${Browser}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.