简体   繁体   中英

How can I make an SLTextField tappable?

I have been writing a test with "Subliminal's" "SLTextField" and have run into some really annoying issues lately.

I have written a test which should update a text field, clear it, and update it again.

For some reason when I use "SLTextField" to change the element text I consistently receive errors stating that "SLTextFields" aren't tappable elements. Is this true? If so, what is the point of having an "SLTextField" class at all?

I can rewrite the same test code to find the element as an "SLElement", at which point I can tap the element, open up a keyboard object and type the necessary text, but it seems like I'm circumventing the entire functionality of Subliminal in doing this.

What's wrong w/"SLTextField"?

Code:

SLTextField *textField = [SLTextField elementWithAccessibilityLabel:fieldName];
SLWaitUntilTrue([textField isTappable], DEFAULT_TIMEOUT);
textField.text = newValue;

The above code throws an error, stating that "textField" never becomes tappable. Alternatively, the code below works perfectly, though it's unnecessarily verbose and seems to make "SLTextField" superfluous.

Code:

SLElement *field = [SLElement elementWithAccessibilityLabel:fieldName];
[field tapAtActivationPoint];
//fill with text
SLKeyboard *kb = [SLKeyboard keyboard];
SLKeyboardKey *deleteKey = [SLKeyboardKey elementWithAccessibilityLabel:@"Delete"];
while(![field.value isEqualToString:@""]){
    [deleteKey touchAndHoldWithDuration:1.2];
}
[kb typeString:newValue];
SLKeyboardKey *doneKey = [SLKeyboardKey elementWithAccessibilityLabel:@"Next"];
if(![doneKey isValid]){
    doneKey = [SLKeyboardKey elementWithAccessibilityLabel:@"Done"];
}
[doneKey tap];
[kb hide];

Is your TextField within a TableViewCell? And are you seeing this on iOS 7?

If so, it might have been fixed by https://github.com/inkling/Subliminal/pull/202 (merged 6/6/2014).

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