css定位器,可缩短多个td';s

css定位器,可缩短多个td';s,css,selenium,css-selectors,Css,Selenium,Css Selectors,firefox中的硒酰胺,使用 css=table#students tr +tr td +td +td +td +td +td +td +td mytext 用于表格行的最后一列。 使用css定位器有没有更短的方法 在切换到xpath之前,它类似于 //table//tr//td[contains(@text,'mytext')] 或 如果您想找到最后一列,请尝试(我没有在Selenium IDE上测试过它,但它适用于WebDriver) 如果您只想为td中的一个建立索引,请使用第n个类型

firefox中的硒酰胺,使用

css=table#students tr +tr td +td +td +td +td +td +td +td
mytext
用于表格行的最后一列。
使用css定位器有没有更短的方法

在切换到xpath之前,它类似于

//table//tr//td[contains(@text,'mytext')]


如果您想找到最后一列,请尝试(我没有在Selenium IDE上测试过它,但它适用于WebDriver)

如果您只想为td中的一个建立索引,请使用第n个类型

table#students tr + tr > td:nth-of-type(8)
如果您必须使用文本来查找它,那么除非使用Css选择器,否则无法完成此操作


只是对上一个XPath的一个小更正,我认为它应该是
//table//tr//td[8][text()='mytext']
,如果必须选择包含该文本的
td
,则不能使用CSS定位器。@Michaeldurrent:哦,你的意思是定位器不起作用或在Selenium IDE上不起作用?此外,这与您提供的css定位器相匹配,而不是与您使用的xpath相匹配。正如BoltClock所说,css不支持定位文本,除非您使用sizzle。
table#students tr + tr > td:last-of-type
table#students tr + tr > td:nth-of-type(8)
table#students tr + tr > td:contains(mytext)