Reputation: 75
Need help to get the Selenium cssSelector for the following td attribute to extract the title text that is "Nothing here"
<table id="myTable">
<thead>
<tbody data-bind="foreach: data">
<tr>
<td data-bind="attr: { title: $root.tooltipText($data) }" title="Nothing here">
<i class="colNotes fa hasNoNotes fa-comments-o" data-bind="click: function () { $root.noteClicked($data) }, css: $root.notesCssStyling($data)">
<span class="colNotesText" data-bind="text: NumberOfNotes">0</span>
</i>
</td><br/>
</tr>
<tr>
<td data-bind="attr: { title: $root.tooltipText($data) }" title="Nothing here">
<i class="colNotes fa hasNoNotes fa-comments-o" data-bind="click: function () { $root.noteClicked($data) }, css: $root.notesCssStyling($data)">
<span class="colNotesText" data-bind="text: NumberOfNotes">0</span>
</i>
</td>
</tr>
<tbody>
</table>
I have tried the following with no luck
driver.findElement(By.cssSelector("#myTable tr:nth-child(1) td[data-bind^='attr: { title']")).getAttribute("title");
Upvotes: 0
Views: 1467
Reputation: 75
Thanks for all the help. This is the final working code to get the title.
driver.findElement(By.cssSelector("#myTable td:nth-child(1)")).getAttribute("title"));
Upvotes: 0
Reputation: 8386
EDIT: Assuming you just want to get the first td in your table, this will work:
driver.findElement(By.cssSelector("#myTable td")).getAttribute("title");
Upvotes: 0