Change Browser Capabilities through Robot Framework

时间:2015-06-25 19:01:27

标签: selenium-webdriver robotframework

I do not have privileges to change IE settings locally. I wrote a Java Code to change the capabilities of IEDriver using : DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); caps.setCapability( InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); I want to do the same thing while using the selenium webdriver in Robot Framework. I want to do something like this. But I do not know the right way to do it. *** Keywords *** Test Browser ${options}= Evaluate sys.modules['selenium.webdriver'].DesiredCapabilities.INTERNETEXPLORER sys,selenium.webdriver Call Method ${options} add_argument INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS:True Create WebDriver Internet Explorer ie_options=${options} Open Browser To Login Page Open Browser ${LOGIN URL} ${BROWSER} Maximize Browser Window Set Selenium Speed ${DELAY} Login Page Should Be Open Thanks a lot!

3 个答案:

答案 0 :(得分:7)

DesiredCapabilities的Selenium文档中,列出了可配置的属性。必需的属性是ignoreProtectedModeSettings,必须设置为True

connection.execute(<<-SQL)
    insert into country1 (col1, col2) 
    select col1, col2 from countries
  SQL

答案 1 :(得分:1)

对于任何来这里寻求在Robot Framewor中解决this problem的人:

Set Chrome Desired Capabilities
    [Documentation]  Create the desired capabilities object with which to instantiate the Chrome browser.
    ${dc}                       Evaluate    sys.modules['selenium.webdriver'].DesiredCapabilities.CHROME  sys, selenium.webdriver
    ${experimental_options}     Create Dictionary      useAutomationExtension   ${False}
    Set To Dictionary           ${dc}       chromeOptions   ${experimental_options}
    Set Global Variable         ${DESIRED_CAPABILITIES}  ${dc}

答案 2 :(得分:0)

正如Pavol Travnik所述,David的答案不再有效。在某个时刻,ignoreProtectedModeSettings键被放置在功能字典中的se:ieOptions字典中。以下是适用于IEDriverServer较新版本的代码:

${ie_dc} =      Evaluate  
    ...         sys.modules['selenium.webdriver'].DesiredCapabilities.INTERNETEXPLORER 
    ...         sys, selenium.webdriver
${ieOptions} =  Create Dictionary  ignoreProtectedModeSettings=${True}
Set To Dictionary   ${ie_dc}  se:ieOptions  ${ieOptions}
Open Browser    ${url}  ie  desired_capabilities=${ie_dc}

如果您调试Selenium的Python库(尤其是webdriver / remote / webdriver.py)并查看start_session中的响应,就可以看到此内容。