我试图在同一页面中找到一个重复的元素。我尝试使用我在FirePath中找到的以下XPath,但是通过我的 selenium 自动化测试,我没有成功运行它。
这是两个XPath:
//div[@id='selectGenericMult']/child::div/child::input']
(//*[@id='selectGenericMult']/child::div/child::input)[last()]
这是我页面上的信息:
<input class="ui-select-search input-xs ng-pristine ng-valid ng-touched" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" placeholder="Selecione" ng-disabled="$select.disabled" ng-hide="$select.disabled" ng-click="$select.activate()" ng-model="$select.search" role="combobox" aria-label="Select box" ondrop="return false;" style="width: 1331px;" type="text"/>
Screenshot with the two fields and part of the HTML code
Another screenshot with the the HTML code of both input text, showed on the first screenshot
答案 0 :(得分:0)
要根据您提供的HTML
查找元素,您可以使用以下唯一xpath
:
//input[@class='ui-select-search input-xs ng-pristine ng-valid ng-touched'][@placeholder='Selecione']
答案 1 :(得分:0)
好的,所以我终于有时间来查看它(不是真的,但是花时间),根据你的截图,这应该适用于这两个元素。你可能需要稍微调整它们,但希望不是。
第一元素:
.currency .ui-grid-cell-contents:before{
content: '$';
float: left;
}
第二元素:
//div[contains(@class,"ng-scope")]//input
我测试了他们,他们工作正常。如果它不能以某种方式为你工作,请告诉我。
我建议调查xpath如何工作并研究它,一旦掌握了它,它实际上非常有趣。只需一些简单的参数,您就可以在屏幕上找到任何内容。
祝你好运!