Exception in thread "main" org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: {stacktrace=NoSuchElementError: An element could not be located on the page using the given search parameters.
Caused by: java.lang.ClassCastException: com.google.common.collect.Maps$TransformedEntriesMap cannot be cast to org.openqa.selenium.WebElement
翻译:
在线程“main”org.openqa.selenium中异常。WebDriverException:返回值不能转换为WebElement: {stacktrace=NoSuchElementError:一个元素不能使用给定的搜索参数位于页面上。
引起的:. lang。com.google.common.collect.Maps$TransformedEntriesMap不能被转换为org.openqa.selenium.WebElement。
解决办法:
将 AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
替换为 AndroidDriver<WebElement> driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);