Appium-我们什么时候使用触摸动作?请问有输入文字的实际例子吗? [英] Appium - When do we use touch action? Could I have actual example for inputing text with it?
问题描述
我想问一下我们何时在Appium中使用触摸动作.我也想问:我们是否可以使用触摸操作来点按/按下android.widget.EditText元素并将sendKeys发送给它.我可以给一个可行的例子进行测试吗?
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");
OR
您可以单独单击并发送键,而无需清除text元素内的现有文本,如下所示:
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屋!