lundi 10 juillet 2017

How can I write the waitXXX function when trying to check the value in XCUItest

Can anyone help on this: I want to check the value of a comboBox element, but I need some time to get the value as the value is retrieved from the server, how should I write the code? What I want to check is in fact:

(comboBox.value as! String).isEmpty==false

I tried as following, but it doesn't work:

func waitForValue(element: XCUIElement, waitSeconds: Double) { let existsPredicate = NSPredicate(format: "isEmpty == false") expectation(for: existsPredicate, evaluatedWith: element.value as! String, handler: nil) waitForExpectations(timeout: waitSeconds) { (error) -> Void in if (error != nil) { let message = "Failed to get vlaue from (element) after (waitSeconds) seconds." XCTFail(message) } }

Aucun commentaire:

Enregistrer un commentaire