Page 1 of 1

IOSElement.PressKeys crashes if number.

Posted: Thu Nov 19, 2015 1:11 pm
by stapes
I am using .PressKeys to input data into fields that I know are UITextView fields on an IOS application.

It mostly works fine, until I try to enter a number, or a full stop, or an @ character.

This crashes the application.

Here is my code:

Code: Select all

public void MyPressKeys(IosElement io, string MyString)
        {
        	foreach(char c in MyString)
			{
				Report.Info ("Custom Message",c.ToString ());
				io.PressKeys (c.ToString ());
			}
        	
        }

Code: Select all

public void UserCode_decodeTestForm()
        {

        	Ranorex .IosTable  adapter = repo.RichardPullinIPad .EmptyList.As<IosTable>(); // this elementcontains all the required fields
        	
        	int indexOfMyTextFields=0; // add 1 to it each time we encounter one

        	string[] MyData=new string[4] {"John","Smith","07914079871","stephen.staple@staple"};
        	
        	foreach (var e in adapter.Children  )
        	{

        		if(e.ToString ()=="{Container:UITableViewWrapperView}") // this contains all my text fields
        		{
        			int noOfChildrenIn=e.Children .Count ;
        			
        			if(noOfChildrenIn > 0)
        			{
        				foreach (var e2 in e.Children )
        				{
        					if(e2.ToString ()=="{Cell:UITableViewCell}")
        					{
        						foreach (var e3 in e2.Children )
        						{
        								if(e3.ToString ().Contains ("{Text:"))
        								{
        									if(e3.Enabled )
        									{
        										// THIS IS ONE OF OUR TEXT FIELDS!! 
        										indexOfMyTextFields +=1;

        										Ranorex .IosElement io=e3.As <IosElement >();
        										Report .Info ("Custom Message","Attempting to touch." );
        										io.Touch(); // this worked

        										if(indexOfMyTextFields<5)
        										{
        											Report .Info ("Custom Message","Attempting to enter data." + MyData[indexOfMyTextFields-1] );
        											MyPressKeys (io,MyData[indexOfMyTextFields-1]);
        										}

        										if(indexOfMyTextFields==5)
        										{
        											// this is date field - next problem
        										}
        									}        									
        								}        							
        						}						        						
        					}        					
        				}        				
        			}        			
        		}        		
        	}
        } 
The application crashes as soon as I try to type full stop, @, or any number.

It has been suggested this may be something to do with the keyboards that appear on the ipad screen.

Any ideas?

Re: IOSElement.PressKeys crashes if number.

Posted: Thu Nov 19, 2015 1:31 pm
by stapes
Solved my own problem again.

Used Ranorex.IOSElement.Element.SetAttributeValue instead.