Bing Bing - 29 days ago 14x
Python Question

How to use Marionette web driver in robotframework after upgrade browser to Firefox 47

I was using robotframework Selenium2Library to run test in Firefox.
As I upgrade Firefox to version 47, I found Firefox will crash at the beginning when Firefox starts. The issue is in github issue list as follow link:

So I turned to using Marionette as issue comments suggested, but the result is not good(the error shows: WebDriverException: Message: connection refused, and using selenium directly won't help). Also from selenium2Library guide page, it tells desired_capabilities will not work for local webdriver.

So my questions are:

  1. How can I setup a local Marionette webdriver instance inside Selenium and pass to robot for further testing operations?

  2. If there is a way to keep using Firefox 47 without webdriver support?

I followed instructions here:

in a python file:

def returnFirefoxCapabilities(marionetteBinaryPath):
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = marionetteBinaryPath
return firefox_capabilities

and in robot file:

*** Settings ***
Library Selenium2Library #build-in library
*** Test Case ***
try marionette
${firefox_capabilities}= returnFirefoxCapabilities path/wires
open browser desired_capabilities=${firefox_capabilities}


Selenium2Library does not support passing in desired capabilities for local webdrivers. But you can change the default capabilities for Firefox and it will apply to all future webdriver instances for a given browser type until the interpreter (Python) exits. I was able to run simple tests with Firefox 47, Selenium 2.53.5, and Geckodriver 0.8.0.

${ff default caps}    Evaluate    sys.modules['selenium.webdriver'].common.desired_capabilities.DesiredCapabilities.FIREFOX    sys,selenium.webdriver
Set To Dictionary    ${ff default caps}    marionette=${True}
Open Browser    ff

You asked how to pass in a webdriver instance. This appeared to me as an X-Y problem, so I did not answer that question. Please ask a separate question if needed.