Best way to implement a selection from a list

Ask general questions here.
kieranwood
Posts: 15
Joined: Fri Jan 23, 2015 12:31 pm

Best way to implement a selection from a list

Post by kieranwood » Tue Jun 30, 2015 8:31 am

Hi there,

I am looking to automate some test cases. They need to make a selection based on the name. If you check the picture, they need to make a selection based on the four digit code. i.e. 0101.

These may change and may not be in the correct order all the time. Is there a way I can best implement this to find the text and select the checkbox next to it?

Any helps appreciated.
Attachments
profiles.png
profiles.png (18.76 KiB) Viewed 602 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Best way to implement a selection from a list

Post by odklizec » Tue Jun 30, 2015 9:04 am

Hi,

Please create and upload Ranorex snapshot of the tab in question. It's hard to provide reliable suggestion without seeing the tab content and structure.
Pavel Kudrys
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

kieranwood
Posts: 15
Joined: Fri Jan 23, 2015 12:31 pm

Re: Best way to implement a selection from a list

Post by kieranwood » Tue Jun 30, 2015 11:27 am

Hi there,

I havent actually started doing this with Ranorex just yet but I know I will need to do it and I dont know how to go about it.

I added a snippet of the screen I am trying to get the tests against in the original post and have added a snap of the screen here. Hope this is correct and helps.

I am using Ranorex and VB if it requires code.

Kind regards
Attachments
profiles.rxsnp
(162.6 KiB) Downloaded 47 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Best way to implement a selection from a list

Post by odklizec » Tue Jun 30, 2015 11:41 am

Hi,

Unfortunately, screenshot is not enough. It provides only a very rough idea how your GUI looks like. Ranorex snapshot is much better for general overview of the GUI.

Coding may not necessarily be required here, but again, it's hard to say without seeing the GUI from inside :) If you are lucky, it may be just required to replace some parts of xpaths with variables and then connect them with data connectors. If you are not so lucky, some coding may be required. If you need more help, please publish Ranorex snapshot (or send it to [email protected]).

OK, I just see you published the snapshot, thanks ;)
Pavel Kudrys
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

kieranwood
Posts: 15
Joined: Fri Jan 23, 2015 12:31 pm

Re: Best way to implement a selection from a list

Post by kieranwood » Tue Jun 30, 2015 2:18 pm

Hi there,

Thanks for taking the time to look at this.
I attached the snapshot after first replying, hope this helps :D

CookieMonster
Certified Professional
Certified Professional
Posts: 74
Joined: Mon Aug 14, 2006 7:17 pm
Location: CH

Re: Best way to implement a selection from a list

Post by CookieMonster » Tue Jun 30, 2015 3:44 pm

Hi,

I had look on your snapshot file. There are several ways to select the check box.

1. (Easiest way) Ask your developers if they can add the code (1011) on the unique id. For e.g. form ctl00_cphMain_dgEffective_ctl02_Checkbox3 to 1011 or ctl00_cphMain_dgEffective_1011.

2. Also here ask your developers, if they can remove all postfixes like Label3, Checkbox3.... and the table row and all their descendant should have the same id. If they don't want to do it, does matter you just need more user code :)
Create a user code method, where you pass the Span and Input Repository Item, and bind the code (1011) over the binding.

In your repository you have items like this or use the XPath:
/dom[@domain='pilot.prove-uru.co.uk']//span[@innertext~'$varCode']
/dom[@domain='pilot.prove-uru.co.uk']//input[@id~'$varCheckCode']

Code: Select all


public void GetIdForCheckBox(RepoItemInfo spanItem, RepoItemInfo inputItem)
{
   var spanTag = spanItem.CreateAdapter<SpanTag>(true);
   varCheckCode = spanTag.Id;
}

public void ClickCheckBox(RepoItemInfo inputItem)
{
   var inputTag = inputItem.CreateAdapter<InputTag>(true);
   inputTag.Click(Location.Center);
}
I haven't tried this, but this would be ways I would try to solve your problem.
I hope it helps.

Regards
Dan

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Best way to implement a selection from a list

Post by odklizec » Tue Jun 30, 2015 3:50 pm

Ok, here is an example xpath, which finds a checkbox based of the span containing the 4 digit code:

Code: Select all

/dom[@domain='pilot.prove-uru.co.uk']//span[@innertext~'0103']/../..//input
Now what you need to do is to replace the hardcoded 4 digit code with variable, like this:

Code: Select all

/dom[@domain='pilot.prove-uru.co.uk']//span[@innertext~$codeToFind]/../..//input
Finally, you need to connect the variable to a test case data connector, which contains the list of 4 digit codes.

I would suggest you to check this user guide chapter, to learn more about data driven testing:
http://www.ranorex.com/support/user-gui ... sting.html
and also this screencast:
http://www.ranorex.com/support/screencasts.html#c3896
Using data connector is the most obvious and recommended way to do task like this.

If you would like to select all checkboxes, it may be easier (and faster) doing it via code, using For...Each loop. Bug I guess you want to select only particular check boxes? ;)

Hope this helps?
Pavel Kudrys
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