Note that there are some explanatory texts on larger screens.

plurals
  1. POCatch JavaScript Errors in Selenium WebDriver – Browser Independent
    primarykey
    data
    text
    <p>I am wondering if anyone could expand on any of these attempts or has any other ideas for catching JS errors using WebDriver that will work in Firefox, Chrome, Internet Explorer, and Safari.</p> <p>Here is what's been tried so far:<br> <strong>Attempt</strong> – Problem:</p> <p><strong>JSErrorCollector.jar</strong> - Works fine, but is a Firefox only solution.</p> <p><strong>Inject JS into page source</strong> – I injected <code>window.onerror</code> code into the page’s source code using WebDriver, but any initial errors are missed because the injection is too late.</p> <p><strong>BrowserMob</strong> – I can intercept the HTTP response and planned to inject the <code>window.onerror</code> code into response body, but the author has not implemented the <code>getBody()</code> method yet, so only headers can be modified, that I am aware of. The body is always null for all responses. (I was on a webpage where the author talked about implementing <code>getBody()</code> but it hasn’t happened yet and I cannot find it again)</p> <p><strong>Fiddler</strong> – JS will inject correctly, but Fiddler is Windows only so Safari won’t work.</p> <p><strong>Parent/Child windows</strong> – I use javascript to open and store a reference to the test page’s window. The <code>window.onerror code</code> is contained in the parent window so it will not miss startup errors in the child window. I cannot get this to work in anything but Firefox and Chome somewhat. I already asked a question about it <a href="https://stackoverflow.com/questions/17369327/getting-javascript-errors-from-another-window">here</a>.</p> <p><strong>Selenium RC</strong> – I haven’t tried it because all my tests use WebDriver, but I know it has some kind of method like <code>captureNetworkTraffic()</code>, but I don’t think it can be used in WebDriver.</p> <p><strong>IE error popup</strong> – I was going to use the parent/child solution for Firefox/Chrome and then look for the IE error popup. This popup displays when the setting is checked to display it. The popup is a native Window window (I think) so I cannot use selenium to access it.</p> <p><strong>Read browser console</strong> – I could not find a way to do this in all browsers. In Chrome I found a way to save the console log to a file and then read the file. That is as far as I got.</p> <p>I would like a solution similar to BrowserMob since it seems like it would be a cross browser solution. Are there any other proxies that can be put in the test and intercept the response? It would have been excellent if the <code>getBody()</code> method was implemented. I also like the parent/child solution because it also seems like a simple, cross browser solution, but it is not working for IE (<a href="https://stackoverflow.com/questions/17369327/getting-javascript-errors-from-another-window">parent/child question again</a>).</p> <p>Thanks for any help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload