Page 1 of 1

Getstyle only gives default style

Posted: Tue Jul 28, 2015 9:46 am
by Fandora
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

Re: Getstyle only gives default style

Posted: Tue Jul 28, 2015 9:53 am
by odklizec
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.

Re: Getstyle only gives default style

Posted: Tue Jul 28, 2015 10:04 am
by Fandora
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

Re: Getstyle only gives default style

Posted: Tue Jul 28, 2015 10:11 am
by odklizec
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

Re: Getstyle only gives default style

Posted: Tue Jul 28, 2015 10:19 am
by Fandora
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>

Re: Getstyle only gives default style

Posted: Tue Jul 28, 2015 11:50 am
by odklizec
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"?

Re: Getstyle only gives default style

Posted: Tue Jul 28, 2015 1:22 pm
by Fandora
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

Re: Getstyle only gives default style

Posted: Tue Jul 28, 2015 1:45 pm
by Fandora
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

Re: Getstyle only gives default style

Posted: Tue Jul 28, 2015 1:47 pm
by odklizec
You are welcome! ;)