使用机器人框架时,如何使用--no-sandbox打开chrome?

时间:2017-02-13 02:58:17

标签: robotframework

如何在使用机器人框架时使用--no-sandbox打开chrome?

2 个答案:

答案 0 :(得分:2)

${options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver

Call Method    ${options}  add_argument  --no-sandbox

Create WebDriver   Chrome  chrome_options=${options}

答案 1 :(得分:0)

这可能也有帮助:

*** Settings ***
Library    SeleniumLibrary

Suite Teardown    Close All Browsers

*** Variables ***
${YOUR_URL}    https://stackoverflow.com/

*** Test Cases ***
No_Sandbox Chrome - Create Webdriver
    ${chrome_options}    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${chrome_options}   add_argument    no-sandbox
    ${options}    Call Method     ${chrome_options}    to_capabilities      

    Create Webdriver    Chrome    chrome_options==${options}

    Go to     ${YOUR_URL}

No_Sandbox Chrome - Open Browser
    ${chrome_options}    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${chrome_options}   add_argument    no-sandbox
    ${options}    Call Method     ${chrome_options}    to_capabilities     

    Open Browser    ${YOUR_URL}    browser=chrome    desired_capabilities=${options}