question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does Send Key use keyboard events on IOS ?

See original GitHub issue

Question

I have been through your documentation and stack overflow multiple times, but I am confused whether sendKeys function actually sends a Keyboard event through the IOS keyboard or does it simply copy the text sent by the appium-server to that text box?

For our automation we would like the keys to be keyboard events and not a simple copy paste.

Environment

  • Appium version (or git revision) that exhibits the issue: v1.22.0
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: v1.22.0
  • Node.js version (unless using Appium.app|exe):
  • Npm or Yarn package manager:
  • Mobile platform/version under test: IOS 15.2
  • Real device or emulator/simulator: Both
  • Appium CLI or Appium.app|exe: .app

Details

We have previously tried clicking on the key(using X and Y coords) once the keyboard becomes visible but that does not suite our use case

Code To Reproduce Issue

# iOS environment
import unittest
import time
from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy

desired_caps = dict(
    platformName='iOS',
    platformVersion='15.2',
    automationName='xcuitest',
    deviceName='iPhone 11 Pro'
    # app='<location to the app>'
)

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
el = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Settings').click()

el = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Sign in to your iPhone').click()
driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='username-field').send_keys('Hi therellll')


Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mykola-mokhnachcommented, May 20, 2022

It seems like https://github.com/appium/appium-xcuitest-driver#mobile-performiohidevent might be the closest alternative. In general XCTest is pretty limited about their public APIs

0reactions
mykola-mokhnachcommented, Sep 1, 2022

Thanks @mykola-mokhnach! this is exactly what I was looking for

I know I am stretching this conversation too much but…

One last thing: mobile: configureLocalization can you point me to the apple docs for this or any other place? The only references that I could find were from the appium repo (line).

I mean I don’t understand what the layout key should be when I want to write for Chinese and Japanese. The layout key is a required param as well so can’t ignore it.

This is internal Apple stuff. Simply follow the documented suggestion to retrieve possible values:

You could switch the keyboard layout in system preferences of your booted simulator, run xcrun simctl spawn booted defaults read .GlobalPreferences.plist, and inspect the value of AppleKeyboards to see possible combinations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling key presses made on a physical keyboard
In iOS apps and Mac apps built with Mac Catalyst, the system reports key presses that a user makes on a physical keyboard...
Read more >
Handling keyUp and keyDown events on iOS 13.4 and later
The first thing that we'll need to do in order to make that happen is to override three methods that'll let us handle...
Read more >
ios - Programmatically Simulate Keyboard Events on the iPhone
I was wondering if it would be possible to simulate keyboard events - like key down and key up characters - and ...
Read more >
Element: keydown event - Web APIs | MDN
The keydown and keyup events provide a code indicating which key is pressed, while keypress indicates which character was entered. For example, ...
Read more >
[iOS] SendKeys to custom keyboard - Support - Appium Discuss
Hi,. Our application has a custom keyboard used to set text in specific fields. On Android, there is no problem in using sendKeys...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found