gpt4 book ai didi

java - 无法将按键发送到输入元素

转载 作者:行者123 更新时间:2023-12-02 04:49:25 24 4
gpt4 key购买 nike

我试图将登录凭据传递到输入字段,每次运行代码时,输​​入字段都会被识别,但 key 不会在输入字段传递。请帮忙...

Code:
WebElement image=driver.findElement(By.xpath("//android.widget.Image[@content-desc='LandingPAge']"));
System.out.println("Landed Login page");
driver.findElementByXPath("//android.view.View[@content-desc='Username']").sendKeys("u3@gmail.com");
driver.findElementById("password").sendKeys("1231212");
driver.findElementByXPath("//android.widget.Button[@content-desc='Login']").click();

Appium Log Details:
[debug] [W3C (235592b3)] Calling AppiumDriver.setValue() with args: [["u","3","@","g","m","a","i","l",".","c","o","m"],"2","235592b3-a8eb-4ccb-8d22-fef43fa92679"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:setText","params":{"elementId":"2","text":"u3@gmail.com","replace":false}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"2","text":"u3@gmail.com","replace":false}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: setText
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using element passed in: 2
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Attempting to clear using UiObject.clearText().
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"UiSelector[CLASS=android.view.View, INSTANCE=5]"}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[debug] [W3C (235592b3)] Encountered internal error running command: NoSuchElementError: UiSelector[CLASS=android.view.View, INSTANCE=5]

Ecllipse Console Error:
[RemoteTestNG] detected TestNG version 6.14.2
Jun 05, 2019 1:03:25 PM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
Landed Login page
FAILED CONFIGURATION: @BeforeClass setUp
org.openqa.selenium.NoSuchElementException:
UiSelector[CLASS=android.view.View, INSTANCE=5]
For documentation on this error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html

最佳答案

尽管您像 selenium sendKeys 一样在输入字段中输入文本,但有时 appium 无法正常工作。

因此,首先单击输入字段,然后使用 sendKeys 输入值,如下面的代码片段所述。

driver.findElement(By.id("#loc")).click();
driver.findElement(By.id("#loc")).sendKeys("text);

如果您仍然遇到任何问题,请告诉我。

关于java - 无法将按键发送到输入元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56456429/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com