Firefox 中的 SeleniumIDE,使用定位器
css=table#students tr +tr td +td +td +td +td +td +td +td
mytext
用于表格的第三行的最后一列。
使用 css 定位器执行此操作的任何更短的方法?
在我切换到 xpath 之前,它类似于
//table//tr//td[contains(@text,'mytext')]
或
//table//tr//td[8][text='mytext']
最佳答案
如果你想找到最后一列,试试last-of-type (我没有在 Selenium-IDE 上测试它,但适用于 WebDriver)
table#students tr + tr > td:last-of-type
如果你只想索引td之一,使用nth-of-type
table#students tr + tr > td:nth-of-type(8)
如果您必须使用文本来查找它,那么这不能使用 Css Selector 来完成,除非您使用 Sizzle .
table#students tr + tr > td:contains(mytext)
关于可以缩短多张 CD 的 css 选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16639319/