【问题标题】:Enable ChromeDriver Log and path update Path in Robot Framework在 Robot Framework 中启用 ChromeDriver 日志和路径更新路径
【发布时间】:2020-08-03 01:41:34
【问题描述】:

谁能帮助我将 service_arg --log-path 传递给 ChromeDriver,以便在 RobotFramework 中启用和控制驱动程序日志的路径。当我尝试传递服务参数时,我开始收到错误。

我将发布两个结构相似的测试。`Chrome Log Tests

*** Settings ***
Library    Selenium2Library  
Library    OperatingSystem
Library    Collections        
                   
*** Variables ***

${URL}    https://google.com
${Browser}    Chrome
${path}    D:\\Users\\x\\AppData\\Local\\Programs\\Python\\Python38\\Scripts\\chromedriver.exe
${chromelogs}    D:\\Users\\x\\eclipse-workspace\\ChromeOptions\\jpg 
                           
      
*** Test Cases ***

Test 001
    [Documentation]     ChromeLog path

    Create Webdriver    ${Browser}    executable_path=${path}    service_args=["--log-path=${chromelogs}"]
    Go To    ${URL}
    [Teardown]    Close All Browsers
    
Test 002
    [Documentation]     Chrome options
         
    ${chrome_options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys   
    Call Method    ${chrome_options}    add_argument    version                 
    Call Method    ${chrome_options}    add_argument    disable-infobars
    Call Method    ${chrome_options}    add_argument    start-maximized     
    
    Create Webdriver    Chrome    chrome_options=${chrome_options}    executable_path=${path}    service_args=["--log-path=${chromelogs}"]             
    Go To   ${URL}       
    [Teardown]    Close All Browsers

【问题讨论】:

    标签: selenium-chromedriver robotframework


    【解决方案1】:

    我有另一种方法来捕获 chromedriver 日志,这将解决您的调试问题。

    1. 从命令行打开 chromedriver.exe(chromedriver.exe --verbose --log-path=C:\chromedriver.log,它将侦听端口 9551)
    2. 使用示例代码 打开浏览器 http://vpatel.rf.gd gc 无 http://localhost:9515
      点击元素 id=alertbtn

    chrome 将在 step1 的命令窗口中显示需要日志。如果您碰巧找到了一种方法来输入登录代码,请在此处分享。

    -维奈

    【讨论】:

      【解决方案2】:

      较新版本的 SeleniumLibrary 包含 service_log_path 参数。 https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Open%20Browser

      打开浏览器 ${LOGIN URL} ${BROWSER} service_log_path=webdriver.log

      【讨论】:

        猜你喜欢
        • 2020-07-18
        • 1970-01-01
        • 2014-07-03
        • 1970-01-01
        • 2011-11-26
        • 1970-01-01
        • 2016-05-07
        • 1970-01-01
        • 2017-11-26
        相关资源
        最近更新 更多