When attempting to locate
css=table#Salarytable.dataTable.3.4
in Selenium IDE, the cell highlights correctly. However, when using this locator in my Selenium code...
String salary=driver.findElement(By.cssSelector("table#Salarytable.dataTable.3.4")).getText();
I encounter an error stating that an illegal string is present. EDIT: The HTML code is as follows:
<table id="Salarytable" class="dataTable" cellspacing="0" border="0" style="border-collapse:collapse;">
The stacktrace reads:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
(...)
at org.openqa.selenium.remote.ErrorHandler$UnknownServerException: An invalid or illegal string was specified
Build info: version: '2.35.0', revision: '8df0c6b', time: '2013-08-12 15:43:19'
System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2', java.version: '1.6.0_35'
Driver info: driver.version: unknown
I understand how to achieve this using XPath, but I specifically want to utilize CSS. How can this be accomplished? EDIT: Currently, I have implemented "table#Salarytable > tbody > tr:nth-of-type(3) > td:nth-of-type(4)" in my WebDriver code and it functions properly. However, I am puzzled as to why a locator (css=table#Salarytable.dataTable.3.4) that worked in Selenium IDE does not work in WebDriver code. Thank you.