Data Driven: Repo Element or RxPath in data file?

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
solovengo
Posts: 24
Joined: Mon Dec 19, 2011 8:14 pm

Data Driven: Repo Element or RxPath in data file?

Post by solovengo » Mon Oct 15, 2012 12:16 am

I am wanting to create a Test Suite for smoke tests that simply validate that a screen loads successfully. The object or element that is validated will vary from screen to screen. And I wanted to use a data driven approach for opening and validating each screen; the object I will be validating on each screen would be specified in the data file.

I initially did something similar to what is described in this post (http://www.ranorex.com/forum/using-a-co ... ble#p15365) using the RxPath in the column of the data file. This works fine. However if edits are made to the RxPath of the element in the repository, then each of the rows in the data file will need to be manually updated as well. And in my case, there are hundreds of screens that need to be validated. That is a lot of editing in the data driver file.

To validate the screen, I created a User Code that simply does this:

Code: Select all

Validate.Exists(varRxPathFromDataFile);
The value for varRxPathFromDataFile is a string that represents the RxPath to the element. Like I mentioned... that works fine.

But is there a way I could replace the RxPath in the data file with a repo element instead? Something like this:

Code: Select all

Validate.Exists(repo.myScreen.myElement);
This doesn't work because "repo.myScreen.myElement" from the data file comes in as a string. How would I convert this to the actual element I am trying to validate on the screen?

Thanks in advance!

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

Re: Data Driven: Repo Element or RxPath in data file?

Post by Support Team » Tue Oct 16, 2012 4:16 pm

Hello!

Could you explain why do you want to read the RxPath from the data file?

Is it possible to adjust the RxPath with a regular expression to find the element in the repository?
Which technology is used by your AUT (WPF, Web, MSAA ...)?
If it's a web application you could use 'enable search by Unique ID' in the global settings.

Regards,
Markus (T)
Support Team
.
Image

solovengo
Posts: 24
Joined: Mon Dec 19, 2011 8:14 pm

Re: Data Driven: Repo Element or RxPath in data file?

Post by solovengo » Tue Oct 16, 2012 9:01 pm

Hello,

My reason for reading the RxPath from the data file is because the paths to the elements that I need to validate are very different from screen to screen.

For example, here are 4 button elements that being validated on 4 different screens:

.//object[#'ShellControl']/container/element/container[@class='ThunderRT6UserControlDC']/element/container[@class='ThunderRT6UserControlDC']/container[@class='ReBarWindow32']/toolbar/toolbar/button[@commandid='100']

.//object[#'ShellControl']/container/element/container/element/button[@text='&Close']

.//object[#'ShellControl']/container/element/container/container/container[@class='ReBarWindow32']/toolbar/toolbar/button[@commandid='100']

.//object[#'ShellControl']/element/container/container[@class='ReBarWindow32']/toolbar/toolbar/button[@commandid='100']

Correct me if I'm wrong, but I didn't think a regular expression would work in this case because of the diversity in paths.

The technology on the AUT uses ActiveX controls.

Is there is a better approach for this type of validate using a data driver?

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

Re: Data Driven: Repo Element or RxPath in data file?

Post by Support Team » Wed Oct 17, 2012 8:56 am

Hello,

Thank you for your example.
You could adjust the RxPath to find all 4 buttons as shown below:

.//object[#'ShellControl']//button[@commandid='100' or @text='&Close']

In that case, the full path of the element is not needed to be identified by Ranorex.
Please read the RanoreXPath section in our user guide.


Regards,
Markus (T)
Support Team
.
Image

solovengo
Posts: 24
Joined: Mon Dec 19, 2011 8:14 pm

Re: Data Driven: Repo Element or RxPath in data file?

Post by solovengo » Wed Oct 17, 2012 8:34 pm

Thanks for the reply. And I wish the suggestion you posted would work for me. Unfortunately using the path you provided finds additional buttons inside my AUT, but that are outside of the screen that I want to validate; e.g. A Close button on the Toolbar above the area where the screens load and display. So, this might lead to a "false-positive" test result. Also, there will be other forms/screens that open as a separate window. So in that case the path you provided will not work very well either.

And that takes me back to my original question. If I were able to specify the repository element in the data source, then I can drive the Validation from the Data Source. I know that using the RxPath in the data source works, but that means having to maintain all the paths in the data source, which is doable, but tedious.

It still seems best to store a string in the Data Source representing the actual repo element path to be validated in the UI form. Then the RxPaths wouldn't have to be maintain; just the element names. And the repo path could be passed into the User Code. The User Code would have to convert it to the actual the repo element. That is where I get stuck... I'm no sure how to convert the string into the actual repo element. Another option might be to create a Case statement for each string repo element that validates against the correct UI repo element.

Any other ideas?

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: Data Driven: Repo Element or RxPath in data file?

Post by artur_gadomski » Thu Oct 18, 2012 6:31 am

Look into reflection but it seems like you won't get away with maintaining RxPaths, one way they're in data source in another they're in repository.
What if you kept a name next to each Path in Data source for reference?

solovengo
Posts: 24
Joined: Mon Dec 19, 2011 8:14 pm

Re: Data Driven: Repo Element or RxPath in data file?

Post by solovengo » Thu Oct 18, 2012 7:30 pm

artur_gadomski wrote:...it seems like you won't get away with maintaining RxPaths, one way they're in data source in another they're in repository.
What if you kept a name next to each Path in Data source for reference?
Yes, I agree. Although I would prefer to maintain one RxPath in the repository instead of maintaining that same path in a hundred or more rows in a Data Source table. Your idea of the name next to the RxPath is exactly what I did so that I could visually find the path quickly when I need to update them. :D

But... I think I found a better approach. I put the Element name in the Data Source. And then I created a User Code that has a Case statement:

Code: Select all

        	switch (elementName) 
        	{        			
        		case "Element1":
        			Validate.Exists("/dom/.//object/toolbar/toolbar/button[@commandid='100']");        			
        			break;
        			
        		case "Element2":
        			Validate.Exists("RxPath2");  // replace with actual path
        			break;
        			
        		case "Element3":
        			Validate.Exists("RxPath3");   // replace with actual path
        			break;

        		case "Element4":
        			Validate.Exists("RxPath4");  // replace with actual path
        			break;
        			
        		case "Element5":
        			Validate.Exists("RxPath5");   // replace with actual path
        			break;
        			
        		case "Element6":
        			Validate.Exists("RxPath6");   // replace with actual path
        			break;
        			
        		default:
        			Report.Log(ReportLevel.Error, "A value for the Element in the Data Source is not handled in the User Code.", elementName);        			
        			break;
        	}
This will allow me to maintain the RxPaths easier for each different element I need to validate... one line in the User Code and the same one element in the repository.