Width of label

Ask general questions here.
User avatar
giuseppe.lacagnina
Posts: 113
Joined: Fri Sep 18, 2015 10:25 am
Location: Brunn am Gebirge, Vienna, Austria

Width of label

Post by giuseppe.lacagnina » Tue Feb 28, 2017 2:00 pm

Dear All,

I am doing some tests in HTML involving a label element, of which I need to check the width.
From the spy, I see
Capture.JPG
Capture.JPG (10.61 KiB) Viewed 496 times
But I simply do not know how to check in the test that the value is 300.
I have a repo item but I do not know how to put it into a form that will let me call GetValue or equivalent.

Can anyone help? Thanks!!!

User avatar
giuseppe.lacagnina
Posts: 113
Joined: Fri Sep 18, 2015 10:25 am
Location: Brunn am Gebirge, Vienna, Austria

Re: Width of label

Post by giuseppe.lacagnina » Tue Feb 28, 2017 2:07 pm

I actually managed to produce this code

int test = repo.Client.WizardSteps.FieldLabels.LblEditText.Element.Size.Width;

but when I debug... I get 0. The Spy sees "300".

qwertzu
Posts: 178
Joined: Wed Jan 25, 2017 11:08 am

Re: Width of label

Post by qwertzu » Tue Feb 28, 2017 2:21 pm

Hi guiseppe,

Have you already tried a Validation Action?
It validates if the width is 300 and reports success or failure.

Simply drag and drop the element from the repository to your actions and select validation.

Afterwards you can select the Match Name "Width" and the Match Value "300". (See attached Screenshot)

I hope, this will help!
Attachments
validation.png
validation.png (7.18 KiB) Viewed 492 times
scrSh.png
scrSh.png (24.95 KiB) Viewed 492 times

User avatar
giuseppe.lacagnina
Posts: 113
Joined: Fri Sep 18, 2015 10:25 am
Location: Brunn am Gebirge, Vienna, Austria

Re: Width of label

Post by giuseppe.lacagnina » Tue Feb 28, 2017 2:27 pm

Thanks, but unfortunately the test fails. It finds "100%" and not the actual value that I see in the Spy.
Is this the size of the parent? I tried the same on the parent div, and I get "auto".
Admittedly, the value is greyed out in the Spy. Does this mean it is not directly accessible? Strange.

qwertzu
Posts: 178
Joined: Wed Jan 25, 2017 11:08 am

Re: Width of label

Post by qwertzu » Wed Mar 01, 2017 11:01 am

Hi,

It is hard to help you without further information.
Would it be possible for you to upload a Ranorex Snapshot?
This will make it easier to assist you with your issue.

User avatar
giuseppe.lacagnina
Posts: 113
Joined: Fri Sep 18, 2015 10:25 am
Location: Brunn am Gebirge, Vienna, Austria

Re: Width of label

Post by giuseppe.lacagnina » Wed Mar 01, 2017 11:05 am

Unfortunately, I cannot. The issue now boils down to the fact that, when I try to access the width, I get 100%. But the Spy sees the real width, which is 300 pixels. If the real number cannot be retrieved, I will find some workaround.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Width of label

Post by odklizec » Wed Mar 01, 2017 12:09 pm

Hi,

Could you please post at least an HTML sample code with problematic label? Just the label itself, not the entire app.

Additionally, you can try ScreenRectangle method...

Code: Select all

int width= repo.Client.WizardSteps.FieldLabels.LblEditText.Element.ScreenRectangle.Width;
My guess is that the label is set to be loaded at 100% width of its parent element? Hence you get 100% instead of real size.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
giuseppe.lacagnina
Posts: 113
Joined: Fri Sep 18, 2015 10:25 am
Location: Brunn am Gebirge, Vienna, Austria

Re: Width of label

Post by giuseppe.lacagnina » Wed Mar 01, 2017 12:17 pm

Thanks! The rectangle size gives the same result. I will dig up the code and upload it as soon as I can.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Width of label

Post by odklizec » Wed Mar 01, 2017 12:21 pm

Yeah, I've expected that. My guess is that you will have to get the size of its parent element? But the strange thing is, why Spy returns correct size?

BTW, I just tried a simple HTML, where the style section sets the width of label to 100% and Ranorex correctly returns (both in IE and FF) its size in pixels, not just 100%. So I guess the problem must be somehow related to the HTML/stylesheets of your app or the browser you are using?
Last edited by odklizec on Wed Mar 01, 2017 12:46 pm, edited 1 time in total.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
giuseppe.lacagnina
Posts: 113
Joined: Fri Sep 18, 2015 10:25 am
Location: Brunn am Gebirge, Vienna, Austria

Re: Width of label

Post by giuseppe.lacagnina » Wed Mar 01, 2017 12:44 pm

Well, unsurprisingly, looking at the parent is no good either: it says "auto". It is probably a complex game of boxes and style inheritances. What I also do not understand is why the Spy sees the right number but than the test, dynamically, fails to see the number.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Width of label

Post by odklizec » Wed Mar 01, 2017 12:52 pm

Unfortunately, without at least Ranorex snapshot, but even better HTML sample, there is not much anyone here can do or suggest to help you with this problem.

If you can't share the snasphot at public place like this, try contact Ranorex support directly ([email protected]). I'm sure it's pretty safe to send them the snapshot/HTML. Or even better, they may do a remote session with you and suggest the best way to overcome your problem.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
giuseppe.lacagnina
Posts: 113
Joined: Fri Sep 18, 2015 10:25 am
Location: Brunn am Gebirge, Vienna, Austria

Re: Width of label

Post by giuseppe.lacagnina » Wed Mar 01, 2017 12:53 pm

Thanks!!! I never contacted the support, but I think it is time to do so.
Let us see :-)