简体   繁体   English

单击按钮使用葫芦为Android

[英]clicking button using calabash for Android

I have an app with three interactive UI elements, two edittext's and one button. 我有一个包含三个交互式UI元素,两个edittext和一个按钮的应用程序。 I'm running calabash android 0.4.20 (since 0.4.21 seems broken) 我正在运行葫芦android 0.4.20(因为0.4.21似乎坏了)

If I enter console and run: 如果我进入控制台并运行:

$ query "button"

It shows me just a single result. 它只显示一个结果。

If I click into the second edittext to set focus there, and then run: 如果我单击进入第二个编辑文本以在那里设置焦点,然后运行:

$ touch "button"

The focus is set to the top edittext and the button does not receive a click event. 焦点设置为顶部的edittext,并且该按钮不接收单击事件。

Any clues why? 有什么线索吗?

I saw some notes here and there that calabash sometimes miscalculates the locations of the UI element when keyboard is present. 我在这里和那里看到一些注意事项,当使用键盘时,葫芦有时会错误地计算UI元素的位置。 I'm not sure where it it sending the touch event, perhaps the x/y coordinates are wrong? 我不确定它在哪里发送触摸事件,也许x / y坐标是错误的?

This fails too: 这也失败了:

$ performAction 'press', 'login' # login is the ID of the button...

How can I troubleshoot this? 我该如何解决?

does your button have an id? 您的按钮是否有ID?

query("Button id:'button_id'") 查询(“按钮ID:'button_id'”)

touch("Button id:'button_id'") touch(“按钮ID:'button_id'”)

there are more details in calabash doc on how to write a query statement... 葫芦文档中有更多有关如何编写查询语句的详细信息...

In your console try this, 在您的控制台中尝试此操作,

start_test_server_in_background (This should launch your app specified in the console) start_test_server_in_background(这将启动控制台中指定的应用程序)

Then try the following login_btn = query("* id:'login'") touch(login_btn) 然后尝试以下login_btn = query(“ * id:'login'”)touch(login_btn)

This should definitely touch the login button on the screen. 绝对应该触摸屏幕上的登录按钮。 If it does not, then the id is not 'login' 如果不是,则标识不是“登录”

Just from the description it sounds like the keyboard is obscuring the button. 仅从描述来看,听起来好像键盘遮住了按钮。 You might want to check out this post: Close/hide the Android Soft Keyboard which has some tricks for hiding the keyboard. 您可能想看看这篇文章: 关闭/隐藏Android软键盘 ,其中包含一些隐藏键盘的技巧。

Another issue I sometimes have is with more than one input being returned in an array. 我有时遇到的另一个问题是数组中返回了多个输入。 Sometimes you need to specify the array result you want to click on otherwise it will click the first item in the array. 有时您需要指定要单击的数组结果,否则它将单击数组中的第一项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM