Selenium Webdriver-在屏幕截图中捕获URL [英] Selenium Webdriver - Capture URL in screenshot

查看:347
本文介绍了Selenium Webdriver-在屏幕截图中捕获URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道屏幕截图功能基本上可以像绘制DOM一样工作.由于URL不属于DOM,因此屏幕截图不包含URL.但是,是否有任何解决方法可将URL捕获为屏幕截图的一部分?

I understand that the screenshot functionality basically works as painting the DOM. Since the URL is not part of the DOM, the screenshot does not contain the URL. But is there any workaround to capture the URL as part of the screenshot?

推荐答案

当前无法使用webdriver.

Currently it is not possible with webdriver.

您可以采用以下任何一种方法. (您没有提到编程语言.这些示例是Java的.)

You can follow any of the below approaches. (You did not mention the programming language. These examples are in Java.)

1.捕获当前的桌面屏幕

机器人具有createScreenCapture方法.所以,我会选择&这很容易实现.

Robot has createScreenCapture method. So, I would go with that & It is very easy to implement.

    Robot robot = new Robot();
    BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
    ImageIO.write(screenShot, "JPG", new File("ScreenShot.jpg"));

2.您可以在图像中写入URL.

有时这可能是一种令人讨厌的方法,因为它可能会在图像中隐藏信息.但这也很容易实现.

This might be an annoying approach sometimes as it might hide information in the image. But this too is very easy to implement.

选中此答案

3.将当前URL作为元数据添加到图像

选中此答案

这篇关于Selenium Webdriver-在屏幕截图中捕获URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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