编码的用户界面:通过CSS选择器查找元素 [英] Coded UI: Find Element(s) by CSS Selector
问题描述
我正在尝试构建页面的工具,以便我们可以针对该页面编写测试。我想做的是使用CSS选择器查找给定的一个或多个元素,而不是手动修改SearchProperties或FilterProperties。对于网络测试,CSS Selector似乎比SearchProperties直观得多。
I am trying to build out a harness for a page so that we can write tests against it. What I would like to be able to do is use a CSS selector to find the given element or elements instead of manually modifying the SearchProperties or FilterProperties.For a web test the CSS Selector seems far more intuitive then the SearchProperties do. Is there some mechanism for doing this that I am simply not seeing?
推荐答案
尝试一下...
https://github.com/rpearsondev/CodedUI.jQueryExtensions/
它将扩展方法添加到BrowserWindow对象...
It adds extension methods to the BrowserWindow object...
var example1 = browser.JQuerySelect<HtmlHyperlink>('a.class1');
var example2 = browser.JQuerySelect<HtmlListItem>('li.class2');
但是,我会告诉您它在抱怨定期转换错误方面存在问题。
However, I will let you know I'm having issues with it complaining about casting errors regularly.
这篇关于编码的用户界面:通过CSS选择器查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!