Robot Framework Selenium ChromeOptions
1 min read

Robot Framework Selenium ChromeOptions

I've found that there is a lack of resources for defining Google Chrome settings in RobotFramework's SeleniumLibrary (formerly Selenium2Library). Recently, I needed to connect my Selenium containers with a proxy for a project I was working on. I needed to set the chromeOptions proxy-server flag. Unfortunately, I couldn't find much online for this use case. While the SeleniumLibrary documentation technically explains this, its definitely not clear and took a lot of trial and error before I figured this out. There are many ways to do this when you write a custom keyword of your own and use the native selenium library (SO example). You can use this method to set other ChromeOptions too

I used 4 spaces as my seperator. You can change that to whatever your RF project uses.

${list} =     Create List    --proxy-server=http://${ip address}:${port}
${args} =     Create Dictionary    args=${list}
${desired caps} =     Create Dictionary    platform=${OS}     chromeOptions=${args}
Open Browser    remote_url=${grid_url}    browser=${BROWSER}    desired_capabilities=${desired caps}

${desired caps} is where the compiled desired capabilities should go. By creating a list and then a dictionary, we create the object that Chrome expects for its ChromeOptions.

Here are the required data types broken down with some other examples and where too find out what data type is required.

desired_capabilites => dictionary
    browserName => string
    version => string
    platform => string
    chromeOptions => dictionary
        binary => string
        args => list of strings
        extensions => list of strings

The desired_capabilities are from the [Selenium Wiki]

The chromeOptions are from this the [Chrome Driver Docs]

My library versions for reference:


StackOverflow python method (instead of test-type, just set the proxy option):

DesiredCapabilities capabilities =;
ChromeOptions options = new ChromeOptions();
capabilities.setCapability("chrome.binary", "<Path to binary>");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
webDriver = new ChromeDriver(capabilities);