Page 1 of 1
Element position in website
Posted: Tue Mar 19, 2013 10:54 am
by rbnfdez
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
Re: Element position in website
Posted: Tue Mar 19, 2013 4:02 pm
by Ciege
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...
Re: Element position in website
Posted: Tue Mar 19, 2013 5:19 pm
by rbnfdez
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').
Re: Element position in website
Posted: Wed Mar 20, 2013 3:47 pm
by Support Team
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)
Re: Element position in website
Posted: Mon May 20, 2013 4:51 pm
by mdgairaud
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.
Hope next release solves it...
regards,
Mateo.
Re: Element position in website
Posted: Tue May 21, 2013 4:38 pm
by Support Team
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)