upgrade to python3 libraries
[testsuite.git] / robot / resources / browser_setup.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with VID. It handles low level stuff like managing the selenium request library and VID required steps
3 Library           Collections
4 Library           OSUtils
5 Library           OperatingSystem
6 Library           SeleniumLibrary
7 Resource          global_properties.robot
8
9 *** Variables ***
10 ${HEADLESS}   True
11
12 *** Keywords ***
13 Setup Browser
14     [Documentation]   Sets up browser based upon the value of ${GLOBAL_SELENIUM_BROWSER}
15     Run Keyword If    '${GLOBAL_SELENIUM_BROWSER}' == 'firefox'    Setup Browser Firefox
16     Run Keyword If    '${GLOBAL_SELENIUM_BROWSER}' == 'chrome'    Setup Browser Chrome
17     Log    Running with ${GLOBAL_SELENIUM_BROWSER}
18
19
20 Setup Browser Firefox
21     ${caps}=   Evaluate   sys.modules['selenium.webdriver'].common.desired_capabilities.DesiredCapabilities.FIREFOX   sys
22     Set To Dictionary   ${caps}   marionette=
23     Set To Dictionary   ${caps}   elementScrollBehavior    1
24     ${wd}=   Create WebDriver   Firefox   capabilities=${caps}
25     Set Global Variable    ${GLOBAL_SELENIUM_BROWSER_CAPABILITIES}    ${caps}
26
27  Setup Browser Chrome
28     ${os}=   Get Normalized Os
29     Log    Normalized OS=${os}
30     ${chrome options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys
31     Call Method    ${chrome options}    add_argument    no-sandbox
32     Run Keyword If  ${HEADLESS}==True  Call Method    ${chrome options}    add_argument    headless
33     ${dc}   Evaluate    sys.modules['selenium.webdriver'].DesiredCapabilities.CHROME  sys, selenium.webdriver
34     Set To Dictionary   ${dc}   elementScrollBehavior    1
35     Create Webdriver    Chrome   chrome_options=${chrome_options}    desired_capabilities=${dc}
36     Set Global Variable    ${GLOBAL_SELENIUM_BROWSER_CAPABILITIES}    ${dc}
37
38 Handle Proxy Warning
39     [Documentation]    Handle Intermediate Warnings from Proxies
40     ${status}    ${data}=    Run Keyword And Ignore Error   Variable Should Exist    ${GLOBAL_PROXY_WARNING_TITLE}
41     Return From Keyword if    '${status}' != 'PASS'
42     ${status}    ${data}=    Run Keyword And Ignore Error   Variable Should Exist    ${GLOBAL_PROXY_WARNING_CONTINUE_XPATH}
43     Return From Keyword if    '${status}' != 'PASS'
44     Return From Keyword if    "${GLOBAL_PROXY_WARNING_TITLE}" == ''
45     Return From Keyword if    "${GLOBAL_PROXY_WARNING_CONTINUE_XPATH}" == ''
46     ${test}    ${value}=    Run keyword and ignore error    Title Should Be     ${GLOBAL_PROXY_WARNING_TITLE}
47     Run keyword If    '${test}' == 'PASS'    Click Element    xpath=${GLOBAL_PROXY_WARNING_CONTINUE_XPATH}