简体   繁体   English

使用Selenium监视JavaScript错误和404

[英]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. 我想在我们的组织中设置一个基本的监视服务,该服务监视javascript错误或404的关键URL列表。 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. 我想制作一个ASP.Net Web应用程序来执行此操作,并将任何错误记录到Elmah中-我们用于所有内部/外部Web应用程序的工具。 The web applicataion would periodically poll a list of URLs for errors. Web应用程序将定期轮询URL列表以查找错误。

I was hoping to use Selenium for this. 我希望为此使用Selenium。 Specifically PhantomJS.exe as this is a webkit-based headless browser implementation. 特别是PhantomJS.exe,因为这是基于Webkit的无头浏览器实现。

However, it seems that trapping errors in rendering of pages is not the strong point of Selenium! 但是,似乎在页面渲染中捕获错误并不是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. 也许我正在以错误的方式进行操作-我希望能够导航到URL,然后检查错误收集和/或陷阱404相关事件。

Any suggestions as to how I can get this working using Selenium or other tools would be most appreciated :) 我将如何使用Selenium或其他工具来完成这项工作的任何建议,将不胜感激:)

Thanks. 谢谢。

You can do this pretty easily with TrackJS error monitoring . 您可以使用TrackJS错误监视非常轻松地做到这一点。 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. 当Selenium(或任何其他用户)在页面上遇到错误时,它将被报告给服务。

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. 如果要使其自动化,可以在硒测试中检查TrackJS API ,以断言现在在测试的最后X分钟内发生了错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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