如何以编程方式点击iOS键盘上的一个点 [英] how to programmatically tap a point on the iOS keyboard

查看:114
本文介绍了如何以编程方式点击iOS键盘上的一个点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 KIF 来使我的应用程序自动化,而我正在尝试实现自动化在UISearchBar中输入内容并进行搜索.不幸的是,我找不到令人满意输入搜索文字后,以编程方式单击搜索按钮的方式.

I'm using KIF to automate my app, and I'm trying to automate typing something into a UISearchBar and searching for it. Unfortunately I couldn't find a satisfactory way to do that by programmatically clicking on the search button after I've entered my search text.

因此,我考虑只使用KIF的 tapScreenAtPoint 方法.该方法的问题在于它会执行以下操作:

So instead, I considered simply using KIF's tapScreenAtPoint method. The problem with that method is that it does the following:

CGPoint windowPoint = [window convertPoint:screenPoint fromView:nil];
view = [window hitTest:windowPoint withEvent:nil];

期望点击可以实际触摸视图.并且由于键盘显然不是视图,因此该测试将无法触发键盘上的搜索按钮.

It's expecting the tap to actually touch a view.. and since the keyboard is obviously not a view this test won't be able to trigger the search button on the keyboard.

一个人如何以编程方式点击键盘上的一个按钮?我认为这对于任何自动化测试套件都将非常有用.

How can one programmatically tap a button on the keyboard? I think this would be very useful for any automation-test suite.

推荐答案

听起来您正在尝试点击键盘上的搜索"按钮.返回键上的辅助功能标签不遵循任何合理的模式.在可访问性检查器中,您会看到"SEARCH",但在所有操作系统版本上可能不一致.

It sounds like you're trying to tap the "Search" button in the keyboard. The accessibility labels on return keys don't follow any sort of sane pattern. Looking in the accessibility inspector, you'll see "SEARCH" but that may not be consistent on all OS versions.

更新

您可以通过将\n添加到enterText...

[tester enterTextIntoCurrentFirstResponder:@"query\n"];

这篇关于如何以编程方式点击iOS键盘上的一个点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆