[英]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.