Unique application help needed

Ask general questions here.
annias411
Posts: 5
Joined: Fri Aug 10, 2012 3:50 pm

Unique application help needed

Post by annias411 » Fri Aug 10, 2012 4:13 pm

I'm evaluating Ranorex for purchase and I need a little help with using your product with our application.

We use Google web tools as a development framework and the objects are dynamic.

So a checkbox ID'd as 'x-auto-118' on one iteration might be 'x-auto-204' on the next.
Untitled.jpg
Untitled.jpg (18.26 KiB) Viewed 751 times
Putting the checkbox in the repository does no good because the object ID's change every time the application is run. The label remains the same obviously.

Can someone point me in the right direction as to how I should approach this situation in Ranorex please?

Thank you.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Unique application help needed

Post by Ciege » Fri Aug 10, 2012 4:32 pm

Personally, I would write my own code that searches for the for the Label element then finds it's sibling Checkbox...

You can also read about using Relationship Operators within Ranorex here: http://www.ranorex.com/support/user-gui ... ditor.html
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

annias411
Posts: 5
Joined: Fri Aug 10, 2012 3:50 pm

Re: Unique application help needed

Post by annias411 » Wed Aug 15, 2012 8:58 pm

Is there any sample code on how to loop through all the labels?

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Unique application help needed

Post by Ciege » Wed Aug 15, 2012 10:02 pm

If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

annias411
Posts: 5
Joined: Fri Aug 10, 2012 3:50 pm

Re: Unique application help needed

Post by annias411 » Thu Aug 16, 2012 8:36 pm

Thanks Ciege for your help, I'm almost there.

I'm new to XPath, so please forgive my ignorance.

This works, it finds the checkbox I'm looking for.
var cb = webDoc.Find("/dom[@domain=myDomain.net']//div[#'x-auto-119']/label[@innertext='mycheckbox']");

However, I need to search all the "x-auto-n" possibilities. The -119 will change because of dynamic creation of the object. The label remains the same.

This does not. :(
var cb = webDoc.Find("/dom[@domain='myDomain.net']//div['^x']/label[@innertext='mycheckbox']");

I was thinking the ^ attribute would act as a wildcard. Maybe I misunderstood.

Can you help me get over this last hump?

Thanks!

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Unique application help needed

Post by Ciege » Thu Aug 16, 2012 9:38 pm

See if this helps...
You need to use a Regular Expression within your XPath.

http://www.ranorex.com/support/user-gui ... html#c3294
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

annias411
Posts: 5
Joined: Fri Aug 10, 2012 3:50 pm

Re: Unique application help needed

Post by annias411 » Fri Aug 17, 2012 8:46 pm

Figured it out thanks...
(Again this is allowing me to find dynamic input controls created by javascript, which have changing IDs.)
Maybe someone else will find this of value.

var label = webDoc.FindSingle("/dom[@domain='MyDomain.net']//label[@innertext='"+ controlName+"']");

The controls I'm trying to find have labels that remain constant. So I find the label, then get the parent, then get children of the parent.

var labelElement = (WebElement)label;
WebElement parent = labelElement.Parent;
var checkBoxList = parent.Children;

var checkBoxId = checkBoxList[0];

string _checkBoxId = checkBoxId.Element.GetAttributeValue("Id").ToString();
string chSearchStr = "/dom[@domain='MyDomain.net']//input[#'" + _checkBoxId +"']";
var _cb = webDoc.FindSingle(chSearchStr);
WebElement cb2 = (WebElement)_cb;
cb2.Click();

Single out the checkbox portion of the control. Then click it.

*****************
Edit... bleh... too much code. :D

var labelElement = (WebElement)label;
WebElement parent = labelElement.Parent;
var checkBoxList = parent.Children;

var checkBoxId = checkBoxList[0];
checkBoxId.Click();

Works without having to search again for the control... I already have the checkbox child element of the checkbox control...so just click it.
Last edited by annias411 on Mon Aug 20, 2012 4:12 pm, edited 1 time in total.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Unique application help needed

Post by Ciege » Fri Aug 17, 2012 8:51 pm

I'm glad you figured it out on your own... I apologize for not "helping" more and giving the code to you, but I'm a firm believer in once you figure out the basics on your own you are a better person (developer) for it!

Good job!
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...