Getstyle only gives default style

Ranorex Spy, Recorder, and Studio.
Fandora
Posts: 9
Joined: Thu Apr 30, 2015 2:55 pm

Getstyle only gives default style

Post by Fandora » Tue Jul 28, 2015 9:46 am

Hello,

I got a problem with the function getstyle.

I search an element (divTag) in a webdocument, and then try to inspect the different styles of

Report.Info(textElement.GetStyle("color"));
// textElement is my divTag
but the color is not correctly displayed, in the report, I only have rgb(0, 0, 0) while in the HTML the color is rgb(136,65,65)

the style in html code (same as in "style" if I track the element in the repository) is :
font-weight:normal;font-style:italic;font-family:Arial;text-decoration:underline;position:relative;top:0px;display:inline;color:rgb(136,65,65);


I have a similar problem with the style "text-decoration", which only displayed "none" instead of "underline"

Thank you for your help

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

Re: Getstyle only gives default style

Post by odklizec » Tue Jul 28, 2015 9:53 am

Hi,

Could you please post some more details about your web app, system and Ranorex?

What's your Ranorex version?
Is this problem applicable to a specific browser or it's the same in all major browsers (IE, FF, Chrome, Opera)?
Could you please post a sample HTML code, which we can test with Ranorex?
Ranorex snapshot would be nice too, but not necessary, if you post the HTML code.
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

Fandora
Posts: 9
Joined: Thu Apr 30, 2015 2:55 pm

Re: Getstyle only gives default style

Post by Fandora » Tue Jul 28, 2015 10:04 am

Thank for your rapidity

I use Chrome (not tried on the other browser), and ranorex version is 5.1.4.21168

sorry but I cannot tell you the app or post html

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

Re: Getstyle only gives default style

Post by odklizec » Tue Jul 28, 2015 10:11 am

Thanks for the reply. Sadly, without the HTML sample is next to impossible to tell what's wrong and if there is a workaround. You don't have to post the code of entire web app! Just a single divTag with used style code should be enough. All we need is the code of subjected div tag, so we can test it for example here:
http://www.w3schools.com/tags/tryit.asp ... l_div_test
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

Fandora
Posts: 9
Joined: Thu Apr 30, 2015 2:55 pm

Re: Getstyle only gives default style

Post by Fandora » Tue Jul 28, 2015 10:19 am

here is the html code of the element, don't know if this helps

<div style="font-weight:normal;font-style:italic;font-family:Arial;position:relative;top:0px;display:inline;color:rgb(216,40,40);">ll</div>

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

Re: Getstyle only gives default style

Post by odklizec » Tue Jul 28, 2015 11:50 am

Thanks for the code, it definitely helped. Well, the good news is that the GetStyle definitely works in latest Ranorex 5.4. It correctly returns RGB(216,40,40) from the given div tag.
So now there are two options...

1) There is a problem in version 5.1.4 you are using, so the only way for you may be to update Ranorex with later version (actual is 5.4).

2) The rxpath behind the "textElement" you are referring to in your code points to something else than the div tag? Could you please share the rxpath behind the "textElement"?
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

Fandora
Posts: 9
Joined: Thu Apr 30, 2015 2:55 pm

Re: Getstyle only gives default style

Post by Fandora » Tue Jul 28, 2015 1:22 pm

Unfortunately I cannot change the version (we are many to use the same version for the project)

i find the element with this line :
DivTag textElement = rootDiv.FindSingle(".//div[@innerText='" + innerText + "']");
were innerText is "ll" and rootDiv one of the element's parent (cannot put it in the repository, the element I want to test could be created during the test and is not necessarily the same at each iteration of the test

Fandora
Posts: 9
Joined: Thu Apr 30, 2015 2:55 pm

Re: Getstyle only gives default style

Post by Fandora » Tue Jul 28, 2015 1:45 pm

I found!!

thank for your help, it was effectively the element pointed that wasn't correct
thank a lot for your time and suggestions which helped me a lot in finding what was wrong

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

Re: Getstyle only gives default style

Post by odklizec » Tue Jul 28, 2015 1:47 pm

You are welcome! ;)
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