I have this code that works fine in IE and Chrome but for some reason it does not work in Firefox. In IE and Chrome the alert box pops up and also in their console the error is displayed, but in firefox the console
never gets the message nor is the alert shown. Its like somehow Firefox swallows the error. Funny thing is if I dont use element.click and manually click the link it will then thrown the error in the console but still no alert.
If I dont use webdriver and load things directly with firefox then everything works.
I am using Jruby 1.6.7 and firefox 11 for testing.
The html that I am using is
======================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript" ></script>
<script type="text/javascript">
window.onerror = function(msg, url, linenumber){
alert(msg);
}
$(document).ready(function() {
$('#link').on('click',function(e) {
$(this).text("clicked");
blah.text("hello");
$(this).text('after error');
});
});
</script>
</head>
<body>
<h1 id="#msg">JavaScript Runtime Error Triggered By Interacting With A Page Element</h1>
<a href="#" id="link">call error function</a>
</body>
</html>
======================================================================
And the webdriver code is
======================================================================
require "rubygems"
require "selenium-webdriver"
driver = Selenium::WebDriver.for :firefox
#Selenium::WebDriver::Chrome.path = "C:\chormedriver.exe"
#driver = Selenium::WebDriver.for :chrome
#driver = Selenium::WebDriver.for :ie
driver.navigate.to "http://www.blah.com/testapp/triggered_erroralert.html"
element = driver.find_element(:id, 'link')
#open webconsole to view if there is any error
sleep 5
element.click
======================================================================