简体   繁体   中英

Monitoring for JavaScript errors and 404s with Selenium

I want to set up a basic monitoring service within our organisation that monitors a list of key URLs for javascript errors or 404s. This way we will know if we've made any really obvious mistakes moving code into production!

I want to make a ASP.Net web application to do this and log any of the errors into Elmah - the tool we use for all of our internal/external web applications. The web applicataion would periodically poll a list of URLs for errors.

I was hoping to use Selenium for this. Specifically PhantomJS.exe as this is a webkit-based headless browser implementation.

However, it seems that trapping errors in rendering of pages is not the strong point of Selenium! Maybe I'm going about this the wrong way - I was hoping to be able to Navigate to a URL and then inspect an errors collection and/or trap 404-related events.

Any suggestions as to how I can get this working using Selenium or other tools would be most appreciated :)

Thanks.

You can do this pretty easily with TrackJS error monitoring . Put our agent on the pages you want to check, even the internal private ones. When Selenium (or any other user) encounters an error on the page, it will be reported to the service.

If you want to automate it, you can check the TrackJS API as part of your selenium test to assert that now errors have occurred in the last X minutes of the test.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM