how to use coordinates wisely and successfully?

Ask general questions here.
AutomationTester
Posts: 30
Joined: Mon Jan 21, 2013 1:31 pm

how to use coordinates wisely and successfully?

Post by AutomationTester » Wed Jan 23, 2013 10:43 am

Hai all,

My testscripts are running successfully in my computer. But, when the screen resolution changes, it all get messed up. Can any one tell me how to use get coordinates of an element and to use them wisely, so that my testscripts can run in any size monitor screen?

Note: I'm using coordinates hard code. :!:

Thanks in advance,
Amir aka Automation Tester :wink:

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: how to use coordinates wisely and successfully?

Post by sdaly » Wed Jan 23, 2013 11:28 am

How about just using RX paths to find target elements -

Code: Select all

Button b = "/button[@text='Start']";
b.Click();
..and if you need to carry out an action in a specific place on that element, use relative locations -

Code: Select all

b.Click(Location.CenterRight);

AutomationTester
Posts: 30
Joined: Mon Jan 21, 2013 1:31 pm

Re: how to use coordinates wisely and successfully?

Post by AutomationTester » Wed Jan 23, 2013 2:14 pm

Dear S Daly,

I have already tried your code in some lines. But, I have to click Just a little diagonal (Say 20 by 20 pixel) from topleft corner. How can I get the screen location of an element for top leftcorner? I will add and make my script stabilize. I have attached a snapshot of the imag

Regards

Amir aka Automation Tester
Attachments
image snap.PNG
image snap.PNG (84.37 KiB) Viewed 3275 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to use coordinates wisely and successfully?

Post by Support Team » Thu Jan 24, 2013 1:56 pm

Hi,

You could calculate the proportional position of the point (20,20) in the image and use this relative values for the click action as shown below:
yourElement.Click(new Location(double xFactor, double yFactor));
For more details please take a look at our online API.

Regards,
Markus
.
Image

AutomationTester
Posts: 30
Joined: Mon Jan 21, 2013 1:31 pm

Re: how to use coordinates wisely and successfully?

Post by AutomationTester » Fri Jan 25, 2013 12:39 pm

Hai Markus,

Thanks a lot. I calculated the coordinates by some assumption calculation and IT works perfectly well in any kind of resolution.

Thanks,

Amir

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to use coordinates wisely and successfully?

Post by Support Team » Fri Jan 25, 2013 2:00 pm

Hi,

I am glad I was able to point you in the right direction :).

Regards,
Markus
.
Image