这是indexloc提供的服务,不要输入任何密码
Skip to content

Unable to append text due to placeholder value being returned as element value #986

@luckyyyyy

Description

@luckyyyyy

Description

I'm trying to implement a text append functionality for text fields in my automation tests, but I've noticed that the current implementation in XCUIElement+FBWebDriverAttributes.m prevents this from working correctly.

In the wdValue method, when handling text fields, the code sets the placeholder value as a fallback when the actual value is empty:

else if (elementType == XCUIElementTypeTextView ||
         elementType == XCUIElementTypeTextField ||
         elementType == XCUIElementTypeSecureTextField) {
  NSString *placeholderValue = self.placeholderValue;
  value = FBFirstNonEmptyValue(value, placeholderValue);
}

This causes an issue where I can never properly append text to a field that has a placeholder, as the WebDriverAgent returns the placeholder text instead of an empty string when the field is empty.

Question

  1. Why was the decision made to return the placeholder value as the element's value? I understand this might be useful for element location/identification, but it breaks the ability to append text.
  2. Is there another way to implement text append functionality while maintaining this behavior?
  3. Would it be possible to add an additional attribute that returns the raw value without the placeholder fallback?

Reference

https://github.com/appium/WebDriverAgent/blob/master/WebDriverAgentLib/Categories/XCUIElement%2BFBWebDriverAttributes.m#L84

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions