How to deal with JavaScript error: "e is null" when trying to click on a browser popup in Firefox

When using selenium-webdriver warning methods, I encountered a JavaScript error: "e is null"

the code:

browser = Watir::Browser.new :firefox browser.alert.ok; sleep 5 

Mistake:

 Selenium::WebDriver::Error::UnknownError: [JavaScript Error: "e is null" {file: "file:///var/folders/f4/rz3xgqkj22zdyldyzrnyx4v40000gn/T/webdriver-profile20140731-47367-tyngix/extensions/ fxdriver@googlecode.com /components/command_processor.js" line: 7716}]' [JavaScript Error: "e is null" {file: "file:///var/folders/f4/rz3xgqkj22zdyldyzrnyx4v40000gn/T/webdriver-profile20140731-47367-tyngix/extensions/ fxdriver@googlecode.com /components/command_processor.js" line: 7716}]' when calling method: [nsICommandProcessor::execute] 

Environment:

  • 'selenium-webdriver', '2.42.0'
  • Firefox 31.0
  • MAC 10.9
  • Ruby 2.0

Any advice would be greatly appreciated. Thanks!

+7
javascript firefox testing selenium-webdriver watir-webdriver
source share
4 answers

My was triggered by JavaScript warnings. There Ajax selects a date that periodically partially makes. Although this is something that needs to be fixed in the application, at the same time I can handle this:

 try{ driver.findElement(By.xpath("//span")).click(); } catch (UnhandledAlertException uae) { driver.switchTo.alert().accept(); driver.findElement(By.xpath("//span")).click(); } 

I would also like to indicate that I am using WebDriver, so the syntax may be different.

+1
source share

So this is not what you want to hear, but this is my super hacky solution:

  target=browser.ul(:id => 'editor_sections').li(:index => j) target.drag_and_drop_by -300,200 begin browser.button(:id => 'editor_panel_save').when_present.click puts "clicked save for module sidebar" rescue => e begin browser.alert.ok puts Thread.current["name"].white.on_red + ": No events for the " +sectionName + " module" rescue => e end end 

As you can see, the drag event for me triggers a jquery warning. I had the same problem as with the browser. Alert.ok does not always work. So I just wrapped it in an extra block -> start. In fact, browser.alert.ok is called and the warning is rejected. And that annoying random e is an empty error, is ignored.

If anyone has a real solution, I would like to see it.

+1
source share

I'm not sure about the syntax of Watir, but below is the Java code for handling alerts.

 Alert alert=driver.switchTo().alert(); alert.accept(); 
0
source share

We cannot answer this, because the problem is in your javascript code (which is not included).

 Selenium::WebDriver::Error::UnknownError: [JavaScript Error: "e is null" {file: "file:///var/folders/f4/rz3xgqkj22zdyldyzrnyx4v40000gn/T/webdriver-profile20140731-47367-tyngix/extensions/ fxdriver@googlecode.com /components/command_processor.js" line: 7716}]' 

The problem is in command_processor.js on line 7716.

-4
source share

All Articles