Change Browser Capabilities through Robot Framework

末鹿安然 提交于 2019-12-23 17:06:03

问题


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!


回答1:


In the Selenium documentation for DesiredCapabilities, the configurable properties are listed. The required property is ignoreProtectedModeSettings which must be set to True

${dc}   Evaluate    sys.modules['selenium.webdriver'].DesiredCapabilities.INTERNETEXPLORER  sys, selenium.webdriver
Set To Dictionary   ${dc}   ignoreProtectedModeSettings ${True}
Open Browser    www.google.com  ie  desired_capabilitie=${dc}

${s2l}= Get Library Instance    Selenium2Library
Log Dictionary  ${s2l._current_browser().capabilities}  # actual capabilities



回答2:


For anyone that came here looking for a solution to this problem within Robot Framewor:

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}


来源:https://stackoverflow.com/questions/31058663/change-browser-capabilities-through-robot-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!