Sendkeys and click function does not work for IOS Simulator

org.openqa.selenium.WebDriverException: undefined status object (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.07 seconds
Build info: version: ‘2.47.1’, revision: ‘411b314’, time: ‘2015-07-30 02:56:46’
System info: host: ‘Stevans-MacBook-Pro.local’, ip: ‘192.168.6.53’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.10.5’, java.version: ‘1.7.0_79’
Session ID: bf82ee98-c282-4f6a-bf00-28b1ce83f27c
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities [{platformVersion=7.1, app=/Users/stevangomes/Downloads/MyOrderApp 2.app, platform=MAC, databaseEnabled=false, javascriptEnabled=true, platformName=iOS, deviceName=iPhone 5s, browserName=iOS, webStorageEnabled=false, networkConnectionEnabled=false, palatformName=iOS, desired={platformVersion=7.1, app=/Users/stevangomes/Downloads/MyOrderApp 2.app, deviceName=iPhone 5s, platformName=iOS, palatformName=iOS}, locationContextEnabled=false, warnings={}, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:27)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:273)
at io.appium.java_client.DefaultGenericMobileElement.execute(DefaultGenericMobileElement.java:27)
at io.appium.java_client.MobileElement.execute(MobileElement.java:1)
at io.appium.java_client.ios.IOSElement.execute(IOSElement.java:1)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at MigrationApp2.Login2.addContact(Login2.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

Try to apply send keys to parent UIATextView , it should help.

Hi Sargis,
I am not quite sure how we can apply sendkeys for UITextView.I have two issues , the major one is related to driver.findelement(by.xpath()).click() does not work.
I will provide the below reproduction Steps.
At the moment I am trying to automate a scenario were user has to provide a verification code and Click on the verify button.Attach is the screenshot for the same.

The thing is Appium Inspector does locate the element using Xpath but when I use the same Xpath in the Test Case then while running the test case I am getting the above error.
Below are the specifications :
Appium Version : Version 1.4.8 (Draco)
Java Client 3.1.0.jar
gson 2.3.1 .jar
Selenium standalone server 2.47.1
Selenium Java 2.47.1

Actual Result
Still getting the same error.

Error: invalid json
at parse (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/body-parser/lib/types/json.js:79:15)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/body-parser/lib/read.js:102:18
at done (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/body-parser/node_modules/raw-body/index.js:248:14)
at IncomingMessage.onEnd (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/body-parser/node_modules/raw-body/index.js:294:7)
at IncomingMessage.g (events.js:199:16)
at IncomingMessage.emit (events.js:104:17)
at _stream_readable.js:908:16
at process._tickDomainCallback (node.js:381:11)

info: [debug] Responding to client with error: {“status”:1,“value”:{“message”:“undefined status object”},“sessionId”:“54d82cc6-4d9a-4350-ae51-35b60f4f4722”}
info: <-- POST /wd/hub/session/54d82cc6-4d9a-4350-ae51-35b60f4f4722/element/0/click 500 1017.498 ms - 109

@Stevan_Gomes can you provide xpath for input field “Enter the code word here”

The xpath for the input field is “//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]”

	String xpath = "//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]";
	WebElement inputField = driver.findElement(By.xpath(xpath));
	inputField.sendKeys("security code");

If this will not work , i’ll write another variation with javascript.

I did try with it earlier and it still shows
org.openqa.selenium.WebDriverException: undefined status object (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 32 milliseconds
Build info: version: ‘2.47.1’, revision: ‘411b314’, time: ‘2015-07-30 02:56:46’
System info: host: ‘Stevans-MacBook-Pro.local’, ip: ‘192.168.6.53’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.10.5’, java.version: ‘1.7.0_79’
Session ID: 4d6c6ea7-8e87-487b-809e-7be4e7dcf261
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities [{platformVersion=7.1, app=/Users/stevangomes/Downloads/MyOrderApp 2.app, platform=MAC, databaseEnabled=false, javascriptEnabled=true, platformName=iOS, deviceName=iPhone 5s, browserName=iOS, webStorageEnabled=false, networkConnectionEnabled=false, palatformName=iOS, desired={platformVersion=7.1, app=/Users/stevangomes/Downloads/MyOrderApp 2.app, deviceName=iPhone 5s, platformName=iOS, palatformName=iOS}, locationContextEnabled=false, warnings={}, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:27)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:273)
at io.appium.java_client.DefaultGenericMobileElement.execute(DefaultGenericMobileElement.java:27)
at io.appium.java_client.MobileElement.execute(MobileElement.java:1)
at io.appium.java_client.ios.IOSElement.execute(IOSElement.java:1)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:94)
at MigrationApp2.Login2.addContact(Login2.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

Did you try do a send keys by inspector ?

Try to read this topic https://github.com/appium/appium/issues/3166
You might find some answers.

Yes I tried to do send keys by locating elements using Appium inspector but it did not work

I had already gone through this ticket number,and I have all the necessary Jar filed for appium.

The things is driver.tap() works fine but driver.findElelement(by.xpath().click().sendkeys
and driver.findElelement(by.xpath().click() does not work.
The same piece of code works fine with Android App but with IOS app it does not work

Try this

/**

  • Created by sargisazaryan on 7/3/15.
    */
    public class IOSKeyboard {
    private static final String GET_KEYBOARD_SCRIPT = “UIATarget.localTarget().frontMostApp().keyboard()”;
    private final IOSDriver driver;

    public IOSKeyboard(IOSDriver driver) {
    this.driver = driver;
    }

    public void pressKey(String key) {
    this.executeScript(this.pressKeyScript(key));
    }

    public void type(String text) {
    this.executeScript(this.typeScript(text));
    }

    private void executeScript(String script) {
    IOSDriver jsExecutor = this.driver;
    jsExecutor.executeScript(this.keyboardScript(script), new Object[0]);
    }

    private String pressKeyScript(String key) {
    return String.format(".keys().firstWithName("%s").tap();", new Object[]{key});
    }

    private String typeScript(String text) {
    return String.format(".typeString("%s");", new Object[]{text});
    }

    private String keyboardScript(String script) {
    return GET_KEYBOARD_SCRIPT + script;
    }

}

according to screenshot this path is not correct!

we see on screenshot that after “UIAApplication → UIAWindow → UIAScrollView” we have “UIAButton” but you use “UITextField”.

Also if you have ONLY one button on screen it is MUCH more easier to do:

driver.findElement(MobileBy.className("UIAButton")).click();
//or
driver.tap(1, driver.findElement(MobileBy.className("UIAButton")), 200);

I do have same issue. I am unble to use send keys. what i understood is sedkeys are for webelement which i are recognized by appium. Alternative when i use SetVlaue, I am able to enter the text on test field. but when i click on login app throws me error saying incorrect text. During that time when I delete the last character and reenter the same. If i tap on login app works fine. If you have understood my problem please help me

Hi Phanindra007,

I faced the similar kind of issue few days back and the solution for that is to access the keypad which is present and send the string.
driver.executeScript(“target.frontMostApp().keyboard().typeString(‘Whatever you wanna write!’)”);
I found this from : https://github.com/appium/appium/issues/2866
It actually works :slight_smile:

Hi Pramod_G,

Thanks for your reply. I will check on suggested solution and will update here.

Phanindra.

I am facing the same issue with android, unable to click on a button after update node and appium 1.5.2 . previously my script is worked fine with same element id now its shows me error .

An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.05 seconds
Build info: version: ‘2.53.0’, revision: ‘35ae25b1534ae328c771e0856c93e187490ca824’, time: ‘2016-03-15 10:43:46’

Please suggest me, i spent more time on it

On the page for the first text box the sendkeys will not work. First do send keys for the secound text box then to the first text box on the page. it is bug where we have to log it . if any body knows please let me know

Hi,
I am also facing the same issue, Sendkeys not working on iOS simulator
I am using Appium ,java to write automate iOS mobile app.
Already tried the above mentioned work around, But still no success.

Guys. Now it is

driver.getKeyboard().sendKeys(text);