Reputation: 12434
I am attempting to find a table cell using a CSS selector in Selenium. This is my selector:
//table[@id='prepaymentItemsDataGrid']//tr[@class='tablerowlight']/td[3]
The exception being thrown is:
Driver.FindElementByCssSelector("//table[@id='prepaymentItemsDataGrid']//tr[@class='tablerowlight']/td[3]") threw an exception of type 'OpenQA.Selenium.InvalidSelectorException'
What is wrong with my selector? How do I know what Selenium is complaining about?
I have tried simplifying it to:
//table[@id='prepaymentItemsDataGrid']
which has no effect.
Does Selenium have a different method of executing CSS selectors and how can I check that the selector is valid before trying to run it?
Upvotes: 0
Views: 394
Reputation: 193338
Though you have tried to use FindElementByCssSelector()
but the values were of XPath. You can use either of the following Locator Strategies :
CssSelector :
Driver.FindElementByCssSelector("table#prepaymentItemsDataGrid tr.tablerowlight > td:nth-of-type(3)");
XPath :
Driver.FindElementXPath("//table[@id='prepaymentItemsDataGrid']//tr[@class='tablerowlight']/td[3]");
Upvotes: 4