简体   繁体   English

使用硒在后台进行屏幕截图

[英]Take Screen Shot in Background using Selenium

I am Running the Script in IE browser. 我正在IE浏览器中运行脚本。 I have a problem, when I run the script and try to do other task on my PC the script run successfully BUT its capture the screen shots of the current window not the one in which the script is running Ie IE browser 我有一个问题,当我运行脚本并尝试在PC上执行其他任务时,脚本运行成功,但是它捕获了当前窗口的屏幕截图,而不是脚本正在运行的那个窗口(即IE浏览器)

How can I Capture the screen shot of the browser in which the script is running ? 如何捕获运行脚本的浏览器的屏幕快照? I am using following command for capturing the screen 我正在使用以下命令捕获屏幕

  selenium.captureScreenshot("D:/screen_" + System.currentTimeMillis()+".jpg");      

I want to execute the script and take screen shot but at the same time I want to do my other task. 我想执行脚本并进行屏幕截图,但同时我想执行其他任务。 After successfully execution i just want to check my screen shots. 成功执行后,我只想检查我的屏幕截图。

Any Suggestion ? 有什么建议吗?

Thanks Dushyant 感谢Dushyant

In current user session, If you move focus on different window then It will capture current window. 在当前用户会话中,如果将焦点移到其他窗口,则它将捕获当前窗口。

Solution - Use window focus command prior to screenshot command but it might disturbing as you are working on some other windows and its moved to other window 解决方案-在截图命令之前使用窗口焦点命令,但是在您正在其他一些窗口上工作以及将其移至其他窗口时可能会打扰

Other solutions - As Lucas mentions - Run on different user session 其他解决方案-正如卢卡斯提到的-在不同的用户会话上运行
Or run on different machine/VM Or keep machine ideal 或在其他机器/ VM上运行或保持机器理想

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM