简体   繁体   English

无法使用 Robot Framework 的 --Variable 为不同的浏览器运行

[英]Unable to run for different browsers using --Variable of Robot Framework

In the Keywords.robot i have specified the Browser as variable and assigned to chrome, but when i tried to run from the terminal using the below command在 Keywords.robot 我已将浏览器指定为变量并分配给 chrome,但是当我尝试使用以下命令从终端运行时

C:\Users\rajre\PycharmProjects\Automation>robot --variable Browser:firefox TestCases\LoginTest.robot C:\Users\rajre\PycharmProjects\Automation>robot --variable Browser:firefox TestCases\LoginTest.robot

throws error as "SessionNotCreatedException: Message: Unable to find a matching set of capabilities "抛出错误为“SessionNotCreatedException:消息:无法找到一组匹配的功能”

Note: I have kept the geckodriver.exe at location C:\Users\rajre\PycharmProjects\Automation\venv\Scripts注意:我将 geckodriver.exe 保存在位置 C:\Users\rajre\PycharmProjects\Automation\venv\Scripts

LoginKeywords.robot: LoginKeywords.robot:

 *** Settings *** Library Selenium2Library Variables../PageObjects/Locaters.py *** Variables *** ${AppUrl} https://xxxxxxxxxxxxx ${Browser} chrome *** Keywords *** Open my Browser [Arguments] ${AppUrl} ${Browser} open browser ${AppUrl} ${Browser} maximize browser window Input UserName [Arguments] ${Username} input text ${txt_loginUserName} ${Username} Input Pwd [Arguments] ${Password} input text ${txt_loginPassword} ${Password} Click Login Button click button ${btn_Login} Verify Message should contain Password cannot be empty Password cannot be empty should contain Username cannot be empty Username cannot be empty should contain Invalid credentials Invalid credentials should contain Dashboard Dashboard

LoginTest.robot LoginTest.robot

 *** Settings *** Library Selenium2Library Resource../Resources/LoginKeywords.robot Library DataDriver../TestData/LoginTestData.xlsx Suite Setup Open my Browser ${AppUrl} ${Browser} Suite Teardown Close Browser Test Template Login Validation *** Test Cases *** LoginTest Login Validation *** Keywords *** Login Validation [Arguments] ${Username} ${Password} Input UserName ${Username} sleep 1 Input Pwd ${Password} sleep 1 Click Login Button sleep 1 Verify Message

LoginTest.robot LoginTest.robot

I have tried this way too, but no luck我也尝试过这种方式,但没有运气

Suite Setup Open my Browser ${AppUrl} browser=${Browser}套件设置 打开我的浏览器 ${AppUrl} browser=${Browser}

C:\Users\rajre\PycharmProjects\Automation>robot --variable browser:firefox TestCases\LoginTest.robot C:\Users\rajre\PycharmProjects\Automation>robot --变量浏览器:firefox TestCases\LoginTest.robot

Open Browser keyword will find a browser driver on your environment variables, you may add your drivers there.打开浏览器关键字将在您的环境变量中找到一个浏览器驱动程序,您可以在那里添加您的驱动程序。 Or, you can use its optional parameter "executable-path"或者,您可以使用其可选参数“executable-path”

So it goes like this for Chrome所以对于 Chrome 来说是这样的

Open Browser    https://www.google.com/   Chrome  executable_path=C:/chromedriver.exe

For Firefox适用于 Firefox

Open Browser    https://www.google.com/   Firefox  executable_path=C:/geckodriver.exe

You can have different keywords for that or just also pass the executable_path on your [Arguments]您可以为此使用不同的关键字,或者也可以在[Arguments]上传递 executable_path

The geckodriver is only used for Firefox Browser, and you have specified the Browser as variable and assigned to Chrome, This will definitely not work. geckodriver只用于 Firefox 浏览器,并且您已将浏览器指定为变量并分配给 Chrome,这肯定不起作用。 Download the latest chromedriver from here这里下载最新的chromedriver

Hope this helps!希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用“AND”条件为机器人框架中的多个变量设置套件变量 - Unable to Set Suite Variable for multiple variables in robot framework using "AND" condition 无法从机器人框架运行 python 脚本 - Unable to Run python script from Robot framework 在使用 run.py 的单次运行中,在机器人框架中使用各自的排除标签运行不同的测试套件? - Running different test suites with respective exclude tag in robot framework in a single run using run.py? 机器人框架:使用“关闭所有浏览器”时,套件拆解失败 - Robot Framework: Suite Teardown fails when using Close All Browsers 无法使用ROBOT框架的SSH库通过“执行命令”运行python脚本 - unable to run python script through “execute command” using SSH library of ROBOT framework 应用 | 机器人框架 | 无法使用自定义定位器策略运行关键字来查找元素 - Appium | Robot Framework | Unable to run a keyword to find an element using a custom locator strategy 机器人框架 - 获取变量 - Robot Framework - Get variable Robot Framework:无法使用文件中包含unicode的变量来运行Robot测试用例 - Robot Framework: Unable to run the Robot test case with variables that has unicode in the file 减慢使用Robot Framework进行测试运行的好方法? - Good ways to slow down a test run using Robot Framework? 无法打印 Robot Framework 中的日志 - Unable to print the log in Robot Framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM