Data enter into dynamic textfield

Class library usage, coding and language questions.
omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Data enter into dynamic textfield

Post by omayer » Wed Nov 21, 2012 3:48 pm

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
Tipu

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Data enter into dynamic textfield

Post by Support Team » Thu Nov 22, 2012 1:38 pm

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)
.
Image

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: Data enter into dynamic textfield

Post by omayer » Sun Nov 25, 2012 6:18 am

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
	}
        
}
        
}  
Tipu

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: Data enter into dynamic textfield

Post by omayer » Mon Nov 26, 2012 7:44 am

i could use switch statment but then control name might change on second test iteration
Tipu

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Data enter into dynamic textfield

Post by Support Team » Mon Nov 26, 2012 10:38 am

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)
.
Image

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: Data enter into dynamic textfield

Post by omayer » Wed Nov 28, 2012 6:59 am

I can use if or swithc statement but the problem with control name which gets created on time w/date and time stamp.
Tipu

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Data enter into dynamic textfield

Post by Support Team » Wed Nov 28, 2012 11:45 am

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)
.
Image