# Having trouble with text fields in iOS Simulator 17

**URL:** <https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218>\
**Category:** Issues/Bugs\
**Created:** [December 28, 2023, 1:34pm UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218 "2023-12-28T13:34:38Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![kshumanev](https://discuss.appium.io/user_avatar/discuss.appium.io/kshumanev/32/12334_2.png) [@kshumanev](https://discuss.appium.io/u/kshumanev)\
**Post date:** [December 28, 2023, 1:34pm UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/1 "2023-12-28T13:34:38Z")

</div>

It is rather difficult to properly explain what is going on, so I filmed a video.  
It is impossible to upload a video here, so I uploaded it to YouTube

  
But to summarize:
- Appium doesn’t click or send keys to text fields, if you do not click on a field manually in the iOS simulator.
- But even when you click on the field yourself, behavior is incorrect. Keys are often being sent to the wrong fields (the cases are shown in details in the video).

Properties from the video:

- Appium: 2.1.3
- appium-xcuitest-driver: 5.12.1
- XCode: 15.1 (15C65)
- iOS Simulator: 17.0 (21A328)
- OS: MacOS 14.1.2, Apple M3 Max
- Python: 3.12.0

Also tried on (the same behavior):

- Appium: 2.2.3, 2.3.0
- appium-xcuitest-driver: 5.2.0; 5.12.2
- iOS Simulator: 17.0.1, 17.2

On my old laptop (MacBook '2019 on Intel Chip) everything worked fine. I can’t check which versions were installed there, but I set these tests there ~2 months ago, so it was also very close to the latest.  
But now on the M3 chip the behavior is very strange, and I didn’t manage to localize the problem by upgrading/downgrading everything I could. So it looks like some crazy compatibility problem.

Please, help me understand what is going on.

UPD: interesting update: I have just run the test on BrowserStack (the test code itself is still located on my local machine), and I got EXACTLY the same behavior there: text fields are not being filled with text. So I don’t think it is related to the upgrade from Intel to M3 anymore. But I still have no idea what is going on.

---

<div class="post-metadata">

**Author:** ![Conrad\_Braam](https://discuss.appium.io/user_avatar/discuss.appium.io/conrad_braam/32/7031_2.png) [@Conrad\_Braam](https://discuss.appium.io/u/Conrad_Braam)\
**Post date:** [January 3, 2024, 11:44am UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/2 "2024-01-03T11:44:20Z")

</div>

send keys more slowly with delays?

---

<div class="post-metadata">

**Author:** ![kshumanev](https://discuss.appium.io/user_avatar/discuss.appium.io/kshumanev/32/12334_2.png) [@kshumanev](https://discuss.appium.io/u/kshumanev)\
**Post date:** [January 3, 2024, 1:18pm UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/3 "2024-01-03T13:18:43Z")

</div>

Hi, Conrad. It is not about delays.  
As you can see from the video, the problems are not only with not sending keys, but also with clicks, and with sending keys successfully, but to the wrong elements.

Originally I tried to send keys char-by-char, it doesn’t change the behavior.

I’ve seen problems before when some chars are missing, if you pass the whole string into send\_keys at once. This is obviously something different.

---

<div class="post-metadata">

**Author:** ![Conrad\_Braam](https://discuss.appium.io/user_avatar/discuss.appium.io/conrad_braam/32/7031_2.png) [@Conrad\_Braam](https://discuss.appium.io/u/Conrad_Braam)\
**Post date:** [January 3, 2024, 1:44pm UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/4 "2024-01-03T13:44:26Z")

</div>

this is the most detailed defect demonstration clip ever - I am seeing that when you send a click to the element it actually is not setting focus to the element? Is that right?  
Does this reproduce if you use a real phone? (I’ve never used the simulator successfully myself.)

---

<div class="post-metadata">

**Author:** ![kshumanev](https://discuss.appium.io/user_avatar/discuss.appium.io/kshumanev/32/12334_2.png) [@kshumanev](https://discuss.appium.io/u/kshumanev)\
**Post date:** [January 3, 2024, 4:28pm UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/5 "2024-01-03T16:28:40Z")

</div>

“this is the most detailed defect demonstration clip ever” - thanks! Well, the more detailed it will be, the more chances I have to get help 🙂

“I am seeing that when you send a click to the element it actually is not setting focus to the element? Is that right?” - yes, that is one of the parts of the problem.

“Does this reproduce if you use a real phone?” - I don’t have an IPhone, but I believe it doesn’t: if you look at 2:33 in my video, then you could see, that even in the simulator a real mouse click works fine. But not the Appium click.

---

<div class="post-metadata">

**Author:** ![Conrad\_Braam](https://discuss.appium.io/user_avatar/discuss.appium.io/conrad_braam/32/7031_2.png) [@Conrad\_Braam](https://discuss.appium.io/u/Conrad_Braam)\
**Post date:** [January 4, 2024, 8:25am UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/6 "2024-01-04T08:25:26Z")

</div>

(I used to use the simulator intermittently a long time ago, back when the simulator was just painfully slow. It’s much faster on the nice new macs now though. But, we added some new product features and the simulators for iOS and Android no longer support quite a few of our test cases sadly.)

Does look like one of the appium gurus needs to watch your clip. Here’s hopeing they do.

---

<div class="post-metadata">

**Author:** ![kshumanev](https://discuss.appium.io/user_avatar/discuss.appium.io/kshumanev/32/12334_2.png) [@kshumanev](https://discuss.appium.io/u/kshumanev)\
**Post date:** [January 5, 2024, 9:01am UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/7 "2024-01-05T09:01:50Z")

</div>

Do you know if it is possible to ping someone here who could possibly help? The problem still blocks me, but maybe it is just something simple I am doing wrong.

---

<div class="post-metadata">

**Author:** ![Aleksei](https://discuss.appium.io/user_avatar/discuss.appium.io/aleksei/32/6267_2.png) [@Aleksei](https://discuss.appium.io/u/Aleksei)\
**Post date:** [January 5, 2024, 1:55pm UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/8 "2024-01-05T13:55:47Z")

</div>

> [@kshumanev](#):
>
> Appium doesn’t click or send keys to text fields, if you do not click on a field manually in the iOS simulator.

This is often happens, all depends how app written.

Did you try send text with actions instead of to element?

> [@iOS - Strong password cover text intermittently breaking tests](https://discuss.appium.io/t/ios-strong-password-cover-text-intermittently-breaking-tests/41110/2):
>
> how you enter text into this field? try logic as user: tap on password input send text with keyboard // Java new Actions(driver).sendKeys(text).perform(); Quite often sendKeys to element does not work correctly. Much depends on how app written.

Also share page source of your app screen and code how you find text inputs to undersrand better issue.

---

<div class="post-metadata">

**Author:** ![kshumanev](https://discuss.appium.io/user_avatar/discuss.appium.io/kshumanev/32/12334_2.png) [@kshumanev](https://discuss.appium.io/u/kshumanev)\
**Post date:** [January 8, 2024, 1:25pm UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/9 "2024-01-08T13:25:18Z")

</div>

1. As I said before and shown in the video, the problem is not only in send\_keys. It is in the clicking itself also: click() also doesn’t work.

2. ActionChains doesn’t change the behavior: after running

> ```
> from appium.webdriver import WebElement
> from appium.webdriver.common.appiumby import AppiumBy
> from selenium.webdriver import ActionChains
> 
> doctor_username: WebElement = self._driver.find_element(AppiumBy.XPATH, "//XCUIElementTypeTextField[@name='login.textField.doctorUsername']")
> ActionChains(self._driver).click(doctor_username).send_keys("hello").perform()
> 
> ```

nothing happens in the app (as in the initial video example): there is no click, the keys are not sent. Appium logs:  
[Appium actions approach logs.txt](https://discuss.appium.io/uploads/short-url/grY3MDs0NafYmeIvGeKon61KmY8.txt) (15.0 KB)

1. I am not allowed to share the full application source code, but the fields are initialized in this manner:

- Username:

> ```
> TextField(
> viewModel.editingChanged ? "" : viewModel.placeholder,
> text: $viewModel.text.animation(.easeInOut)
> )
> 
> ```

- Password:

> ```
> SecureField(
> viewModel.editingChanged ? "" : viewModel.placeholder,
> text: $viewModel.text.animation(.easeInOut)
> )
> 
> ```

where TextField and SecureField are standard SwiftUI entities.  
I can share some other pieces, but I need to know, which ones.  
I also remind that the problem is not only for the secured (password) field, it is there for all the fields.

1. I don’t think that the problem is with the fields initialization, because, as I’ve said in the description, the test worked a couple of months ago on my old laptop, and the initialization of the fields of the view or the view itself haven’t change since then (the test hasn’t changed also).  
At the same time, compatibility issues on my current laptop would be strange, because behavior in BrowserStack is exactly the same as on my laptop: incorrect. So I am quite confused.  
Unfortunately, when I had my old laptop, BrowserStack runs were not set up yet, so it is not possible to track when and why exactly everything stopped working.

---

<div class="post-metadata">

**Author:** ![Aleksei](https://discuss.appium.io/user_avatar/discuss.appium.io/aleksei/32/6267_2.png) [@Aleksei](https://discuss.appium.io/u/Aleksei)\
**Post date:** [January 8, 2024, 1:58pm UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/10 "2024-01-08T13:58:49Z")

</div>

> [@kshumanev](#):
>
> ppiumBy.XPATH, “//XCUIElementTypeTextField[@name=‘login.textField.doctorUsername’]”

you have 2 inputs on screen. May you pls use another search - NOT XPATH?  
Example:

```auto
// Java
        WebElement usernameInput = driver.findElement(AppiumBy.className("XCUIElementTypeTextField"));
        usernameInput.sendKeys("my_username");
        WebElement passcodeInput = driver.findElement(AppiumBy.className("XCUIElementTypeSecureTextField"));
        passcodeInput.sendKeys("my_pass");

```

---

<div class="post-metadata">

**Author:** ![kshumanev](https://discuss.appium.io/user_avatar/discuss.appium.io/kshumanev/32/12334_2.png) [@kshumanev](https://discuss.appium.io/u/kshumanev)\
**Post date:** [January 8, 2024, 2:08pm UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/11 "2024-01-08T14:08:24Z")

</div>

Yes:

> username: WebElement = self.\_driver.find\_element(  
> # AppiumBy.XPATH,  
> # “//XCUIElementTypeTextField[@name=‘login.textField.doctorUsername’]”)  
> AppiumBy.NAME,  
> “login.textField.doctorUsername”)
> 
> username.id  
> ‘13000000-0000-0000-869C-000000000000’
> 
> username.click()
> 
> username.send\_keys(“hello”)  
> \<appium.webdriver.webelement.WebElement (session=“ca9e04ad-f38a-4e87-bb1c-cdb7ec3e02e5”, element=“13000000-0000-0000-869C-000000000000”)\>

No changes in the behavior, the app doesn’t respond to click and send\_keys commands from Appium.

UPD: also tried your option with class names - the result is the same.

---

<div class="post-metadata">

**Author:** ![Aleksei](https://discuss.appium.io/user_avatar/discuss.appium.io/aleksei/32/6267_2.png) [@Aleksei](https://discuss.appium.io/u/Aleksei)\
**Post date:** [January 8, 2024, 3:20pm UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/12 "2024-01-08T15:20:43Z")

</div>

Share page source…

---

<div class="post-metadata">

**Author:** ![Arsen\_Domanych](https://discuss.appium.io/user_avatar/discuss.appium.io/arsen_domanych/32/8860_2.png) [@Arsen\_Domanych](https://discuss.appium.io/u/Arsen_Domanych)\
**Post date:** [January 23, 2024, 8:34pm UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/13 "2024-01-23T20:34:15Z")

</div>

@kshumanev Just an assumption from my side but still, do you have **accessibilitylabel** set in the source code for your username/password fields?

Also what should help is simply getting the coordinates of an input field and perform click by those coordinates using Actions so as a result the input become focused and you will be able to input the value

---

<div class="post-metadata">

**Author:** ![kshumanev](https://discuss.appium.io/user_avatar/discuss.appium.io/kshumanev/32/12334_2.png) [@kshumanev](https://discuss.appium.io/u/kshumanev)\
**Post date:** [June 25, 2024, 9:45am UTC](https://discuss.appium.io/t/having-trouble-with-text-fields-in-ios-simulator-17/41218/14 "2024-06-25T09:45:12Z")

</div>

So after some communication with some of the iOS developers from another team, it was found out, that the problem can be solved by changing padding to 0 in a TextField struct. The code in our case is the following:

Before:

```auto
var body: some View {
        field
            .padding(configuration.padding)
            .font(.roboto(.regular, size: configuration.fontSize))
            ...

```

After:

```auto
var body: some View {
        field
            .padding(0)
            .font(.roboto(.regular, size: configuration.fontSize))
            ...

```

I am not an iOS developer, and I don’t really know why it has such an affect, but I hope it helps other people having a similar problem. If we get more insights, I will update the answer.
