Appium - 我们什么时候使用触摸动作?我可以用它输入文本的实际示例吗? [英] Appium - When do we use touch action? Could I have actual example for inputing text with it?

查看:22
本文介绍了Appium - 我们什么时候使用触摸动作?我可以用它输入文本的实际示例吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下我们什么时候在 Appium 中使用触摸操作.我还想问:我们可以使用触摸动作来点击/按下 android.widget.EditText 元素并将其发送给它.我可以有一个可行的例子来测试它吗?

I would like to ask when do we use touch action in Appium. I also want to ask: could we use touch action to tap/press the android.widget.EditText element and sendKeys to it. Could I have an workable example to test it?

推荐答案

每当我们想点击/点击设备上的特定元素时,我们都会使用触摸操作.

We use touch action whenever we want to click/tap on the particular element on the device.

用于点击

您可以对 EditText 元素使用触摸操作,如下所示:

You can use touch action for EditText element as bewlow :

driver.findElement(By.xpath("your element xpath/id")).click();

用于打字

此外,您可以将 sendKeys 用于 EditText 元素,如下所示:此内部单击元素,清除文本并键入您要发送的字符串.

Also, You can use sendKeys for EditText Element as below : This internal clicks on the element, clears the text and types the string that you are sending.

driver.findElement(By.xpath("your element xpath/id")).sendKeys("textToBeTyped");

您可以单独单击和发送密钥,而无需清除文本元素内的现有文本,如下所示:

You can click and send keys separately without clearing the existing text inside the text element as below :

driver.findElement(By.xpath("your element xpath/id")).click();
driver.getKeyboard().sendKeys(textToBeTyped);

这篇关于Appium - 我们什么时候使用触摸动作?我可以用它输入文本的实际示例吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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