I use Selenium WebDriver to automate some scripts. Most of the functionality is done using JavaScript endpoints, and I could not move this logic in Python:
// Python Selenium script data = self.driver.execute_async_script('selenium.get_data(arguments)') // JavaScript placed somewhere on the page tested selenium.get_data = function(args) { $.ajax({ url:'http://servername/ajax_data', success: function(data) { args[0](data); }, error: function(data) { // here I would like to notify selenium that everything is broken } }); };
There is usually a certain point in JavaScript when I know that everything is already broken, and I would like to make an exception in the Selenium script. Of course, I could wait for a timeout, but the timeouts of my scripts are quite long, and I could not provide additional information about debugging in the error message.
(http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/JavascriptExecutor.html) (http://code.google.com/p/selenium/source/browse/trunk/java/client/test/org/openqa/selenium/ExecutingAsyncJavascriptTest.java?r=15810).
, :
error: function(data) { window.alert(JSON.stringify(data)); }
?
: