Capturing Label Attributes in Selenium

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Capturing Label Attributes in Selenium

VaibhavCSC
Hi All,

I needed some help in detecting the attributes of a label attached to the TextBox field through Selenium.
My requirement is to find out the spacing between a label and the text box below it. And also, I need to find out the spacing between a label and its adjoining image.

Please provide your responses for the same.
Thanks

Reply | Threaded
Open this post in threaded view
|

Re: Capturing Label Attributes in Selenium

softwaretestingforum
Administrator
Hi Vaibhav,

You can use methods like - getElementPositionLeft, getElementPositionTop to get the position of element.
I f you could post one snap shot of page then I could better guide you.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Capturing Label Attributes in Selenium

VaibhavCSC
Snap


As you can see in the attachement, we have a asterisk sign(*) attached with label.
We need to check through Selenium that there is no spacing between the image(*) and the label.

Also, we need to check the distance between a field(textbox) and its label.

Can you please suggest.

Note: The * image does have any name , its attributes are just Mandatory
Reply | Threaded
Open this post in threaded view
|

Re: Capturing Label Attributes in Selenium

softwaretestingforum
Administrator
You could try this -

getElementPositionLeft("elementLocatorForAsterisk")

getElementPositionLeft("elementLocatorForLabel")

subtraction of these should be within some limit, say - 5 or 6

But then I would suggest against doing such automation to compare pixel level info as it is bound to fail from configuration to configuration. Automation tests should be more logical then pixel based.



~ seleniumtests.com