Web object identification via Text with Regex

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Posts: 23
Joined: Thu Mar 08, 2018 9:32 pm

Web object identification via Text with Regex

Post by CWhiting » Thu Mar 08, 2018 9:44 pm

I need to validate a popup by using part of the message.
I have tried following the example in the Ranorex manual where the examples are like: button[@text~'sample[0-9]']
note the text is entered as an attribute by the @text. This not working where the Div I am searching for has the text as innerText.

I change the search path to use text() instead which is working for me.
/dom[@domain=$WebUIURL]//div[#'simpleDialogContent'][text()~'Modifying the Secondary']

I also tried [@innertext~''Modifying the Secondary'] which also worked.

What is the difference in RxPath between @text, text() and @innertext from a Ranorex viewpoint?

I have used Selenium for years and for standard XPath, text() is the usual form.

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

Re: Web object identification via Text with Regex

Post by Support Team » Fri Mar 09, 2018 6:47 pm

Hi CWhiting,

Great question! @text and text() essentially do the same thing except that @text will use the "text" attribute if available. If a "text" attribute isn't available, it is going to use the text() method and look for something that is text, such as the InnerText on an HTML object. @Innertext will look at the actual "InnerText" attribute.

I hope this helps!