Cucumber / Capybara Error: arguments[0] is undefined (Selenium::WebDriver::Error::JavascriptError)
Asked Answered
M

4

27

I've been running my tests via the terminal for a while now without any problems.:

cucumber Create\ New\ Game.feature

Which contains the following:

Feature: Create New Game

  Background: 
    Given I am logged in

  Scenario: Cleanup & New Game 01
    Then I Delete all test Games

And the ruby:

Given(/^I am logged in$/) do
  el = first("button[ttag='account_dropdown_btn']", :visible => true)
  if el.nil?
    logMeIn("[email protected]","pa55w0rd")
  end
end

logMeIn defined as:

# Logs the user in with given credentials
def logMeIn(username, password)
  page.driver.browser.manage.window.maximize
  visit ENV['BASE_URL']
  fill_in 'j_username', :with => username
  fill_in 'j_password', :with => password
  click_button 'Login'
end

None of the above has changed from when the tests were working until now. Today, when I start the tests, as soon as Firefox opens, I immediately get:

  Background:            # features/Create New Game.feature:4
    Given I am logged in # features/step_definitions/Generic Steps.rb:1
      arguments[0] is undefined (Selenium::WebDriver::Error::JavascriptError)

As you can see, it's failing on the first line. I don't know why.

I updated all my gems to make sure everything was fresh, but this didn't work. I thought it might have been a browser issue as my system automatically updated to Firefox 35.0 this morning. I uninstalled and tried 34 but it's still the same problem. None of the code has changed.

I don't know what other misconfiguration could've caused this as I haven't changed anything.

Can anyone help further with this error?

Mckenziemckeon answered 15/1, 2015 at 9:16 Comment(2)
It seems to be the update to Firefox 35. I just tried the ChromeDriver and it works. I don't believe it fully removed all residual associations to Firefox when I uninstalled it and downgraded to 34.Mckenziemckeon
This is a bug with Firefox 35 and Selenium-WebDriver. There is an issue open for it - code.google.com/p/selenium/issues/detail?id=8390.Uturn
C
16

Yes, the issue is with Firefox 35. Downgrade to version 34. Perhaps it's the way you went about downgrading. I simply ran the new DMG installer and confirmed overwriting the existing app.

Direct link: https://download-installer.cdn.mozilla.net/pub/firefox/releases/34.0.5/mac/en-US/Firefox%2034.0.5.dmg (link referenced from https://support.mozilla.org/en-US/kb/install-older-version-of-firefox)

More on this issue can be found here: https://code.google.com/p/selenium/issues/detail?id=8387

Communicant answered 24/1, 2015 at 23:30 Comment(1)
I put Firefox 34 in a separate directory and made my capybara use it by Selenium::WebDriver::Firefox::Binary.path = ENV['firefox_path'] if ENV['firefox_path'] and then setting that env variable when running cucumber.Songer
B
3

As Justin Ko commented, this is a bug with Firefox 35 and Selenium-WebDriver 2.44.0. The Selenium project has an issue ticket for it, and at time of writing, there is a pre-release gem (2.45.0.dev3) that includes the fix.

https://code.google.com/p/selenium/issues/detail?id=8390

Bibliogony answered 5/2, 2015 at 19:49 Comment(0)
I
2

As others have said, there is bug in Firefox 35. To avoid that, I found it easiest to config Capybara to run Selenium-tests in Chrome. So if you don't need to run tests particularly in Firefox, you can use chromedriver.

There is a gem for get it easily.

Irs answered 10/2, 2015 at 20:44 Comment(0)
R
0

Same issue with the firefox driver here.

Caused by: org.openqa.selenium.WebDriverException: arguments[0] is undefined
Command duration or timeout: 24 milliseconds
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40'
System info: host: '', ip: '', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_71'
Session ID: 49a4f55c-33b7-4ab8-aea5-cb3bb98041e1
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=WINDOWS, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=35.0.1}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
    at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:508)

Downgraded firefox to 34.0.5 and the Javascript click:

executeScript("arguments[0].click();", el);

Works again like a charm.

And it is quite important to have a working javascript click, since the native click is just way too unreliable.

Reactance answered 13/2, 2015 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.