Appium:“使用给定的搜索参数无法在页面上找到元素".错误 [英] Appium: "An element could not be located on the page using the given search parameters" error
问题描述
我是Appium的新手,并一直在尝试实现Android转化计算器应用程序的自动化.尝试查找EditText元素时,出现错误"org.openqa.selenium.NoSuchElementException:使用给定的搜索参数无法在页面上找到元素".使用Appium版本1.0.0和Android 4.3
I am new to Appium and have been trying to automate the Conversion Calculator app for Android. Am getting the error "org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters", when trying to find a EditText element. Using Appium ver 1.0.0 and Android 4.3
以下是我的代码:
List<WebElement> textViews = driver.findElements(By.className("android.widget.TextView"));
for (i=0; i<textViews.size(); i++) {
if(textViews.get(i).getText().toLowerCase().contains("memory")) {
textViews.get(i).click();
}
}
Thread.sleep(5000);
WebElement editText = driver.findElement(By.className("android.widget.EditText"));
editText.sendKeys("123");
即使是按ID的findElement也不起作用.请让我知道我在这里做错了什么,或者是否需要提供更多详细信息.
Even findElement by ID is not working. Please let me know what I am doing wrong here or if I need to provide more details.
推荐答案
我会使用
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
代替Thread.sleep(5000)
.
尝试使用更新版本的Appium,我得到了很多改进.您可以在此处下载最新版本的Appium和Appium客户端: http://appium.io/downloads.html
Try to use a newer version of Appium, I's been improved a lot. You can download the latest version of Appium and Appium clients here:http://appium.io/downloads.html
但是要小心,因为在较新的版本中,如果搜索结果多于一个,则findElement会引发Exception.
But be careful because in the newer version the findElement throws an Exception if there are more then one result of the search.
我会在评论中写这个,但是我的信誉不够高:/
I would write this in a comment but I've not enough reputation :/
这篇关于Appium:“使用给定的搜索参数无法在页面上找到元素".错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!