Page 1 of 1
how to use coordinates wisely and successfully?
Posted: Wed Jan 23, 2013 10:43 am
by AutomationTester
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
Re: how to use coordinates wisely and successfully?
Posted: Wed Jan 23, 2013 11:28 am
by sdaly
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 -
Re: how to use coordinates wisely and successfully?
Posted: Wed Jan 23, 2013 2:14 pm
by AutomationTester
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
Re: how to use coordinates wisely and successfully?
Posted: Thu Jan 24, 2013 1:56 pm
by Support Team
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
Re: how to use coordinates wisely and successfully?
Posted: Fri Jan 25, 2013 12:39 pm
by AutomationTester
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
Re: how to use coordinates wisely and successfully?
Posted: Fri Jan 25, 2013 2:00 pm
by Support Team
Hi,
I am glad I was able to point you in the right direction
.
Regards,
Markus