IOSDriver 无法在 IOS Safari 上执行 sendKey Enter

问题描述 投票:0回答:2
My scenarios:

1.Start Safari on Iphone
2.Navigate to "https://ja.wikipedia.org/wiki/"
3.Click on icon Search
4.Type text "Apple" and Enter

> 步骤 4 图片 <

我正在使用Java Appium。 在第 4 步,输入文本“Apple”,但 Enter 键无法执行发送。 有人可以帮忙解决这个问题吗?我的代码:

    ....
    AppiumDriver iosDriver = new IOSDriver(new URL(driverUrl), cap);
    ....
    iosDriver.findElement(By.xpath("//*[@class=\"search mw-ui-background-icon-search\"]")).sendKeys("Apple");
    iosDriver.getKeyboard().pressKey(Keys.ENTER);
java ios appium
2个回答
0
投票

你可以试试这个:

将“Keys.ENTER”放在sendKeys“Apple”+Keys.ENTER之后

....
AppiumDriver iosDriver = new IOSDriver(new URL(driverUrl), cap);
....
iosDriver.findElement(By.xpath("//*[@class=\"search mw-ui-background-icon-search\"]")).sendKeys("Apple" + Keys.ENTER);

0
投票

这也适用于 javascript 执行器。

driver.execute_script("var a = document.getElementById('element_location_id'); a.focus(); a.value='10';")

© www.soinside.com 2019 - 2024. All rights reserved.