gpt4 book ai didi

android - Android 上的 Appium - 报告的屏幕尺寸与实际屏幕尺寸不同

转载 作者:行者123 更新时间:2023-12-02 10:17:43 25 4
gpt4 key购买 nike

我正在游戏上使用 Appium 1.3.2 运行一些测试。我试图点击一个我知道坐标的元素的右下角,在许多设备上我遇到了 Appium 报告坐标无效的问题,因为它们位于屏幕之外。

我检查了 Appium 报告的大小:

driver.manage().window().getSize()

并注意到在实际分辨率为 960x540 的设备上报告的窗口大小为 886x540。

此外,尝试单击右下角会在 Appium 日志中生成以下内容:

[36minfo[39m: [debug] Pushing command to appium work queue ["element:touchDown",{"x":889,"y":473}]
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:touchDown","params":{"x":889,"y":473}}
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Got command action: touchDown
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][886,540]
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"Coordinate [x=889.0, y=473.0] is outside of element rect: [0,0][886,540]","status":29}
[36minfo[39m: [debug] Responding to client with error: {"status":29,"value":{"message":"The coordinates provided to an interactions operation are invalid.","origValue":"Coordinate [x=889.0, y=473.0] is outside of element rect: [0,0][886,540]"},"sessionId":"8d43efa4-931a-4886-8940-4bd96fea3d07"}

我正在测试的游戏是在全屏模式下运行的,如果我截图并查看,截图尺寸为960x540,游戏占据了整个屏幕,没有任何菜单项,也没有任何按钮。

我在其他分辨率上也看到了同样的问题,Appium 只是报告屏幕尺寸比实际尺寸小。

还有其他人遇到过这种情况吗?有解决办法吗?

最佳答案

我正在 Android Chrome 浏览器中进行测试,但 driver.manage().window().getSize() 无法正常工作。

所以我采取了以下方法:

JavascriptExecutor js = (JavascriptExecutor) driver;
int width = ((Long) js.executeScript("return window.innerWidth || document.body.clientWidth")).intValue();
LLLogs.getLogger().info("width value calculated is :" + width);
int height = ((Long) js.executeScript("return window.innerHeight || document.body.clientHeight")).intValue();
LLLogs.getLogger().info("height value calculated is :" + height);
Dimension dimension = new Dimension(width, height);

关于android - Android 上的 Appium - 报告的屏幕尺寸与实际屏幕尺寸不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29144650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com