C#中硒的webdriver JavaScript错误日志 [英] C# Selenium webdriver JavaScript errors logging

查看:146
本文介绍了C#中硒的webdriver JavaScript错误日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我硒测试的webdriver使用C#。
我怎么可以记录所有可能经过我的测试中发生的JavaScript错误?

I'm testing with Selenium webdriver using C#. How can I log all JavaScript errors that could happen through my tests?

推荐答案

这取决于你的意思,如果你想,当你用它来捕捉你的代码生成的JavaScript错误:

That depends what you mean, if you want to capture javascript errors generated in your code when you use:

((IJavaScriptExecutor)_driver).ExecuteScript(一些JavaScript代码在这里 )

然后就换这些语句在一个try / catch /终于和日志例外。

Then just wrap those statements in a try/catch/finally and log the exception.

如果你想捕捉浏览器生成的JavaScript错误,那么简单的答案是:你不能轻易这样做。

If you want to capture javascript errors generated by the browser, then the short answer is: you can't easily do so.

长的答案:


  1. 使用Firefox的驱动程序

  2. 与自定义配置文件中实例化

  3. 安装的Firebug和ConsoleExport插件

  4. 适当配置通过 SetPreference()这些插件,这样它会自动导出控制台您选择的位置

  1. Use the Firefox driver
  2. Instantiate it with a custom profile
  3. install the Firebug and ConsoleExport plugins
  4. Appropriately configure those plugins via SetPreference() so that it will automatically export the console to a location of your choice

如果你需要一些示例代码,让我知道,我给你的真的的长的答案......

If you need some sample code, let me know and I'll give you the really long answer...

这篇关于C#中硒的webdriver JavaScript错误日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆