Is there a way to simulate pressing the tab key on a hardware keyboard in XCUITest for iOS? There is XCUIElement.typeKey()
but it's only available on macOS. I also tried typetext("\t")
but that didn't have the same effect as pressing the tab key.
Asked
Active
Viewed 710 times
3

Uncommon
- 3,323
- 2
- 18
- 36
-
Have you tried `typetext("\n")` ? It's kind of simulate trying to type the "Next" keyboard button. You can also try something like `XCUIApplication().keyboards.buttons["return"].tap()` according to the Action button on the keyboard. – cesarmarch Jun 25 '19 at 15:43
-
Unfortunately that doesn't help. Return and tab work differently, and tab is what I need to test. `XCUIApplication().keyboards` only gives access to the on-screen keyboard, and the tab key is usually only on the hardware keyboard. – Uncommon Jun 25 '19 at 17:18
-
What do you exactly want to test with the tab key ? – cesarmarch Jun 25 '19 at 20:25
-
The tab key advances focus through the active text fields. I want to check that it does so in the expected order and skips fields that are supposed to be disabled. – Uncommon Jun 25 '19 at 20:26