Page 1 of 2

Different information between browsers

Posted: Fri Oct 07, 2016 11:40 am
by Juan
Hi all. I coded one test in C# to be executed in chrome, firefox and internet explorer. In my test for a couple of methods, I use Dynamic attributes to operate with them. In chrome and firefox the information is the same but in internet explorer no and I cannot identify styles as in firefox and chrome. Is there any option to cope with this? Thanks

Re: Different information between browsers

Posted: Mon Oct 10, 2016 1:49 pm
by odklizec
Hi,

Could you please post an HTML sample describing your problem? Use for example http://jsfiddle.net/ where you can publish both HTML and CSS code so we can clearly see the issue. Thanks!

BTW, even if the "style" attribute is not displayed in Spy (in IE), it my still be possible to obtain particular style from code, for example like this:

Code: Select all

string textDecoration= elementName.getstyle("text-decoration");

Re: Different information between browsers

Posted: Wed Oct 12, 2016 2:55 pm
by Support Team
Hello Juan,

I'm sorry to tell you that the 'style' attribute is currently not supported in IE.
As mentioned by odklizec you could use the WebElement.GetStyle() method to read specific style properties.

Another workaround would be accessing certain style properties in the RanoreXPath directly. For example, you could use 'text-align' to identify the h1 tag in every browser.

Code: Select all

<h1 style="color:blue;text-align:center">This is a header</h1>
RanoreXPath: /dom[@caption='Tryit Editor v3.1']//h1[@text-align='center']

I hope this information will help you.

Sincerely,
Johannes

Re: Different information between browsers

Posted: Thu Oct 13, 2016 2:55 pm
by Juan
Thanks! I solved it with elementName.getstyle("text-decoration"); :D

Re: Different information between browsers

Posted: Mon Oct 17, 2016 10:04 am
by Juan
No I found another problem... These are my styles:
style.png
And using GetStyle() this is what I obtain in my Report in internet explorer:

'TextEdit No Wrap'
text-decoration: none (expected underline)
font-style: normal (expected italic)
font-weight: 400 (expected bold)
background-color: #fff (expected red)

'TextEdit With Wrap'
text-decoration: none (expected underline)
font-style: normal (expected italic)
font-weight: 400 (expected bold)
background-color: #fff (expected red)


Those expected values It's what I obtain in Chrome and Firefox using Dynamic values from style.

Why in internet explorer I obtain different values and why cannot the values are the same for both styles in internet explorer?

Re: Different information between browsers

Posted: Tue Oct 18, 2016 1:46 pm
by Support Team
Hi Juan,

Unfortunately, the result of the WebElement.GetStyle() method depends on the browser. Nevertheless, the returned result is valid in any case.

For example, the font-weight "400" is equivalent to "normal". In this case, you will need to handle both browsers separately. I would suggest implementing a user code action that checks which browser is currently tested and processes the result accordingly.

Thank you for your understanding.

Sincerely,
Johannes

Re: Different information between browsers

Posted: Tue Oct 18, 2016 2:22 pm
by Juan
Yes, but the main problem is that with IE it doesn't matter what's the text style. It's always returning the same values for every different styles so I can only handle different styles with Chrome and Firefox but not with IE

Re: Different information between browsers

Posted: Wed Oct 19, 2016 8:52 am
by odklizec
Hi Juan,

As mentioned by Johannes, IE displays HTML style values differently, but of course, they should not be the same for each style you use ;) So could you please post an HTML/CSS sample we can examine?

Re: Different information between browsers

Posted: Wed Oct 19, 2016 9:21 am
by Juan
The CSS styles are different but they return always same 'Without any Style' values
styles.png

Re: Different information between browsers

Posted: Wed Oct 19, 2016 11:07 am
by odklizec
Please post the code as a text, not as a picture. Thanks! ;)

Re: Different information between browsers

Posted: Wed Oct 19, 2016 11:11 am
by Juan
Text without style

HTML

<label class="nvc-edit-label" style="font-style: normal; font-weight: normal; text-decoration: none;">TextEdit No Wrap</label>

CSS
{
text-decoration: none;
font-style: normal;
font-weight: normal;
}

Text with style

HTML

<label class="nvc-edit-label" style="font-style: italic; font-weight: bold; text-decoration: underline; background-color: red;">TextEdit With Wrap</label>

CSS
{
text-decoration: underline;
font-style: italic;
font-weight: bold;
background-color: Red;
}

Re: Different information between browsers

Posted: Wed Oct 19, 2016 11:18 am
by odklizec
So, I just tried it (with Ranorex 6.1 Spy and IE11) and it seem the GetStyle works for me as expected?
I got this from GetStyle (called from Spy):
TextEdit With Wrap:
text-decoration = underline
font-style = italic
font-weight = 700 (means bold in IE)
background-color = red
TextEdit No Wrap:
text-decoration = none
font-style = normal
font-weight = 400 (means normal in IE)

Re: Different information between browsers

Posted: Wed Oct 19, 2016 11:24 am
by Juan
We are currently using Ranorex 5.4.6. I suppose we have to migrate to 6.1 version. I hope with this new version this problem is no longer happening. Thanks!

Re: Different information between browsers

Posted: Wed Oct 19, 2016 11:26 am
by odklizec
Apparently, it got fixed? ;) I believe there was a "style" related bug resolved in 6.x? Anyway, it seems the GetStyle works in 6.1?

Re: Different information between browsers

Posted: Wed Oct 19, 2016 11:32 am
by Juan
I didn't test it. I believe in you :), but I will try myself