在使用RemoteWebDriver时,将文本提交到EditText中。

huangapple go评论67阅读模式
英文:

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"));

See also: http://appium.io/docs/en/commands/mobile-command/

huangapple
  • 本文由 发表于 2020年9月26日 05:34:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/64071573.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定