简体   繁体   中英

Test if Button Text has changed

I have a button whose text changes based on certain criteria. I want to test this functionality with XCUITest but I can't seem to be able to access the text on the button.

I have tried

button.staticTexts
button.value
button.title
elementsQuery.buttons["My Button"] //This uses the accessibility label

How can I access the text?

I know this is old but try this:

let app = XCUIApplication();
let buttonText = app.otherElements["My Button"].staticTexts;

If this doesn't work let me know. Currently working on iOS XCUITests myself

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM