【问题标题】:Robot Framework's SeleniumLibrary throws an error "chromedriver.exe is not a supported browser"Robot Framework 的 SeleniumLibrary 抛出错误“chromedriver.exe 不是受支持的浏览器”
【发布时间】:2019-09-01 16:15:45
【问题描述】:

我正在使用带有 Python 的机器人框架为登录场景做一些自动化测试脚本。但是当我们运行套件中的第一个测试用例时,它会显示错误并且所有测试用例都失败,因为不支持 chrome/gecko 驱动程序。

我们已经完成了所有的安装和webdriver路径设置(geckodriver和chromedriver)C:\python\scripts\chromedirver.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}

错误:

Starting test: Demo1.Login.Login Suite.Valid user login
20190411 11:03:45.982 :  INFO : Opening browser 
'C:\Users\mahendra\Downloads\chromedriver_win32\chromedriver.exe' to base url 'https://www.gmail.com'.
20190411 11:03:45.982 :  INFO : Cannot capture screenshot because no browser is open.
20190411 11:03:46.060 :  FAIL : ValueError: c:\users\mahendra\downloads\chromedriver_win32\chromedriver.exe is not a supported browser.
Ending test:   Demo1.Login.Login Suite.Valid user login

【问题讨论】:

    标签: python selenium automated-tests selenium-chromedriver robotframework


    【解决方案1】:

    错误来自您如何调用Open Browser - 您将位置传递给驱动程序 exe,但它需要一些不同的东西 - 带有浏览器名称的字符串。例如。这个:

    Open Browser    https://www.gmail.com    ${chromedriver}
    

    实际上必须是这样的:

    Open Browser    https://www.gmail.com    Chrome
    

    如果您想为 webdriver(在您的情况下为 chromedriver)自定义位置,自定义为不在用户路径中,您有 2 个选项 - 在运行时添加它:

    Append To Environment Variable      PATH    C:\\Users\\mahendra\\Downloads\\chromedriver_win32\\
    

    (该关键字在 OperatingSystem 库中)

    ,或使用Create Webdriver 关键字来实例化驱动程序:

    Create Webdriver     Chrome     executable_path=${chromedriver}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-18
      • 2020-02-14
      • 2019-06-27
      • 2019-02-18
      • 1970-01-01
      • 2013-07-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多