GetAttributeValue varies behavior across the browsers

Class library usage, coding and language questions.
bellew.mike
Posts: 10
Joined: Wed Jan 14, 2015 1:20 pm

GetAttributeValue varies behavior across the browsers

Post by bellew.mike » Mon Mar 16, 2015 2:28 pm

Hi,

Firstly let me just state that we do not use the ranorex repo. I mainly just create WebElements as needed and use them from C# code.
Also I am using Ranorex 5.3.0.22324

I have 2 questions to ask really:

1. I have noticed the getAttributeValue<T>(string) function on Adapter (and things that inherit from Adapter) is protected. Is there a particular reason you haven't implemented the ability to query attributes from the adapter and have to use the adapter.element.GetAttributeValue() function? Just seems to be the only place I have ever had to use the adapter.element property.

2. This is the actual issue here. WebElement.Element.GetAttributeValue() appears to work for any attributes of an element which are visible in ranorex spy (for instance "Class" or "Id"). However if i use the statement WebElement.Element.GetAttributeValue("clientWidth"); The correct value is returned when using IE but in Firefox and Chrome, null is returned. This appears to be true for most of the values I have tried.
Is this a ranorex bug? limitation? or is the fact that it works in IE just plain luck?
Also is there a workaround to get these values?

Thanks in advance,
Mike

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: GetAttributeValue varies behavior across the browsers

Post by Support Team » Wed Mar 18, 2015 4:12 pm

Hello Mike,

Concerning your first questions, basically this was a design decision because string names should not be used when using adapters. However it may make sense when using dynamic attributes and actions. Please write an email to [email protected] if you want to make a feature request.

The problem with the value of the "clientWidth" attribute is that Internet Explorer returns JS/HTML element attributes, but Firefox and Chrome don't.
As workaround please try the ExecuteScript method as shown below.
webdoc.ExecuteScript("return document.getElementById('idofyourelement').clientWidth");
Regards,
Bernhard
.
Image

rastek
Posts: 157
Joined: Wed Aug 06, 2014 12:00 pm

Re: GetAttributeValue varies behavior across the browsers

Post by rastek » Mon Jun 08, 2015 2:14 pm

Hi

I also get this error
'Ranorex.Adapter.Protected Function GetAttributeValue(Of T)(name As String) As T' is not accessible in this context because it is 'Protected'. (BC30390) - D:\Users\ravci\Documents\Ranorex\RanorexStudio Projects\TID\TID\Recording1.UserCode.vb:36,11

All I want to to is get text from a web element on my tested page, how can I achieve this ?

I tried

myString= repo.myWeb.txt2.InnerText().ToString
or
myString = repo.myWeb.txt.getAttributeValue("Text").toString()

but dont get any result. ranorex finds objects but I can not get any property

I hope there is someone overthere to help me,

Thanks.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: GetAttributeValue varies behavior across the browsers

Post by Support Team » Tue Jun 09, 2015 2:39 pm

Hi rastek,

May I ask you to post a Ranorex snapshot file of the element you want to get the text from?
The following link will show you how to generate a snapshot file: Creating Ranorex Snapshot Files.

Thanks,
Markus
.
Image