Different information between browsers

Best practices, code snippets for common functionality, examples, and guidelines.
Juan
Posts: 19
Joined: Wed Jul 20, 2016 1:18 pm

Different information between browsers

Post by Juan » Fri Oct 07, 2016 11:40 am

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
You do not have the required permissions to view the files attached to this post.

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

Re: Different information between browsers

Post by odklizec » Mon Oct 10, 2016 1:49 pm

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");
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
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Different information between browsers

Post by Support Team » Wed Oct 12, 2016 2:55 pm

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

Juan
Posts: 19
Joined: Wed Jul 20, 2016 1:18 pm

Re: Different information between browsers

Post by Juan » Thu Oct 13, 2016 2:55 pm

Thanks! I solved it with elementName.getstyle("text-decoration"); :D

Juan
Posts: 19
Joined: Wed Jul 20, 2016 1:18 pm

Re: Different information between browsers

Post by Juan » Mon Oct 17, 2016 10:04 am

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?
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Different information between browsers

Post by Support Team » Tue Oct 18, 2016 1:46 pm

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

Juan
Posts: 19
Joined: Wed Jul 20, 2016 1:18 pm

Re: Different information between browsers

Post by Juan » Tue Oct 18, 2016 2:22 pm

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

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

Re: Different information between browsers

Post by odklizec » Wed Oct 19, 2016 8:52 am

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?
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

Juan
Posts: 19
Joined: Wed Jul 20, 2016 1:18 pm

Re: Different information between browsers

Post by Juan » Wed Oct 19, 2016 9:21 am

The CSS styles are different but they return always same 'Without any Style' values
styles.png
You do not have the required permissions to view the files attached to this post.

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

Re: Different information between browsers

Post by odklizec » Wed Oct 19, 2016 11:07 am

Please post the code as a text, not as a picture. Thanks! ;)
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

Juan
Posts: 19
Joined: Wed Jul 20, 2016 1:18 pm

Re: Different information between browsers

Post by Juan » Wed Oct 19, 2016 11:11 am

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;
}

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

Re: Different information between browsers

Post by odklizec » Wed Oct 19, 2016 11:18 am

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)
Last edited by odklizec on Wed Oct 19, 2016 11:24 am, 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

Juan
Posts: 19
Joined: Wed Jul 20, 2016 1:18 pm

Re: Different information between browsers

Post by Juan » Wed Oct 19, 2016 11:24 am

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!

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

Re: Different information between browsers

Post by odklizec » Wed Oct 19, 2016 11:26 am

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?
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

Juan
Posts: 19
Joined: Wed Jul 20, 2016 1:18 pm

Re: Different information between browsers

Post by Juan » Wed Oct 19, 2016 11:32 am

I didn't test it. I believe in you :), but I will try myself