How to link two non-uniform iterations

Class library usage, coding and language questions.
Bticino
Posts: 12
Joined: Thu Jun 21, 2012 3:45 pm

How to link two non-uniform iterations

Post by Bticino » Thu Jun 28, 2012 9:53 am

Hi,
The problem is quite simple but I need a proper way to automatize the test.
Basically, we are testing a software which import a file containing devices.
We want to try the devices are successfully imported.

So we have several files to import with various devices inside it.
The problem is the number is not regular.

I tried to link an excel sheet like that:
Image

Our program can only import file by file and need to be restarted after checking the devices.
Basically I want to start my software, import a file, check every devices from this file, close the software and restart it again the same way.
Is it possible to do that with my excel file ? Because obviously the problem is during the data binding, when importing file1 I want to test only devA,B C and for file 2 only D and B.
(I simplified the problem but it is more or less what I need to do)

Thanks

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

Re: How to link two non-uniform iterations

Post by Support Team » Fri Jun 29, 2012 10:28 am

Hello,

You can split your table in three tables. One table for each file. For instance if you have tree tables you have to create three test cases and each test case uses one of these tables.
TestCaseDataBinding.JPG
If you want to use only one table you have to implement conditions in the User Code which is a little bit more complicated.

Regards,
Bernhard
Ranorex Support Team
You do not have the required permissions to view the files attached to this post.

Bticino
Posts: 12
Joined: Thu Jun 21, 2012 3:45 pm

Re: How to link two non-uniform iterations

Post by Bticino » Fri Jun 29, 2012 2:20 pm

Hi,

The tricky part is that effectively I cannot know in advance the number of file and elements to test. People will create their own excel to test and the automation will ask for the excel file (or any other format) containing everything. It is the randomness which makes the problem difficult, you cannot determine the number of iterations and count the number of test case you have to make.

So finally I'll have to go into deep C# as I supposed ? That's why I was asking, if there was a way to avoid manipulating lists etc.. I think I will need to store the info in another format than excel then.

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

Re: How to link two non-uniform iterations

Post by Support Team » Mon Jul 02, 2012 4:11 pm

Hello,

I am afraid that easiest way to solve your problem is to use C# code. You could write your devices from each file in one Cell separated via, e.g. a Semicolon.
Devices.JPG
In the user code module you can split the string, extract the devices and store them into a list. You can run through the list in and test each device.
Unfortunately you have to make the test in C# if you do this.
Attached is a little example how you can do this.

Regards,
Bernhard
Ranorex Support Team
You do not have the required permissions to view the files attached to this post.

Bticino
Posts: 12
Joined: Thu Jun 21, 2012 3:45 pm

Re: How to link two non-uniform iterations

Post by Bticino » Tue Jul 03, 2012 11:11 am

Effectively I started to work in C# and in the mean time we changed our imported file to XML, it is more effective than excel.
We are now browsing elements with XML solutions in C# and it is much easier.
Thanks

Bticino
Posts: 12
Joined: Thu Jun 21, 2012 3:45 pm

Re: How to link two non-uniform iterations

Post by Bticino » Tue Jul 03, 2012 3:03 pm

Sorry to double post but I have another question.
I am able to retrieve the button name I need to doubleclick with a string, but is it possible to use a repository technique to avoid a big IF :
I get the name of a button to click on from an XML file and the method :

Code: Select all

string buttonToAdd = button.SelectSingleNode("./ButtonInTTS").InnerText.Replace(" ", "");
This string tells me which button to click in my application, but I want to automatize this method :

Code: Select all

repo.TiTouchScreenApp.ToolbarListBox.Button.DoubleClick();
For example if buttonToAdd == "Automation", I want

Code: Select all

repo.TiTouchScreenApp.ToolbarListBox.Automation.DoubleClick();
buttonToAdd == "Temperature"

Code: Select all

repo.TiTouchScreenApp.ToolbarListBox.Temperature.DoubleClick();
BUT I want to do this without a IF. Because I have a lots of button so I don't want :

Code: Select all

if(buttonToAdd == "Automation"){     
    repo.TiTouchScreenApp.ToolbarListBox.Automation.DoubleClick();
} else if(buttonToAdd == "Temperature") {
    repo.TiTouchScreenApp.ToolbarListBox.Temperature.DoubleClick();
} etc etc...
Do you see a solution to do that automatically ?

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

Re: How to link two non-uniform iterations

Post by Support Team » Tue Jul 03, 2012 4:36 pm

Hi,

You can for instance use a find method:
repo.TiTouchScreenApp.ToolbarListBox.FindSingle("./*[@yourAttribute='"+buttonToAdd +"']");
The "*" stands for every adapter, you can also input "button" if you know that these elements are just buttons.
Is this an option for you?

Regards,
Markus
Ranorex Support Team

Bticino
Posts: 12
Joined: Thu Jun 21, 2012 3:45 pm

Re: How to link two non-uniform iterations

Post by Bticino » Wed Jul 04, 2012 4:08 pm

Thanks it's working by doing

Code: Select all

repo.TiTouchScreenApp.ToolbarListBox.Self.FindSingle<Ranorex.Text>("./*/*[@name='"+buttonToAdd +"']").DoubleClick();
But as I am inside a loop I want to test if this button was already added. (Because when we double click the button disappear)

I tried

Code: Select all

if(Validate.Exists("repo.TiTouchScreenApp.ToolbarListBox/text[@name=0'"+buttonToAdd +"']","Check Object '{0}'",false)){
but it doesn't work, he always tells me he cannot find the element.
The problem is again I want to work with a changing string in the repo.
Do you see another solution ?

Bticino
Posts: 12
Joined: Thu Jun 21, 2012 3:45 pm

Re: How to link two non-uniform iterations

Post by Bticino » Thu Jul 05, 2012 9:12 am

Finally I'm working with an ArrayList to verify if the button was already added or not..

Yet I have another problem with this string buttonToAdd. I want to select an element with this xpath :

Code: Select all

element[@classname='WpfDockingControl']/tabpagelist[@automationid='radPaneGroupMain']/tabpage/element/container/container[@controlname='BTGUI']/container/element[@controlname='uiPanelProperties']/element[@controlname='uiPanel11']/container/element/container/element/element/tree/treeitem/treeitem[@name='Lighting']
Once again I want to change "Lighting" with every values of buttonToAdd. Is it possible to use the InvokeAction Select() with an xpath ? (Because xpath allows me to play with String value)

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

Re: How to link two non-uniform iterations

Post by Support Team » Fri Jul 06, 2012 3:43 pm

Hi,

Regarding your first post, you can't input the path to the repository item, you have to input a RxPath to the specific element, a string including the RxPath to the element or the RepoItemInfo element itself, as mentioned on the following link: Validate Class.
Another way would be to check if the visible attribute of the buttons are set to false.

If you want to call the invokeAction method you have to create an adapter and then you can call it via the element associated with this adapter:
TreeItem item = "element[@classname='WpfDockingControl']/tabpagelist[@automationid='radPaneGroupMain']/tabpage/element/container/container[@controlname='BTGUI']/container/element[@controlname='uiPanelProperties']/element[@controlname='uiPanel11']/container/element/container/element/element/tree/treeitem/treeitem[@name='Lighting']";
item.Element.InvokeAction(...);
Here is the link to the api description of the method: InvokeAction Method.
I hope this will help you solve the problem!

Regards,
Markus
Ranorex Support Team