0

I am trying to access table using selenium. I wanted to take action on one table data i.e. link. But I dont have any attribute of that link which could be permanent. I have table data of other field which is having fixed text.Its sibling of link td.

<tr class="ng-scope" ng-repeat="key in DeviceList">
<td>
<a class="ng-binding" href="#" ng-click="clickedDevice($index)">012</a>
</td>
<td class="ng-binding">Yuvraj</td>
<td>
<i class="fa fa-trash-o fa-lg" ng-click="deleteDevice(key.devId)"></i>
</td>
</tr>

Q: How to access that link using text of other td using Java + Selenium?

1
1

If element is link text then you can use by link text element locator to locate that element.

Use below operation: By.linkText or By.partialLinkText.

1
  • yes, that would be a simplest solution but I dont know what text will be there :( Any other solution? I am not having text or id or any locator for that link Sep 29 '16 at 8:11
0

It seems you want to access/locate the a link with reference to another element. With xpath we could achieve this by using 'sibling' or 'following' keywords. In automated testing services there are multiple locator strategies we could use like Xpath and Css. Css also have feature to access sibling element. Please refer to the tutorial which is related to use of siblings and references: http://zvon.org/xxl/XPathTutorial/Output/example15.html

Hope that helps.

4
0

You can use css path if that too doesn't work try to customize xpath. To know more about it click here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.