Using CSS selectors to access specific table rows with selenium Using CSS selectors to access specific table rows with selenium selenium selenium

Using CSS selectors to access specific table rows with selenium


You can use nth-child selector:

#items tr:nth-child(4) {color:#F00;}

Live example: https://jsfiddle.net/7ow15mv2/1/

But no idea if it works with Selenium.

But according to docs it should.

Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, :only-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after).


Do you want to select by content ("Item 4")? By Position (the 4st row)? Or is <tr id="foo"> and selecting tr#foo>tdan option?