Hi!
I've got a simple, quick question. Here it is.
I have an element in front of me that looks exactly like that:
and another one that looks exactly like that:
What I need to do with them is to get value from the element'slabel from the first screenshot (forget the checkboxes, I don't need those) and check if the first bullet point of the element shown on the second screenshot contains it. The way I want to do this is as follows:
1. Use Get Value action using RegEx (in order to get everything exept spaces, tabs, new lines etc.) and assign it to a variable:
2. Use InnerText Validation action to check.
The problem is as follows:
Get Value action ends gathering the text after first match. Which results in creating a string like '1' or 'Drilling' (one letter or one word). Every time I try different RegEx it either ends up as in case described above, or it ends with something like '↵········1/4·-·5/8·in↵········↵········↵····'. And believe me - I tried every possible angle. Including '/s' and '/S' to avoid whitespaces or even '[^ ]'. Nothing works. There are only two possible reasons for that:
1. I'm doing something wrong or I there is something inside Ranorex I don't know about.
2. Ranorex didn't anticipate a basic testing function which is value comparison.
I know about the RegEx 'toolkit' which is not, infact, a toolkit but a simple RegEx validator. I also know that I could write a simple sanitizer and put it there as a code. But I wanted to use Ranorex itself, as it's advertised. As an all-around comprehensive testing tool.
I will be very obliged for any help, suggestion or - hopefully - an answer.
Get value and RegEx
Get value and RegEx
You do not have the required permissions to view the files attached to this post.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Get value and RegEx
Hi wysojak,
Are you able to provide multiple Ranorex Snapshot files of these elements with different example values? With these Ranorex Snapshots, I may be able to help you build a regex pattern that only grabs the text required so that you can validate the text exists in the other element.
Looking forward to your reply!
Kind Regards,
Ned
Are you able to provide multiple Ranorex Snapshot files of these elements with different example values? With these Ranorex Snapshots, I may be able to help you build a regex pattern that only grabs the text required so that you can validate the text exists in the other element.
Looking forward to your reply!
Kind Regards,
Ned
Re: Get value and RegEx
Hi,
Agree with Ned. It would be very helpful, if you post a Ranorex snapshot for each element. Screenshots are nice, but nowhere as useful as snapshots
At next, if I understand the problem right, there is no need to use regex at all? All you need to do is to get the entire innertext from label of your choice (I guess the checked one?) and simply use the Validate action with AttributeContains parameter. This should be enough to validate, if the text from selected label is available in second screen.
Agree with Ned. It would be very helpful, if you post a Ranorex snapshot for each element. Screenshots are nice, but nowhere as useful as snapshots
At next, if I understand the problem right, there is no need to use regex at all? All you need to do is to get the entire innertext from label of your choice (I guess the checked one?) and simply use the Validate action with AttributeContains parameter. This should be enough to validate, if the text from selected label is available in second screen.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Get value and RegEx
To anyone else who comes across this thread, the customer sent us the requested Ranorex Snapshot file privately to further investigate. Below is my reply to the customer in hopes it will be useful to you as well.
Ned
Cheers,The problem with this element is that the actual InnerText attribute value contains a lot of leading and trailing whitespace. Below is a screenshot of the value copied and highlighted in Notepad to visually see the whitespace.
In order to grab only the data we need (i.e. “5 – 12 in”), we need to use the following RegEx pattern. As you can see in the RegEx tester linked below, this will grab the value between the leading and trailing spaces. This link also provides a nice explanation of how the pattern works. Furthermore, I have also included a screenshot of a sample recording module demonstrating how to use this pattern in Ranorex.
(?:\s*)(.+)(?:\s*)
https://regex101.com/r/IeRMzN/1
Ned
You do not have the required permissions to view the files attached to this post.