placeholderValue for input field

Hello everyone, a quick question…
It appears that appium driver merges value and placeholderValue here.

Is there any way to get the placeholderValue for the text field? I am trying to figure out if user has actually entered anything into the text field or if it is still in the placeholder state. It does not look like placeholder is passed through.

“XCUIElementTypeTextField”: {
“_attrs”: {
“type”: “XCUIElementTypeTextField”,
“value”: “Required”,
“name”: “Name field”,
“label”: “Name field”,
“enabled”: true,
“visible”: true,
“accessible”: true,
“x”: 93,
“y”: 199,
“width”: 260,
“height”: 23,
“index”: 1,
“xpath”: “//XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[2]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTextField”
}
},

Is ‘Required’ not the placeholderValue? It seems like it could be, but I don’t know your app. I don’t know of any way to get placeholderValue other than checking the element before interaction.

@wreed it is in fact placeholder if user has not interacted with the field. However, there is no way to determine that for edit operation (for example). Is it something that user entered or is it a placeholder?

In XCTest I can check textField.placeholderValue:

    let textField = app.textFields["Name field"]
    XCTAssertEqual(textField.value as? String, "Required")
    XCTAssertEqual(textField.placeholderValue, "Required")

    textField.tap();
    textField.typeText("Henrik")
    
    XCTAssertEqual(textField.value as? String, "Henrik")
    XCTAssertEqual(textField.placeholderValue, "Required")

It feels like that extra piece of metadata about the textField is not exposed in appium api.

Could be, but also could be that Apple, in it’s infinite wisdom, did not expose this in the later api. I personally don’t have a way to look and see, maybe the best advice is to make a feature request/bug report here: GitHub - appium/appium-xcuitest-driver: Appium iOS driver, backed by Apple XCTest

1 Like