1

after some lost hours browsing internet, I'm not able to find the solution. I'm currently trying to test my app on older versions of Firefox (here, v41.0) for some reasons. I'm passing by a docker image of Selenium for the hub (v3.4.0) and a docker image for the Firefox node (v41.0).

I know that for older versions of Firefox, Geckodriver, isn't compatible but it seems having a solution using

{ "marionette": true }

The Firefox node is perfectly connecting to the grid. I can connect to it using docker exec -it <container-id> bash but the issue appears while running the test.

I'm still trying to find it but I'm blocked. Here the code of the Dockerfile: hub.docker.com/r/selenium/node-firefox/~/dockerfile/ for the Firefox node and here is the code for the test (using MochaJS).

test.it("should redirect to Google with FIREFOX 41.0", () => {

    var firefoxCap = Capabilities.firefox();
    firefoxCap.set('marionette', true);

    driver = new webdriver.Builder()
        .usingServer(CONSTANTS.SELENIUM_HUB)
        .withCapabilities(firefoxCap)
        .build();

    driver.get(CONSTANTS.GOOGLE_URL);
    driver.wait(until.titleIs(CONSTANTS.GOOGLE_TITLE));
    driver.wait(until.elementLocated(By.name(CONSTANTS.GOOGLE_SEARCH_KEY))).sendKeys(CONSTANTS.GOOGLE_SEARCH_VALUE);
    driver.findElement(By.name(CONSTANTS.GOOGLE_SEARCH_BUTTON_NAME)).click();
    driver.wait(until.titleIs(CONSTANTS.GOOGLE_SEARCH_TITLE));
    driver.wait(until.elementLocated(By.tagName(CONSTANTS.GOOGLE_RES_LINK))).click();
    driver.wait(until.titleIs(CONSTANTS.GOOGLE_TITLE));
    driver.quit();
});

Here the logs

~/dev/selenium-grids/src$ mocha --timeout 30000 tests.js 
Starting the tests...


  Work with REMOTE URL
    1) should redirect to Google with FIREFOX 41.0


  0 passing (6s)
  1 failing

  1) Work with REMOTE URL should redirect to Google with FIREFOX 41.0:
     WebDriverError: Missing 'marionetteProtocol' field in handshake
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'd4b3266d29f4', ip: '172.17.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-87-generic', java.version: '1.8.0_131'
Driver info: driver.version: FirefoxDriver
remote stacktrace: stack backtrace:
   0:           0x5787ed - backtrace::backtrace::trace::h59229d13f6a8837d
   1:           0x578942 - backtrace::capture::Backtrace::new::h23089c033eded8f0
   2:           0x450aec - geckodriver::marionette::MarionetteHandler::create_connection::h6f7058fccafe4367
   3:           0x425c32 - <webdriver::server::Dispatcher<T, U>>::run::h8f5348b8f5f7c053
   4:           0x40b22c - std::panicking::try::do_call::hb67c6fb6bcd96195
   5:           0x5dc20a - panic_unwind::__rust_maybe_catch_panic
                        at /checkout/src/libpanic_unwind/lib.rs:98
   6:           0x41b943 - <F as alloc::boxed::FnBox<A>>::call_box::h4100941edc372034
   7:           0x5d48a4 - alloc::boxed::{{impl}}::call_once<(),()>
                        at /checkout/src/liballoc/boxed.rs:650
                         - std::sys_common::thread::start_thread
                        at /checkout/src/libstd/sys_common/thread.rs:21
                         - std::sys::imp::thread::{{impl}}::new::thread_start
                        at /checkout/src/libstd/sys/unix/thread.rs:84
      at Object.checkLegacyResponse (node_modules/selenium-webdriver/lib/error.js:517:15)
      at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:509:13)
      at doSend.then.response (node_modules/selenium-webdriver/lib/http.js:441:30)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:169:7)
  From: Task: WebDriver.createSession()
      at Function.createSession (node_modules/selenium-webdriver/lib/webdriver.js:777:24)
      at Function.createSession (node_modules/selenium-webdriver/firefox/index.js:667:55)
      at createDriver (node_modules/selenium-webdriver/index.js:167:33)
      at Builder.build (node_modules/selenium-webdriver/index.js:629:16)
      at Context.test.it (tests_web.js:64:14)
      at runTest (node_modules/selenium-webdriver/testing/index.js:164:22)
      at node_modules/selenium-webdriver/testing/index.js:185:16
      at new ManagedPromise (node_modules/selenium-webdriver/lib/promise.js:1085:7)
      at controlFlowExecute (node_modules/selenium-webdriver/testing/index.js:184:14)
      at TaskQueue.execute_ (node_modules/selenium-webdriver/lib/promise.js:3092:14)
      at TaskQueue.executeNext_ (node_modules/selenium-webdriver/lib/promise.js:3075:27)
      at asyncRun (node_modules/selenium-webdriver/lib/promise.js:2982:25)
      at node_modules/selenium-webdriver/lib/promise.js:676:7
      at <anonymous>
  From: Task: Work with REMOTE URL should redirect to Google with FIREFOX 41.0
      at Context.ret (node_modules/selenium-webdriver/testing/index.js:183:10)



Closing the tests

When googling the issue because "Google is your friend", the only responses are "Update your Firefox versions" or "Downgrade your Selenium version" but I can't. Can someone explain me how to make it work? Even a workaround would be accepted.

Thanks

gigouni
  • 11
  • 3

1 Answers1

1

While you work with Selenium 3.4.0 with Mozilla Firefox 41.0 you need to downgrade your geckodriver to either version v0.17.0 or v0.16.1 or v0.16.0.

The following were the last announced dependency:

geckodriver v0.18.0 now recommends Firefox 53 and greater

geckodriver v0.16.0 is only compatible with Selenium 3.4 and greater

Finally, assuming the geckodriver.exe absolute path is within your System/User Path you have to explicitly set the marionette property to false (mandatory)

Your code block will be looking like:

test.it("should redirect to Google with FIREFOX 41.0", () => {

    var firefoxCap = Capabilities.firefox();
    firefoxCap.set('marionette', false);

    driver = new webdriver.Builder()
        .usingServer(CONSTANTS.SELENIUM_HUB)
        .withCapabilities(firefoxCap)
    .build();

Java Code to open legacy Mozilla Firefox 47.0.1 (geckodriver v0.16.1) :

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class Opening_FIREFOX_legacy 
{
    public static void main(String[] args) 
    {
        System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver-v0.16.1-win64\\geckodriver.exe");
        DesiredCapabilities dc = DesiredCapabilities.firefox();
        dc.setCapability("firefox_binary", "C:\\Program Files\\Mozilla Firefox47\\firefox.exe");
        dc.setCapability("marionette", false);
        WebDriver driver =  new FirefoxDriver(dc);
        driver.manage().window().maximize();
        driver.get("https://google.com");
    }
}

Python Code to open legacy Mozilla Firefox 47.0.1 (geckodriver v0.18.0) :

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

binary = FirefoxBinary(r'C:\Program Files\Mozilla Firefox47\firefox.exe')
caps = DesiredCapabilities().FIREFOX
caps["marionette"] = False
driver = webdriver.Firefox(capabilities=caps, firefox_binary=binary, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe")
driver.get('https://stackoverflow.com')
Community
  • 1
  • 1
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I tried it but it doesn't seem to like it neither. Here the edit for firefoxCapabilities `firefoxCap.set('marionette', false);` and using Geckodriver v0.16 and v0.17. The logs are different ` Error: You may not use a custom command executor with the legacy FirefoxDriver`. Any idea? – gigouni Aug 07 '17 at 08:51
  • I've found this article http://qavalidation.com/2016/08/whats-new-in-selenium-3-0.html/, do you think I should pass by System.setProperty(...)? – gigouni Aug 07 '17 at 08:55
  • Nopes you can't bypass `System.setProperty(...)` while working with `Selenium 3.x` Thanks – undetected Selenium Aug 07 '17 at 09:04
  • Provide you all the helps I had in my armor :) Let me know if those helps. – undetected Selenium Aug 07 '17 at 09:39
  • I'm not able to make it works. Do you have any example using previous version of Firefox? – gigouni Aug 07 '17 at 10:05
  • Well I am pretty new to Selenium-JavaScript combo :) simply got npm & webdriver installed. Maybe I will need a couple of days time to get back to you with a solution. Thanks – undetected Selenium Aug 07 '17 at 10:10
  • Which IDE do you use for `node.js`? Can you guide me to a documentation on how to setup an `IDE` for `node.js` and write code so that I can help you out? Thanks – undetected Selenium Aug 07 '17 at 10:18
  • When setting ` let firefoxCap = Capabilities.firefox(); firefoxCap.set('marionette', false); firefoxCap.set('javascriptEnabled', true);`, I've got a new error "Error: You may not use a custom command executor with the legacy FirefoxDriver". For the IDE, I'm using Visual Studio Code. Simple but effective. It's maybe not the perfect one but it's my favorite one. Here some resource: https://code.visualstudio.com/nodejs – gigouni Aug 07 '17 at 13:13