selenium - PageSource() 获取的代码与 appium 检查器代码不同
问题描述
我很难理解以下问题,我有一个应用程序,我使用 appium 检查器查看元素,但是当我使用元素时,我发现找不到元素,因此我使用驱动程序打印了代码.getPageSource() 方法,我意识到在运行应用程序时创建的 xml 代码实际上与 appium 检查器看到的不同,问题是什么以及如何解决?一旦我知道根本原因,我可以要求开发人员修复它,在此先感谢。
这是一个不同的例子
在< XCUIElementTypeOther name = Picture, Left Rear Corner>
还有 4 个元素 2 StaticText、2 Buttons (appium inspector) 和同一个元素上,但在 java 控制台中,只有 2 个标签,所以我看不到 2 个静态文本和 2 个按钮(这是什么我想点击)
如您所见,控制台中的代码与我在 appium iinspector 中看到的不同。这是针对 IOS 应用程序的。
while (driver.findElementsById("Additional Videos").size() == 0) {
swipeScreenDown();
}
driver.getPageSource();
WebElement additionalVideos = driver.findElementByXPath("//XCUIElementTypeOther[@name=\"Picture, Left Front Corner\"]");
driver.getPageSource();
List<WebElement> idf = additionalVideos.findElements(By.className("XCUIElementTypeButton"));
driver.getPageSource();
System.out.println(idf.size());
driver.getPageSource();
idf.get(0).click();
driver.getPageSource();
错误得到:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
解决方案
推荐阅读
- rust - structopt 是否支持多上下文位置参数?
- apache-spark - 用于字母的 Spark 命令
- sql - T-SQL:将行转换为列
- python - 为什么 pip3 不能使用代理链在 Tails4.22 OS 中与 root 一起使用
- python - discord.py 中的 client.wait_for 中的“检查未定义”
- laravel - NestJs 项目的“php artisan tinker”相当于什么?
- html - 是否有一些没有分号的有效 HTML 实体?
- laravel-livewire - 如何在 livewire 2 中挂钩验证错误事件?
- html - 如何避免在弹出的抽屉外部导航
- javascript - for循环中的document.click只能工作一次?