Search This Blog

Subscribe:

Tuesday, September 7, 2010

How to use Selenium ClickAt Command

Folks nowadays I'm working on automation and open source tool selenium is been used. Frankly speaking, tool is awesome but still it has some loop holes, workarounds need to be done to get work done. I was trying to click on the rows on the grid and took me 2 hours to figure out how to do.

Here with an example I will tell how and what needs to be done.

Problem description: You had a grid with rows have values and need to click on the basis of values.

Grid looks like this.


abc

Some-Description1

Date1

Comments1

def

Some-Description2

Date2

Comments2

ghi

Some-Description3

Date3

Comments3

jkl

Some-Description4

Date4

Comments4

mno

Some-Description5

Date5

Comments5

pqr

Some-Description6

Date6

Comments6






Now, the requirement says, click on ghi which might open another window. (How to capture the window is not dealt here). When recording from selenium IDE, gave me click command with some XPATH but when I ran same command from IDE, it wasn't working at all.



Solution: Use clickAt(String locator, String co-ordinates)



Selenium IDE do not records clickAt(this was the catch here). I changed click to clickAt and it worked perfectly fine.



so command becomes :



selenium.clickAt("//div[contains(text(),\"ghi\")]","");





locator = "//div[contains(text(),\"ghi\")]"

co-ordinates = ""



This command says, click at the link (given by the XPATH) which has text ghi with no co-ordinates.



Same way to click on grid abc =



selenium.clickAt("//div[contains(text(),\"abc\")]","");














0 comments:

Post a Comment