selenium webdriver: How to click a random value stored in grid at unknown position .

by admin on March 7, 2014

The questions we are trying to answer here is : selenium webdriver: How to click a random value stored in grid at unknown position .
i had added a task lets say ‘Record1’ it gets stored in top of the grid with edit option and after that i had added some more tasks and all tasks have same edit option, now position of ‘Record1’ is changed to an unknown position, Now i want to create a script which always clicks on the edit button against the ‘Record1’ task.

so you can click on Edit option link by having following-sibling:: pattern in Xpath.
something like,
html/body/table/tbody/tr[3]/td[1]/following-sibling:: td[1]

html/body/table/tbody/tr[3]/td[1]- would be xpath to hit Record1
following-sibling:: td[1]- to hit Edit option link , depends on which td Edit link is present.

you will have to move around this xpath but i believe this approach will work.

#SQASolutionShare on FacebookShare on Google+Share on LinkedInTweet about this on TwitterEmail this to someone

Previous post:

Next post: