How to add Selenium Arg. in addition to chrome arg

Hello,

I have a problematic in adding selenoid (docker) arguments as follow:

&{REMOTE_CAPABILITIES} name=${None} videoName=${None} enableVideo=${True} enableVNC=${True} screenResolution=1920x1080x24 videoScreenSize=1920x1080 enableLog=${True} timeZone=Europe/Paris

To the chrome option as follow my non working solution is as follow

Open Chrome

[Arguments]    ${SELENIUM_REMOTE}=${None}
${chrome options}    BuiltIn.Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
# SET ARGS TO OPTIONS
Call Method    ${chrome_options}    add_argument    --start-maximized
Call Method    ${chrome_options}    add_argument    --disable-infobars
Call Method    ${chrome_options}    add_argument    --ignore-certificate-errors
Call Method    ${chrome_options}    add_extension   autom-rbf-tests/Resources/proxy.crx
${chrome options}    Set Chrome Disable Popup Automation    ${chrome options}

${remote_args}     Create List
...    name=${TEST NAME}   videoName=${TEST NAME}
...    enableVideo=${True}  enableVNC=${True}
...    screenResolution=1920x1080x24  videoScreenSize=1920x1080
...    enableLog=${True}    timeZone=Europe/Paris
${remote_args}     Create Dictionary    ${remote_args}

run keyword unless    ${REMOTE}    SeleniumLibrary.Open Browser    url=None    browser=chrome    desired_capabilities=${capabilities}
run keyword if        ${REMOTE}    SeleniumLibrary.Open Browser    browser=chrome    remote_url=${SELENIUM_REMOTE}    desired_capabilities=${remote_args}

Thanks for your help

Selenoid example. Create file (for example test.py) and paste this:

from selenium import webdriver

firefox_options = webdriver.firefox.options.Options()
firefox_options.set_preference("devtools.toolbox.footer.height", 0)
firefox_options.set_preference("devtools.netmonitor.persistlog", True)
firefox_options.set_preference("devtools.toolbox.selectedTool", "netmonitor")
firefox_options.add_argument("--devtools")
firefox_options.add_argument("--profile")
firefox_options.add_argument("./Temp/profile")


capabilities = firefox_options.to_capabilities()

capabilities["browserName"] = "firefox"
capabilities["version"] = "71.0"
capabilities["platform"] = "LINUX"
capabilities["enableVNC"] = True

Then, in your test you add test.py as a variable file in settings, so there will be variable ${capabilites} set in RF

Variables test.py

After that in your test add the following line:
Create Webdriver Remote command_executor=http://your_selenoid_host:your_selenoid_port/wd/hub desired_capabilities=${capabilities}

This example is for Firefox browser custom profile, but you can easily convert it for Chrome

P.S. Formatter here eating space between Create Rebdriver and Remote, please note that it’s driver type, not a keyword

desired_capabilities does not work anymore.
how to pass the enableVNC and enableVideo=True now in browser options?

For the record this is the correct way to use Selenoid with Robot Framework passing the arguments in the browser options:

${selenoid_args} Create Dictionary enableVNC=${True} enableVideo=${True}

Open Browser ${URL} ${BROWSER} remote_url=${SELENOID_SERVER}
options=set_capability(“selenoid:options”,${selenoid_args})

1 Like