KIF可以定位UIWebView组件吗?

时间:2012-11-06 19:54:51

标签: ios testing uiwebview kif-framework

是否可以在KIF测试中定位UIWebView组件?

我使用stepToTapScreenAtPoint设法获得了有限的功能,但目标内容“低于”时存在重大问题。

我使用stepToEnterText:kTestEmail intoViewWithAccessibilityLabel:@"Email"]的成功也很有限,但它可以找到输入字段&开始打字,完成打字后测试失败。

所以我的问题是KIF是否支持定位基于webview的步骤?测试这个的正确方法是什么?

谢谢! (KIF结果如下)

Integration[29024:c07] PASS (0.01s): Tap screen at point "{50, 520}"
2012-11-06 14:49:58.493 Integration[29024:c07] FAIL (4.48s): Type the text "[redacted]" into the view with accessibility label "Email"
2012-11-06 14:49:58.494 Integration[29024:c07] FAILING ERROR: Error Domain=KIFTest Code=0 "Failed to actually enter text "[redacted]" in field; instead, it was "SIGN UP
Sign in

Email

Password

   Stay signed in
Can't access your account?
Coming soon: A new sign-in page! Try it now Learn more
© 2012 Google Privacy Policy Help"" UserInfo=0x14eda060 {NSLocalizedDescription=Failed to actually enter text "[redacted]" in field; instead, it was "SIGN UP
Sign in

Email

Password

   Stay signed in
Can't access your account?
Coming soon: A new sign-in page! Try it now Learn more
© 2012 Google Privacy Policy Help"}
2012-11-06 14:49:58.494 Integration[29024:c07] ---------------------------------------------------
2012-11-06 14:49:58.494 Integration[29024:c07] END OF SCENARIO (duration 11.15s)
2012-11-06 14:49:58.495 Integration[29024:c07] 

1 个答案:

答案 0 :(得分:2)

一年后仍然没有人发布解决方案,所以我会分享我有一个类似的问题,我只是通过使用第一个响应者而不是进入文本字段来解决。

这是我项目中代码的片段。只需让它与你的工作。希望这有助于某人!

//Make sure the field is in view
[scenario addStep:[KIFTestStep stepToWaitForTappableViewWithAccessibilityLabel:@"Username"]];

//This will pop the keyboard to screen
[scenario addStep:[KIFTestStep stepToTapViewWithAccessibilityLabe:@"Username"]];

[scenario addStep:[KIFTestStep stepToEnterTextIntoCurrentFirstResponder:@"testUser"]];