首页 > 代码库 > RobotFrameWork--selenium2模拟chrome的user agent

RobotFrameWork--selenium2模拟chrome的user agent

${options}=    Evaluate    sys.modules[selenium.webdriver].ChromeOptions()   sys, selenium.webdriver
${options.add_argument}=    Set Variable    user-agent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36 System/ComputerId" 
Create WebDriver    Chrome  chrome_options=${options}   
Go To   http://www.useragentstring.com
${options}=    Evaluate    sys.modules[selenium.webdriver].ChromeOptions()    sys, selenium.webdriver
Call Method    ${options}    add_argument    --user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36 System/ComputerId
Create WebDriver    Chrome    chrome_options=${options}    
Go To    http://www.useragentstring.com

技术分享

 

RobotFrameWork--selenium2模拟chrome的user agent