I'm following the Swift example under the heading Is there a way to return a specific element from the FAQ to try to retrieve a property from an element.
I copied the example directly from the FAQ but after calling performAction, textValue still has its original value. In fact, whatever I set the inout parameter to in the action block, the variable retains its original value once the action returns.
What am I missing? Here is the code I have:
func grey_getText(inout text: String) -> GREYActionBlock {
return GREYActionBlock.actionWithName("get text",
constraints: grey_respondsToSelector(Selector("text")),
performBlock: { element, errorOrNil -> Bool in
text = element.text
print("in block: \(text)")
return true
})
}
and in the test method:
var textValue = ""
let domainField = EarlGrey().selectElementWithMatcher(grey_text("Floor One"))
domainField.assertWithMatcher(grey_sufficientlyVisible())
domainField.performAction(grey_getText(&textValue))
print("outside block: \(textValue)")
prints
in block: Floor One
outside block:
I'm using XCode version 7.3.1