[英]How to download images from mobile application using webdriver\appium?
How to download images from mobile application using webdriver\\appium? 如何使用webdriver \\ appium从移动应用程序下载图像? for example: whatsapp, amazon
例如:whatsapp,亚马逊
If the sole purpose of your task is to download some images that are coming in through a Native app like Amazon or Whatsapp, you don't need a high level framework like Appium or web driver. 如果您的任务的唯一目的是下载通过Amazon或Whatsapp之类的本机应用程序传入的某些图像,则您不需要诸如Appium或Web驱动程序之类的高级框架。 You can accomplish that task through network layer.
您可以通过网络层完成该任务。
To start with, While browsing through the images that you are interested in hook up Fiddler or Charles proxy , enable SSL proxying, install root cert etc. to see what are the HTTP requests that are giving the images. 首先,在浏览您感兴趣的图像时,请连接Fiddler或Charles代理 ,启用SSL代理,安装root cert等,以查看给出图像的HTTP请求。
You can mimic the exact same thing using network requests in your favorite programming language. 您可以使用自己喜欢的编程语言使用网络请求来模仿完全相同的事物。
I suggest you look at HtmlUnit library. 我建议您看一下HtmlUnit库。
After you added the library, the code will looks like: 添加库后,代码将如下所示:
File fileToSaveImage = new File(dirToSave, normalizedName);
HtmlImage elementHtmlImage = (HtmlImage) pageWithImage.<HtmlImage>getFirstByXPath(X_PATH_FOR_IMAGE);
elementHtmlImage.saveAs(fileToSaveImage);
Of course you have to care about X_PATH_FOR_IMAGE
, but I am sure it can be generalized by some site-specific pattern. 当然,您必须关心
X_PATH_FOR_IMAGE
,但是我确信可以通过某些特定于站点的模式将其推广。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.