在页面&中查找损坏的图像图片替换为另一张图片 [英] Find broken images in page & image replace by another image

查看:80
本文介绍了在页面&中查找损坏的图像图片替换为另一张图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Selenium Webdriver 2.25.0&面对一些严重的问题,

Hi I am using selenium webdriver 2.25.0 & faceing the some serious issues,

  1. 如何使用Selenium Webdriver在页面中查找损坏的图像
  2. 如何使用Webdriver将图像替换为另一个具有相同名称的图像(这也是bug).

提前感谢您的有价值的建议.

Thanks in advance for your value-able suggestions.

推荐答案

下一行未进行优化,但它们可能会找到损坏的图像:

The next lines are not optimized, but they could find broken images:

List<WebElement> imagesList = _driver.findElements(By.tagName("img"));
for (WebElement image : imagesList)
{
    HttpResponse response = new DefaultHttpClient().execute(new HttpGet(image.getAttribute("src");));
    if (response.getStatusLine().getStatusCode() != 200)
        // Do whatever you want with broken images
}

关于您的第二个问题,我认为我没有正确理解它.您能详细解释一下吗?

Regarding your second issue, I think I didn't understand it correctly. Could you explain it with more detail?

这篇关于在页面&amp;中查找损坏的图像图片替换为另一张图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆