Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable iOS simulator keyboard #4553

Open
MetodievIvaylo opened this issue Aug 16, 2024 · 4 comments
Open

Disable iOS simulator keyboard #4553

MetodievIvaylo opened this issue Aug 16, 2024 · 4 comments

Comments

@MetodievIvaylo
Copy link

MetodievIvaylo commented Aug 16, 2024

I am using Jest and Detox for mobile automation testing on iOS simulators. However, I am encountering a recurring issue where the iOS simulator keyboard interferes with my tests, causing them to fail.

The main problem arises when the keyboard remains open after entering text into an input field, which disrupts subsequent test steps. The usual methods I’ve tried to close the keyboard include:

  • Tapping on a different element to dismiss the keyboard
  • or typeText('\n') to close it
  • Also tried adding this defaults write com.apple.iphonesimulator ConnectHardwareKeyboard -bool false added as a step in CI

Unfortunately, these methods are not consistently reliable. Additionally, the keyboard’s opening or closing animations sometimes cause tests to break, leading to flaky tests.

I am seeking a solution to disable the iOS simulator keyboard before running tests.

Your environment

Detox version: 20.25.5
React Native version: 0.74.1
Node version: 20.15.1
Device model:
OS: 17
Test-runner (select one): jest

@asafkorem
Copy link
Contributor

Hey @MetodievIvaylo,

I'm surprised this didn’t work:

Tapping on a different element to dismiss the keyboard

Did you try tapping on a specific point on the screen's container to dismiss the keyboard? If that doesn’t work, it might also affect real users. Worth trying with a small swipe().
We’ll soon have a new API, device.tap(point), that should help with this.

@mat1asl0pez
Copy link

await element(by.id('my_input_field')).tapReturnKey()

this worked for me⬆️

@Cancercookie
Copy link

I don't have this issue with versions preceding 20.23.1, after the update the keyboard doesn't dismiss or hide in any way and resolving with .tapReturnKey() it's unfeasible, we have hundreds of tests to change.
I'm using [email protected] and iPhone15.

@mthahzan
Copy link

After hours of trial and error figured out using .replaceText(...) opened the keyboard in a weird state which stopped the known workarounds to dismiss the keyboard. Using .typeText(...) worked for me.

A reliable way to completely disable the soft keyboard would be very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants