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.

iOS TextField `clear` not working on iOS 12.x with Xcode 11

See original GitHub issue

The problem

I have updated my environment with Xcode 11 and Appium 1.15.0. The clear function on iOS TextField still works fine on iOS 13.0, but not anymore on 12.x

Environment

  • Appium version (or git revision) that exhibits the issue: 1.15.0
  • Last Appium version that did not exhibit the issue (if applicable): 1.14.2
  • Desktop OS/version used to run Appium: macOS 10.14.6 with Xcode 11
  • Node.js version (unless using Appium.app|exe): 11.9.0
  • Npm or Yarn package manager: 6.9.0
  • Mobile platform/version under test: iOS 12.2, 13.0
  • Real device or emulator/simulator: Simulator and actual devices
  • Appium CLI or Appium.app|exe: CLI

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:29 (9 by maintainers)

github_iconTop GitHub Comments

11reactions
mAiNiNfEcTiOncommented, Sep 26, 2019

😃 I think it’s related with XCode 11’s update. As an example, getText() only works properly for iOS 13, but not lower versions. (E.g. I have a TextField which returns the placeholder all the time, although the value attribute is properly set in the PageSource 😉 😃)

XCode 11 seems to be breaking a lot of stuff 😕

7reactions
mAiNiNfEcTiOncommented, Sep 27, 2019

I’ve installed their latest XCode 11.1 GM Seed, still doesn’t fix it …

One of the things I’ve noticed is that my PageSource now contains a lot of XCUIElementTypeOther… Something like this:

<TextInput
  accessible={true}
  accessibilityLabel="BeveilingingscodeTextBox"
  autoCorrect={false}
  placeholder="Vul hier de 8 cijferige code in"
  returnKeyType="done"
  spellCheck={false}
  style={styles.formElementInput}
  keyboardType="number-pad"
  maxLength={this.state.maxLength}
  onChangeText={this.handleResponseCode}
  value={this.state.responseCode}
/>

Is generating:

<XCUIElementTypeOther type="XCUIElementTypeOther" name="BeveilingingscodeTextBox" label="BeveilingingscodeTextBox" enabled="true" visible="true" x="40" y="267" width="295" height="29">
  <XCUIElementTypeTextField type="XCUIElementTypeTextField" value="12345671" name="BeveilingingscodeTextBox" label="BeveilingingscodeTextBox" enabled="true" visible="true" x="40" y="267" width="295" height="28"/>
</XCUIElementTypeOther>

So, I was forced to do something like this to select the proper element:

  const fields = await $$(`~${fieldLabel}`);
  const tags = await Promise.all(fields.map((f) => f.getTagName()));
  const field = fields.filter((f, index) => tags[index] !== 'XCUIElementTypeOther').pop();

On iOS >= 13.0

  • Tests pass.

On iOS < 13.0

  • Downgrading Appium’s version does not help.
  • field.clearValue() does not work
  • field.setValue() works
  • field.getText() / field.getValue() return the placeholder’s value…
  • If I remove the placeholder attribute it returns the label’s value…
  • If I change the placeholder value to {this.state.responseCode} then all tests pass, because it retrieves the right value (… doesn’t look like something I’d like to ship though 😄 )
Read more comments on GitHub >

github_iconTop Results From Across the Web

insertText on UITextField not enab… | Apple Developer Forums
I have a use case where I call insertText(_ text: String) on UITextField and expect the iOS Keyboard's return key (Go button in...
Read more >
Adding the "Clear" Button to an iPhone UITextField
This button is a built-in overlay that is provided by the UITextField class, but as of the iOS 2.2 SDK, there isn't any...
Read more >
How to make a clear button appear in a textfield - YouTube
Subscribe : https://www.youtube.com/channel/UC_0srkcd_tioJrb11wBCdEQ?sub_confirmation=1Source ...
Read more >
SwiftUI: How to add a clear button to a textfield - Martin Albrecht
In this article I want to show how to accomplish a simple clear button inside a SwiftUI TextField element. Note: XCode 11.x, Swift...
Read more >
How to dismiss the keyboard for a TextField - Hacking with Swift
If you're supporting only iOS 15 and later, you can activate and dismiss the keyboard for a text field by focusing and unfocusing...
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