Hi all,
I am still a beginner with Ranorex, I used to work with Selenium but I think Ranorex well be more useful to me.
But is have a little problem.
I want to select a tag according to a part of its attribute.
For example: an <iframe> tag with attribute name='text1_screenName_text2'
I want to select the iframe by its name by using only (_screenName_) segment ignoring what ever written in (text1) and (text2) segments
how can I do that?!
Thank you
identify an attribute by using a part of its value
Re: identify an attribute by using a part of its value
Hello,
You could use a regular expression within your RanoreXPath using the tilde (~).
Please take a look at the example below that searches for an IFrame that contains 'w3schools' as value for 'src'.
Example page: http://www.w3schools.com/tags/tryit.asp ... tml_iframe
Path: /dom[@caption='Tryit Editor v1.8']//iframe[#'iframeResult']/?/?/iframe[@src~'w3schools']
Regards,
Markus (T)
You could use a regular expression within your RanoreXPath using the tilde (~).
Please take a look at the example below that searches for an IFrame that contains 'w3schools' as value for 'src'.
Example page: http://www.w3schools.com/tags/tryit.asp ... tml_iframe
Path: /dom[@caption='Tryit Editor v1.8']//iframe[#'iframeResult']/?/?/iframe[@src~'w3schools']
Ranorex.IFrameTag myTag = Ranorex.Host.Local.FindSingle("/dom[@caption='Tryit Editor v1.8']//iframe[#'iframeResult']/?/?/iframe[@src~'w3schools']"); Report.Info(myTag.Src.ToString());Please let me know if you need more information.
Regards,
Markus (T)
Re: identify an attribute by using a part of its value
Dear MarkusT,
Your solution is working just fine, really really thank you.
Just one more question, how can I force ranorex to ignore location and depend only on the xpath of the element??
Thank you again
Your solution is working just fine, really really thank you.
Just one more question, how can I force ranorex to ignore location and depend only on the xpath of the element??
Thank you again
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: identify an attribute by using a part of its value
Hello,
You are welcome
You could use a path to ignore elements between the dom object and the IFrame (see below).
It is also possible to ignore the dom object but not recommended since it would take much longer to find the element and the path might not be unique.
Markus (T)
You are welcome
You could use a path to ignore elements between the dom object and the IFrame (see below).
It is also possible to ignore the dom object but not recommended since it would take much longer to find the element and the path might not be unique.
// ignore elements between dom object and IFrame Ranorex.IFrameTag myTag = Ranorex.Host.Local.FindSingle("/dom[@caption='Tryit Editor v1.8']//iframe[@src~'w3schools.com']"); // search all elements in the Spy hierachy tree - NOT RECOMMENDED Ranorex.IFrameTag myTag = Ranorex.Host.Local.FindSingle(".//iframe[@src~'w3schools.com']");Regards,
Markus (T)