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"?
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 totrue
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.