英文:
Submit text in EditText when using RemoteWebDriver
问题
我目前正在尝试在EditText中编写文本,然后发送这段文本。
使用以下代码在EditText中编写文本是有效的:
> productInputField.sendKeys("Test");
现在的问题是如何发送这段文本。使用RemoteWebDriver无法直接按下键盘上的ENTER键。我尝试直接将ENTER键发送到EditText:
> productInputField.sendKeys(Keys.ENTER);
使用这种方法只会在EditText中插入一个数字(这里是数字7)。遗憾的是文本并没有被发送。
非常感谢您提前提供的任何帮助,希望能够解决这个问题。
英文:
I am currently trying to write a text in an EditText and then send this text.
Writing the text in the EditText works fine with the following code:
> productInputField.sendKeys("Test");
The problem now is to send this text. Pressing the ENTER key on the keyboard is unfortunately not possible with the RemoteWebDriver. I tried to send the ENTER key directly to the EditText:
> productInputField.sendKeys(Keys.ENTER);
With this method only a number (here the 7) is inserted into the EditText. Unfortunately the text is not sent.
I thank you in advance for any help that could help me to solve this problem.
答案1
得分: 0
"ENTER"键有两种常见功能。其中一种是用于提交内容,另一种是用于换行。Keys.ENTER
用于提交。您应该使用Keys.RETURN
。
英文:
The ENTER key has two common functionality. One is for submitting something, another for go to the next line. Keys.ENTER
is for submitting. You should use Keys.RETURN
答案2
得分: 0
问题通过使用以下代码得到解决:
> driver.executeScript("mobile: performEditorAction", ImmutableMap.of("action", "search"));
另请参阅:http://appium.io/docs/en/commands/mobile-command/
英文:
The problem was solved by using the following code:
> driver.executeScript("mobile: performEditorAction", ImmutableMap.of("action", "search"));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论