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.
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.
Unique application help needed
Unique application help needed
You do not have the required permissions to view the files attached to this post.
Re: Unique application help needed
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
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...
Ciege...
Re: Unique application help needed
Is there any sample code on how to loop through all the labels?
Re: Unique application help needed
Something like this?
http://www.ranorex.com/support/user-gui ... html#c3574
http://www.ranorex.com/support/user-gui ... html#c3574
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...
Ciege...
Re: Unique application help needed
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!
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!
Re: Unique application help needed
See if this helps...
You need to use a Regular Expression within your XPath.
http://www.ranorex.com/support/user-gui ... html#c3294
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...
Ciege...
Re: Unique application help needed
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.
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.
(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.

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.
Re: Unique application help needed
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!
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...
Ciege...