I am using .net PhantomJS lib(namespace OpenQA.Selenium.PhantomJS) to implement a project trying to catch all the script error within a page. I couldn't find a way to enable onError described in this page:
There is no option in PhantomJSDriverService class, neither a PhantomJS command line option. How can I enable this in .net?
My code snippet:
PhantomJSDriverService service = PhantomJSDriverService.CreateDefaultService(myPhantomJSPath);
PhantomJSDriver) webDriver = new PhantomJSDriver(service);
string script = File.ReadAllText("onError.js");
var result = webDriver.ExecutePhantomJS(script);
EventFiringWebDriver driver = new EventFiringWebDriver(webDriver);
driver.ExceptionThrown += myExceptionHandler;
It will throw script error exception on a call to execute script directly on my code, like this:
Driver.ExecuteScript("var y=window.prompt(\"Test script with error\");window.alert(z);");
but won't throw similar script error exception on a page which contains similar error, script portion of my page looks like:
<script>
var y=1;alert(mm);
</script>
Does anyone know how to make this work on throwing error on script error on a page?
Thanks,
Xun