Reputation:
I'm using JavaScript, not Java here. But, for example, if I am running a particular website, say foo.com, I will set it up like:
var webdriver = require("selenium-webdriver");
By = webdriver.By,
until = webdriver.until;
var chrome = require("selenium-webdriver/chrome");
var path = require("chrome");
var service = new chrome.ServiceBuilder(path).build();
chrome.setDefaultService(service);
var driver = new webdriver.Builder()
.forBrowser("chrome")
.build()
driver.get("foo.com");
I am interested in catching non-Selenium based errors. So for example, this is an error I see pretty often that I'd like to test for:
Uncaught TypeError: Cannot read property 'testVariable' of undefined
at test.js:27
How do I grab the site specific errors? I'd like to create a function that helps me with it. Maybe something like:
var seekErrors = function(){
return driver.(some function to get a list of js errors or things output to the console)
}
Is there anything like this in Selenium WebDriver? If so, I would really appreciate the help.
Upvotes: 1
Views: 178
Reputation: 790
Have a look at DesiredCapabilities within Selenium and the LoggingPref object.
More info on the SeleniumHQ wiki.
Here is an example using it in Firefox
Upvotes: 2