0

I've just upgraded by Selenium Test Project to use the new version 3.0.1 from 2.53.0. I'm now using Geckodriver v0.11.1 and am currently testing exclusively on Firefox, which is version 46.0.1.

Before the upgrade I had code that looked like this:

driver.Navigate().GoToUrl(DefaultBaseURL);
driver.ExecuteScript("$('#" + XXXX + "').val(\"" + XXXX + "\");");

After the upgrade the second line now fails, with the following error:

WebDriverException: ReferenceError: $ is not defined

I can make work again if I enable "UseLegacyImplementation". According to the Selenium's website this is "indicating whether to use the legacy driver implementation." So, not a whole lot of detail there... but when I enable it, it seems to run in the same manner as 2.53.0.

My first guess on this issue is that it's timing related, similar to the post mentioned here. But even when I put large wait times between the two lines the end result is always the same. It appears as though the new selenium library is unable to detect that the page has already loaded jQuery.

Is there a way to invoke JQuery dependent scripts in Selenium 3.0.1, without enabling "UseLegacyImplementation"?

Community
  • 1
  • 1
David Rogers
  • 2,601
  • 4
  • 39
  • 84

1 Answers1

0

The UseLegacyImplementation property tells the .NET bindings to use the legacy, browser-extention-based driver implementation developed and maintained by the Selenium project itself. In other words, setting it to true tells the binding not to use geckodriver. One of the changes from 2.x to 3.x is that the default value of this property changed. In 3.x, it defaults to attempting to use geckodriver.

If you're using geckodriver, you'll find that the experience is better with later versions of Firefox. What you may be experiencing may be a bug with geckodriver that has already been fixed in a later browser version. I would recommend either remaining with the legacy Selenium-project implementation (UseLegacyImplementation = true) if you want to remain with Firefox 46. If you want to use geckodriver, you should move to a more recent version of Firefox.

JimEvans
  • 27,201
  • 7
  • 83
  • 108
  • Thank you for the assistance, I upgraded to Firefox 47.0.2, which should be the latest version and disabled "UseLegacyImplementation" but I still have the same issue, maybe its something environmental :( Also do you have a guide or reference as to what version of each component is compatible with what other component, typically I look at the release notes, but its a rather time intensive and, at times, incomplete way to get that information? – David Rogers Dec 19 '16 at 15:32
  • The Selenium documentation is really a shame. The information it gives is incomplete or even completely missing. – Elmue Feb 27 '17 at 16:54
  • As with many all-volunteer open source projects, @Elmue, documentation is often not the first thing contributors think of. However, also like many all-volunteer open source projects, contributing to documentation is a great way to get involved with the project. If you think the documentation "is really a shame," pull requests are most assuredly welcome. – JimEvans Feb 28 '17 at 02:58
  • 1
    I do not agree with you. When I write code I always put a detailed comment at the top of each function that I write which explains what the function does and what parameters it takes. As the majority of Selenium documentation is generated automatically by Doxygen there would already be a useful documentation if Selenium folks would work the same way. But they do their work very sloppy. For example in FirefoxOptions the property "UseLegacyImplementation" has a useless comment "Gets or sets a value indicating whether to use the legacy driver implementation." This comment does not explain anythig – Elmue Feb 28 '17 at 21:16