在使用Appium时,如果在Android Chrome浏览器中按ID和名称无法找到元素,出现“InvalidArgumentException”错误,可能是由于以下几个原因导致的:
By.id()
或By.name()
来查找元素。例如:driver.findElement(By.id("elementId"));
driver.findElement(By.name("elementName"));
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("elementId")));
By.xpath()
来尝试通过元素路径定位元素。例如:driver.findElement(By.xpath("//android.widget.Button[@text='按钮文本']"));
总结一下,解决方法如下:
希望以上解决方法能帮助到你解决问题!