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
Element position in website
Re: Element position in website
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...
Ciege...
Re: Element position in website
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').
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').
- Support Team
- Site Admin
- Posts: 11999
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: Element position in website
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:
Regards,
Markus (T)
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
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.
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.
- Support Team
- Site Admin
- Posts: 11999
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: Element position in website
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)
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)