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 客户端使用上方代码截取到的图不是指定元素的图,针对该问题,大佬们有没有解决方案?


↙↙↙阅读原文可查看相关链接,并与作者交流