设置文件下载路径为浏览器的默认下载路径

*** Test Cases *** window/linux
Specifying a Known Mobile Device
    ${mobile emulation}=    Create Dictionary    deviceName=Google Nexus 5
    ${chrome options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${chrome options}    add_experimental_option    mobileEmulation    ${mobile emulation}
    Create Webdriver    Chrome    chrome_options=${chrome options}
    Goto    https://stackoverflow.com
    Sleep    10 secs

Specifying Individual Device Attributes
    ${device metrics}=    Create Dictionary    width=${360}    height=${640}    pixelRatio=${3.0}    userAgent=Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19
    ${mobile emulation}=    Create Dictionary    deviceMetrics=${device metrics}
    ${chrome options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${chrome options}    add_experimental_option    mobileEmulation    ${mobile emulation}
    Create Webdriver    Chrome    chrome_options=${chrome options}
    Goto    https://stackoverflow.com
    Sleep    10 secs

*** Keywords *** win/linux
打开浏览器
    [Arguments]     ${level_name}  ${downloadPath}
    ${url}  get_xpath  login_page  relax   ${level_name}
    log  ${url}
    ${prefs}=    Create Dictionary    download.default_directory=/home/root/download
    ${chrome options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${chrome options}    add_experimental_option    prefs    ${prefs}
    Create Webdriver    Chrome    chrome_options=${chrome options}
    Go To  ${url}
    MAXIMIZE BROWSER WINDOW

  

 

posted on 2021-09-16 11:50  Old-Kang  阅读(180)  评论(0编辑  收藏  举报