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
我正在使用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);
你可以试试这个:
将“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);
这也适用于 javascript 执行器。
driver.execute_script("var a = document.getElementById('element_location_id'); a.focus(); a.value='10';")