我正在使用Robot框架和Python为登录场景编写一些自动化测试脚本。但是当我们运行套件中的第一个测试用例时,它会显示错误并且所有测试用例都失败,因为chrome/gecko驱动程序不受支持。在
我们已经完成了所有的安装和webdriver路径设置(geckodriver和chromedriver)C:\python\scripts\ChromeServer.exe在
测试脚本:
*** Settings ***
Library Selenium2Library
*** Variables ***
${LoginUserType} Type=email # Login user email field.
${ClickNextButtonXpath} xpath=//span[contains(text(),'Next')] # Click on next button.
${UserPasswordName} name=password #Login user password field.
${NextButtonXpath} xpath=//span[contains(text(),'Next')] # User click on next button.
${UserProfileIcon} //a[@class='gb_x gb_Da gb_f'] # Vefify that icon user profile.
${Geckodriver} C:\\Users\\mahendra\\Downloads\\geckodriver-v0.24.0-win64\\geckodriver.exe
${chromedriver} C:\\Users\\mahendra\\Downloads\\chromedriver_win32\\chromedriver.exe
*** Test Cases ***
Valid user login
[Documentation] Login Test Cases
... Step 1. Open browser.
... Step 2. Enter user email 'mahendra.seervi@connexistech.com' in user email field.
... Step 3. Click on next button.
... Step 4. Enter user password 'mahendra2020kag' in user password field.
... Step 5. Click on next button. Step 6. Verify that 'logout' link should display.
Open Browser https://www.gmail.com ${chromedriver}
Maximize Browser Window
Wait Until Element Is Visible \ 30
Input Text ${LoginUserType} mahendra.seervi@connexistech.com
Click Element ${ClickNextButtonXpath}
Input Text ${UserPasswordName} 2586355
Click Element ${NextButtonXpath}
Page Should Contain Element ${UserProfileIcon}
*** Keywords ***
Set Environment Variable
Set Environment Variable webdriver.geckodriver.driver ${Geckodriver}
Set Environment Variable webdriver.chromedriver.driver ${chromedriver}
错误:
^{pr2}$
错误来自于您如何调用
Open Browser
-您正在将位置传递给驱动程序exe,但它需要的是不同的内容-一个带有浏览器名称的字符串。E、 g.这:一定是这样的:
^{pr2}$如果您想为webdriver(在您的例子中是chromedriver)自定义位置,自定义为不在用户的路径中,您有两个选项-在运行时将其添加到那里:
(该关键字在
OperatingSystem
库中),或使用
Create Webdriver
关键字实例化驱动程序:相关问题 更多 >
编程相关推荐