iOS 测试 python ios appium 如何进行元素截图

Xun · 2022年04月08日 · 最后由 Xun 回复于 2022年04月08日 · 2563 次阅读

android 客户端使用下方代码可以获取到元素截图
self.driver.get_screenshot_as_file(file_path)----appium 自带的截图方法
location = element.location------获取元素位置
size = element.size
box = (location["x"], location["y"], location["x"] + size["width"], location["y"] + size["height"])
image = Image.open(file_path)
new_image = image.crop(box)----使用了 PIL 模块
new_image.save(file_path)
但 ios 客户端使用上方代码截取到的图不是指定元素的图,针对该问题,大佬们有没有解决方案?

共收到 2 条回复 时间 点赞

这个问题描述看得我云里雾里。。。你的问题具体是什么,具体哪几行代码截取到的图不是指定元素的图?那截到的是什么图?

作为测试,描述问题请像报 bug 一样专业吧。

Xun 关闭了讨论 04月08日 12:07
Xun 重新开启了讨论 04月08日 12:07
Xun #2 · 2022年04月08日 Author

box = (location["x"]*2, location["y"]*2, (location["x"] + size["width"])*2, (location["y"] + size["height"])*2),这样可以截取到 ios 上对应的元素截图,问题已经解决

Xun 关闭了讨论 04月08日 12:11
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册