首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EarlGrey失败--“键盘在退出第一个响应程序状态后没有消失”

EarlGrey失败--“键盘在退出第一个响应程序状态后没有消失”
EN

Stack Overflow用户
提问于 2016-03-24 19:51:55
回答 1查看 573关注 0票数 2

我正在尝试为我的登录页面编写UI测试。该页面有一些简介动画,一个搜索字段(用于查找要连接到的正确服务器),然后一旦他们选择了正确的服务器,就会出现一个用户名和密码字段。

到目前为止,这是我的测试:

代码语言:javascript
复制
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"searchTextField")]
 assertWithMatcher:grey_sufficientlyVisible()];
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"searchTextField")] performAction:grey_typeText(@"gtX9Vn23k1")];
[[EarlGrey selectElementWithMatcher:grey_anyOf([self matcherForUITableViewCell], nil)] performAction:grey_tap()];

[[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"usernameTextField")]
 assertWithMatcher:grey_interactable()] performAction:grey_tap()];
[[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"usernameTextField")]
  assertWithMatcher:grey_interactable()] performAction:[GREYActions actionForTypeText:@"Why isnt this working?"]];

这个测试失败了。

EarlGrey正确选择并键入第一个文本字段(searchTextField)。

EarlGrey正确地选择了表视图单元格!

然后,EarlGrey正确地选择了usernameTextField,但是失败了来键入文本,在超时后给出了以下错误:

代码语言:javascript
复制
Exception: ActionFailedException
Reason: Action 'Type "Why isnt this working"' failed.
Element matcher: (respondsToSelector(accessibilityIdentifier) &&   accessibilityID("usernameTextField"))
Complete Error: Error Domain=com.google.earlgrey.ElementInteractionErrorDomain   Code=1 "Keyboard did not disappear after resigning first responder status of   <GHDLoginTextField: 0x7fa96a616bd0; baseClass = UITextField; frame = (150 387; 468    29); text = ''; opaque = NO; autoresize = RM+BM; tintColor = UIDeviceWhiteColorSpace 1 1; gestureRecognizers = <NSArray: 0x7fa96a55d5d0>; layer = <CALayer: 0x7fa96a616a80>>" UserInfo={NSLocalizedDescription=Keyboard did not disappear after resigning first responder status of <GHDLoginTextField: 0x7fa96a616bd0; baseClass = UITextField; frame = (150 387; 468 29); text = ''; opaque = NO; autoresize = RM+BM; tintColor = UIDeviceWhiteColorSpace 1 1; gestureRecognizers = <NSArray: 0x7fa96a55d5d0>; layer = <CALayer: 0x7fa96a616a80>>}

“键盘”在退出"“的第一个响应者状态后并没有消失。

有人知道这是怎么回事吗?奇怪的是,顺便说一句,EarlGrey似乎在出错之前就选择了下一个字段(Password字段)。我在那里没有UI代码来选择密码字段。

更新:我在这个文本字段上使用返回键类型" next“,这样当用户点击返回键时,我将带他们到下一个字段(密码字段)。为此,当下一个键被击中时,我在该文本字段上退出firstResponder,并在密码字段上调用"becomeFirstResponder“。

这会导致EarlGray出错,因为如果我删除"resignFirstResponder“调用,它就会正确地键入我的文本。问题是:当我没有告诉它的时候,它为什么要按下一个键!?

EN

回答 1

Stack Overflow用户

发布于 2016-03-24 23:35:57

它看起来像是EarlGray源代码中的一个bug。GREYActions.m第182行

代码语言:javascript
复制
// If the view already is the first responder and had autocorrect enabled, it must
  // resign and become first responder for the autocorrect type change to take effect.
  [firstResponder resignFirstResponder];

没有进行检查以确定视图以前是否已启用自动更正。因此,所有文本字段都将调用"resignFirstResponder“。对于像我这样的设置来说,这是有问题的,resigningFirstResponder然后将firstResponder状态传递给另一个textfield。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36208917

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档