Can access getStyle from Ranorex Spy, but not Studio

Ranorex Spy, Recorder, and Studio.
acalhoun
Posts: 14
Joined: Mon Mar 04, 2013 11:09 pm

Can access getStyle from Ranorex Spy, but not Studio

Post by acalhoun » Mon Jul 08, 2013 9:59 pm

Hello,
I am trying to verify the color of a text object. When I right click on the object in Spy I can access GetStyle where I can specify the color property and it returns me the color code just like I want. However, in Studio, when I drag the object from the repo into the grid I don't get GetStyle as an option (see attached). I also tried doing it via a code module, but I get a compilation error that getStyle is not a member of Ranorex.Text. Why does it work via Spy, but not Studio and how can I get it to work so I can verify the color code is what I expect?

Thanks for your help!
Attachments
getStyle.PNG
getStyle.PNG (218.09 KiB) Viewed 1577 times

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

Re: Can access getStyle from Ranorex Spy, but not Studio

Post by Support Team » Tue Jul 09, 2013 12:53 pm

Hello,

Unfortunately it is not possible to get the value of the color property using the recorder actions, but you can try to use the GetStyle() in user code.
Please try to use the following code:
var myFlexElement = repo.YourElement;
var color = myFlexElement.As<FlexElement>().GetStyle("color");
Report.Info(color);
Please let me know if this doesn't work.
Thank you!

Regards,
Bernhard
.
Image

acalhoun
Posts: 14
Joined: Mon Mar 04, 2013 11:09 pm

Re: Can access getStyle from Ranorex Spy, but not Studio

Post by acalhoun » Tue Jul 09, 2013 1:27 pm

Hello,
I've tried that already, but I get an error that Value of type 'Ranorex.Text' cannot be converted to 'Ranorex.FlexElement'.

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

Re: Can access getStyle from Ranorex Spy, but not Studio

Post by Support Team » Wed Jul 10, 2013 2:40 pm

Hello,

In order to analyze the issue in more detail I would need more information about the application under test and your script.
Could you please post a Ranorex snapshot file from your application and the code snippet?
If you don't want to post the snapshot file in the forum you can also send it to [email protected].
Thank you!

Regards,
Bernhard
.
Image

acalhoun
Posts: 14
Joined: Mon Mar 04, 2013 11:09 pm

Re: Can access getStyle from Ranorex Spy, but not Studio

Post by acalhoun » Wed Jul 10, 2013 3:21 pm

Hi Bernhard,
These are the couple things I have tried so far and the results I get. I have also attached the Ranorex snapshot.

getStyle' is not a member of 'Ranorex.Text'. (BC30456) -
'Dim color As String = repo.POModule.crownPOAmtGrid_byPoType.getStyle("color")
'Report.Info(color)

Outputs null
'Dim myText As Text = repo.POModule.crownPOAmtGrid_byPoType
'Dim color As String = myText.Element.GetAttributeValue("color").ToString
'Report.Info(color)


Get a compiliation error - Value of type 'Ranorex.Text' cannot be converted to 'Ranorex.FlexElement'. (BC30311) - C:\development\workspaces\qa\trunk\Ranorex\CCIsites\ScriptLibrary\POModule\POModule\ValidateDataChanges.UserCode.vb:47,52
'Dim myFlexElement As FlexElement = repo.POModule.crownPOAmtGrid_byPoType
‘Dim color As String = myFlexElement.As<FlexElement>().GetStyle("color")
'Report.Info(color)
Attachments
POModule.rxsnp
(295.58 KiB) Downloaded 180 times

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

Re: Can access getStyle from Ranorex Spy, but not Studio

Post by Support Team » Thu Jul 11, 2013 1:27 pm

Hello,

Has the element "repo.POModule.crownPOAmtGrid_byPoType" the following path?
/dom[@domain='www.test.ccisites.com']//td[#'myTD']/flexobject/container/container/container/container/container/container/container/table/row/cell/element/text[@automationname='lblData']
If yes, could you please try the following code?
Dim myFlexElement as Text = repo.POModule.crownPOAmtGrid_byPoType
Dim color as String = myFlexElement.[As](Of FlexElement)().GetStyle("color")
Report.Info(color)
Regards,
Bernhard
.
Image

acalhoun
Posts: 14
Joined: Mon Mar 04, 2013 11:09 pm

Re: Can access getStyle from Ranorex Spy, but not Studio

Post by acalhoun » Thu Jul 11, 2013 2:16 pm

That worked for me, thanks so much!