Element position in website

Class library usage, coding and language questions.
rbnfdez
Posts: 2
Joined: Mon Mar 18, 2013 5:59 pm

Element position in website

Post by rbnfdez » Tue Mar 19, 2013 10:54 am

Hi @ll,
I'm automating a website, and i'm looking for a way to know the position (X,Y axis) of
an element to assure in each regression test the element is always placed in the same position.
For instance, i have the following web element in ranorex:

ButtonTag Ingresar = JuegosOnline.FindSingle("/dom[1]//button[#'btnLogin']");
// element definition
Ingresar.EnsureVisible(); // assure is visibled

Is there any way to do that?

thanks in advance,
ruben

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Element position in website

Post by Ciege » Tue Mar 19, 2013 4:02 pm

Use RanorexSpy to look at your Element(s). You should be able to find the information you want from the .ScreenRectangle.Location.X & .ScreenRectangle.Location.Y attributes...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

rbnfdez
Posts: 2
Joined: Mon Mar 18, 2013 5:59 pm

Re: Element position in website

Post by rbnfdez » Tue Mar 19, 2013 5:19 pm

Thanks for the answer.
the problem is in Spy that atributes appear in "disabled" color, ans i can not acces them.
I have tried with this code (itps for another element):

InputTag Beta = Contacto.FindSingle("/dom[1]//div[#'wpcf7-f605-p79-o1']/form/div[2]/div[1]/div[1]/div/div[1]/div/span/input");
try{
Validate.Attribute(Beta,"Visible","True");
Validate.Attribute(Beta,"Enabled","True");
Validate.Attribute(Beta,"TagName","input");
Validate.Attribute(Beta,"Name","name");
Validate.Attribute(Beta,"ScreenLocation.X","522");
Validate.Attribute(Beta,"ScreenLocation.Y","552");
}catch (Exception e)
{
Report.Failure("error :"+e);
}

But the last Attributes ScreenLocation.X & ScreenLocation.Y generate the following error:

Attribute 'ScreenLocation.X' of element '{InputTag:name}' does not match the specified value (actual='(null)', expected='522').

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

Re: Element position in website

Post by Support Team » Wed Mar 20, 2013 3:47 pm

Hello,

Unfortunately, you could not use Validate.Attribute to validate ScreenRectangle or ScreenLocation from your element. Please check the value with a common IF-ELSE statement.

You should be able to get this value by the following code:
Report.Info(Beta.ScreenRectangle.X.toString());
Another way would be to use the method Validate.AreEqual().

Regards,
Markus (T)
.
Image

mdgairaud
Posts: 87
Joined: Sun Aug 05, 2012 11:59 am
Location: Bilbao, Spain

Re: Element position in website

Post by mdgairaud » Mon May 20, 2013 4:51 pm

Hi Rubén,

Is your item loaded with AJAX? Because I had a similar issue with a form loaded with AJAX. I didn't request the position, only interact with it but a homemade workaround fixed it. :roll:

Hope next release solves it... :mrgreen:



regards,
Mateo.

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

Re: Element position in website

Post by Support Team » Tue May 21, 2013 4:38 pm

Hello,

Thank you for your feature request.

ScreenLocation is not returned as an attribute. This is by design.
Additionally, "AttributeName.PropertyName" is only supported for a few technologies.

Therefore, I recommend to use Validate.AreEqual().

Regards,
Markus (T)
.
Image