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
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

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

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: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

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