Page 1 of 1
Data enter into dynamic textfield
Posted: Wed Nov 21, 2012 3:48 pm
by omayer
How to automate to enter data into textfields which textfield gets created ontime, like after I select the item from dropdown list , then multiple textfields got creted on time , sometimes 3 or 4 ro 7 textfields, How do i enter data into these fields .
Thank You
Re: Data enter into dynamic textfield
Posted: Thu Nov 22, 2012 1:38 pm
by Support Team
Hello,
In order to get all your generated textfields you could use the 'FindDescendants' method as shown in the code below. Please use your specific Ranorex.Adapter (instead of InputTag) and your repository.
// get a list of all InputTags
IList<Ranorex.InputTag> inputTags = repo.RanorexTestPage.Self.FindDescendants<Ranorex.InputTag>();
// iterate over the list
foreach (Ranorex.InputTag inputTag in inputTags)
{
inputTag.Value = "YourValue";
}
Regards,
Markus (T)
Re: Data enter into dynamic textfield
Posted: Sun Nov 25, 2012 6:18 am
by omayer
Thank you MArkus, this method does "YourValue" to all textField on the page, how do I enter different value on each textField instead of hardocded "YourValue"
// iterate over the list
Code: Select all
public void GetInputTxtField()
{
// get a list of all InputTags
IList<Ranorex.InputTag> inputTags = repo.TCSF.RKCom.Csf1.FindDescendants<Ranorex.InputTag>();
// iterate over the list
foreach (Ranorex.InputTag inputTag in inputTags)
{
if (inputTag.Name=="csfID")
{
//donothing
}
else if(inputTag.Name=="poTrackingID")
{
break;//exit from the loop
}
else
{
inputTag.Value = "YourValue"; //how do I enter different value on each field instead of hardcoded
}
}
}
Re: Data enter into dynamic textfield
Posted: Mon Nov 26, 2012 7:44 am
by omayer
i could use switch statment but then control name might change on second test iteration
Re: Data enter into dynamic textfield
Posted: Mon Nov 26, 2012 10:38 am
by Support Team
Hello,
You could use an IF or SWITCH-statement but you would need a unique identfier which uniquely identifies your InputTag. This could be done with a specific property (e.g. control name) or a specific RxPath.
Regards,
Markus (T)
Re: Data enter into dynamic textfield
Posted: Wed Nov 28, 2012 6:59 am
by omayer
I can use if or swithc statement but the problem with control name which gets created on time w/date and time stamp.
Re: Data enter into dynamic textfield
Posted: Wed Nov 28, 2012 11:45 am
by Support Team
Hello,
You would need something unique for your elements.
This could be a property like size or height e.g.
As soon as you have found such a unique property you could use it to enter values into your dynamic textfields.
Regards,
Markus (T)