Identify javascript elements using Ranorex

Ask general questions here.
Posts: 14
Joined: Mon Jun 23, 2014 9:20 pm

Identify javascript elements using Ranorex

Post by macgowan » Mon Jul 14, 2014 11:12 pm

Hi ...

Test Environment:
Windows XP / Windows 7 / Windows 2008 Server
Internet Explorer 8
Flash Player
Ranorex 4.1.6

We have been working with Flex - but now I have to identify some elements in Javascipt. I have opened the element repository and used the Track feature to select the object on the webpage. The RanoreXPath is created with an image. The RanoreXPath is below. Ranorex can't seem to find it using the code below.

I'm a little concerned about the --> label[@innertext='Patent'] ??

Code: Select all

/dom[@domain~'[a-z, A-Z]*']//div[#'65868_judicialsummary.trialCourtOrderSummaryPage.section.widget.negHistoryViewerWindow']/div[3]/div[1]/span/div/div[3]/label[@innertext='Patent']

Report.Info("Test that the Patent Tab exists "); 
if (SummaryRegressionRepository.Instance.JSA.History.PatentInfo.Exists())

    Report.Info("Click on the Patent Tab "); 


User avatar
Posts: 67
Joined: Fri Oct 25, 2013 6:37 am
Location: Bangalore, India

Re: Identify javascript elements using Ranorex

Post by testautomator » Tue Jul 15, 2014 6:54 am

I think you have to take a look at that RegEx you have used in thexpath there. Maybe you can just '.*workbench' instead. And one more change I suggest is the div[#'65868_judicialsummary.. make sure its not dynamic. Maybe you can use '.*_judicialsummary' there too.

Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: Identify javascript elements using Ranorex

Post by mzperix » Tue Jul 15, 2014 8:52 am

Hi macgowan,

I have a note about your concern: just leave the attribute out or use another attribute to identify the label. Label is usually used with input fields to put focus on them, or control them. If that is the case, then the label should have an atttribute @for, which should be unique. Another usage is to use like a "span" tag: just add extra formatting options inside the text. Which means the label should have a @class attribute.

But as far As I can see, your xpath contains the whole DOM structure, so just deleting the whole attribute and leaving should do the trick.

What I usually do when encountering an xpath issue, is to open the spy and start playing with the xpath. I try to make it shorter, and still be reasonably fast.

Best Regards,