Appium: How to open a keyboard in iOS device by using Appium

Created on 13 Jul 2017  路  3Comments  路  Source: appium/appium

The problem

Need to open a Keyboard in iOS devices.
I need to enter the value in search text box, I tried webElement.sendKeys("abcd"); but it is not working.
So i tried to enter a value by keyboard.

I opened keyboard manually and executed this code to enter a value.

AppDriver.Keyboard.SendKeys(sValue);
But how to open a keyboard ???

I tried below codes,

  1. webElement.click(); and

  2. AppWebElement = AppDriver.FindElement(By.XPath("//*@id='mkmersNavbar']/div[2]/form/div/input"));
    Actions builder = new Actions(AppDriver);
    AppWebElement.Click();
    builder.Click(AppWebElement);
    builder.DoubleClick(AppWebElement);

  3. AppWebElement = AppDriver.FindElement(By.XPath("//@id='mkmersNavbar']/div[2]/form/div/input"));
    Dictionary tfTap = new Dictionary();
    tfTap.Add("element", string.Format("{0:X}", AppWebElement));
    ((IJavaScriptExecutor).AppDriver).ExecuteScript("mobile: twoFingerTap", tfTap);
    AppWebElement.Click();
    4.
    IWebElement element = AppDriver.FindElement(By.XPath("//
    [@id='mkmersNavbar']/div[2]/form/div/input"));
    Point point = element.Location;
    int a = point.X;
    int b = point.Y;
    Dictionary coords = new Dictionary();
    coords.Add("x", a);
    coords.Add("y", b);
    AppDriver.ExecuteScript("mobile: tap", coords);

  4. new TouchActions(AppDriver).SingleTap(webElement).Perform();

Above all is not working, it is not tapping on text box and not opening keyboard.

In c#, There is no method to open keyboard.

Is there any way to open a keyboard???

Environment

  • Appium version (or git revision) that exhibits the issue:1.6.6 beta2
  • Mobile platform/version under test:iOS 10.2.1
  • Real device or emulator/simulator: Real device
  • Script: c#

Thanks!
Elango

Question XCUITest

Most helpful comment

Hi elan,

Did you find a solutions for this? If yes, can you please share how you resolved this issue.

All 3 comments

There is no separate method to open keyboard - it is only opened when an element with input focus is activated. Regarding how you activate it - try to perform the click in native context.

Hi elan,

Did you find a solutions for this? If yes, can you please share how you resolved this issue.

I am having the same issue? Any solution?

Was this page helpful?
0 / 5 - 0 ratings