从匹配节点列表中选择第n个匹配节点 [英] Select an nth matched node from a list of matching nodes
本文介绍了从匹配节点列表中选择第n个匹配节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用selenium执行一些自动化,我试图与我的网页使用Selenium& CSS选择器。
I'm working with selenium to perform some automation and I'm attempting to interact with my webpage using Selenium & CSS selectors.
我的问题是如何从所有匹配节点的列表中选择返回的第n个匹配节点?
My question is how do I select the nth matched node returned from a list of all matching nodes?
例如,我的CSS选择器是.contactName,它返回2个匹配的节点。使用Selenium我想做像
For example my CSS selector is ".contactName" which returns 2 matching nodes. Using Selenium I want to do something like
selenium.Click("css=.contactName the second match");
推荐答案
< >解决方案
解决方案
这是我最后使用为了选择类名
This is what I ended up using in order to select the second input with the class name
selenium.Click("xpath=(//input[@class='contactName'])[2]");
这篇关于从匹配节点列表中选择第n个匹配节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文