Forum Discussion

SimpleMe's avatar
SimpleMe
Occasional Contributor
7 years ago
Solved

How do I write a script for keyboard dismiss in iOS?

Hi. I'm very new to automation testing. I found useful articles on how to dismiss the keyboard via script, but I'm unsure of how to employ the script.

This article linked below mentions the YourTextview.resignFirstResponder() method. However, I'm not sure how to write the "yourtextview" portion.

 

https://community.smartbear.com/t5/TestComplete-Mobile-Application/iPad-iPhone-on-screen-keyboard/m-p/110044/highlight/true#M838

 

Below is the script I'm working with. I originally attempted to map the dismiss key control, but it doesn't work reliably, as others have noted in threads such as the one I mentioned above. I'd like to replace the underlined statement with the correct YourTextview.resignFirstResponder() method. Names and fields have been renamed to protect the innocent =)

 

def For_Scripting():
Indicator.PushText("Login")
Mobile.SetCurrent("My iPad")
#TestedApps.MyiOSapp.Run()
#The beginning of the Invalid Username Personnel ID LANDSCAPE group
Aliases.Device.processMyiOSapp.window0.textfield_Username.SetText("")
Aliases.Device.processMyiOSapp.window0.textfield_Username.SetText("JSMITH")
Aliases.Device.processMyiOSapp.window0.textfield_Password.SetText("")
Aliases.Device.processMyiOSapp.window0.textfield_Password.SetText(1)
Aliases.Device.processMyiOSapp.window0.textfield_PersonnelID.SetText("")
Aliases.Device.processMyiOSapp.window0.textfield_PersonnelID.SetText("ABC123")
Aliases.Device.processMyiOSapp.window2.bkeyplaneview0.bkeyviewDismissKey.Touch()
Aliases.Device.processMyiOSapp.window0.button_coffeeSelectionFlyOut.Touch()
Aliases.Device.processMyiOSapp.window0.searchbar.textfield_coffeeSearchBar.SetText("1B1")
Aliases.Device.processMyiOSapp.window2.bkeyplaneview0.bkeyviewDismissKey.Touch()
Aliases.Device.processMyiOSapp.window0.button_coffeeSelectionFlyOut.Touch()
Aliases.Device.processMyiOSapp.window0.labelSelectcoffee.setText("1B1")
Aliases.Device.processMyiOSapp.window0.button_SignIn.TouchButton()
#The end of the Invalid JSMITH Personnel ID LANDSCAPE group
Indicator.PopText()

  • Well, I figured it out. I was adding the command in too far in the line.

     

    A correct sample looks like:

     

    Aliases.Device.processMyiOSapp.window0.textfield_Password.resignFirstResponder()

1 Reply

  • SimpleMe's avatar
    SimpleMe
    Occasional Contributor

    Well, I figured it out. I was adding the command in too far in the line.

     

    A correct sample looks like:

     

    Aliases.Device.processMyiOSapp.window0.textfield_Password.resignFirstResponder()