如何识别IWebElement

时间:2015-05-25 18:56:03

标签: .net selenium testing frontend

如果我有一个元素,由某个选择器By定义,是否有一种很好的方法可以将它识别给(测试)用户?

例如:

var element = driver.Find(By.CssSelector(".some .css"));

throw new SomeCustomTestingException(element);

使用哪些好的属性,以便测试输出允许用户识别元素?

e.g。

"Error with element with Css = something"
"Error with element on page MyPage with XPath"

1 个答案:

答案 0 :(得分:1)

使用Selenium的本机记录器。 LoggingPreferences。它提供多级别的日志记录等等。 遗憾的是,这些API在.NET中是不可用的。另一个选项可以是log4Net