Capture screen on server desktop session

后端 未结 6 1373
臣服心动
臣服心动 2020-11-30 06:17

I have developed a GUI test framework that does integrationtesting of our company website on a scheduled basis. When something fails, it\'ll take a screenshot of the desktop

6条回答
  •  感动是毒
    2020-11-30 06:31

    This is not a supported feature it is true that it works in XP and windows server 2003 however this is seen as security flaw.

    To prevent this, don't use the 'x' to close the remote connection, but use %windir%\system32\tscon.exe 0 /dest:console instead. (That will insure that the screen isn't locked). - Nicolas Voron

    It true that if you disconnect from the server in this way the "screen" wont be locked to ensure it stay unlocked you need to make sure you turn off the screen saver since as soon as that start up it will auto lock you screen.

    There is quite a few examples only of people doing the same thing even here at stack overflow the post below suggest that you create a windows application that run under an actual user account that sends screen shots over IPC to the running service.

    The correct way to get a custom GUI that works with a service is to separate them into two processes and do some kind of IPC (inter process communication). So the service will start-up when the machine comes up and a GUI application will be started in the user session. In that case the GUI can create a screenshot, send it to the service and the service can do with it, whatever you like. - Screenshot of process under Windows Service

    I have collated a few strategies I have found online that may give you some ideas.

    Third party software

    There is a lot of programs out there that make screen shots of web sites like http://www.websitescreenshots.com/ they have a user interface and command line tool. But if you are using some testing framework this might not work since it will make a new request to fetch all the assets and draw the page.

    WebBrowser control

    I am not sure what browser you are using to test you company web site however if you are not bothered about which browser It is you could use a WebBrowser control and use the DrawToBitmap method.

    Virtualisation

    I have seen a system where the developers were using virtual environments with the browser of their choice with all the settings done to make sure the machine didn't lock and if it did it would restart.

    Selenium

    It is also possible using selenium with the selenium-webdriver and headless a ruby gem developed by leonid-shevtsov if your test are in selenium this approach might be the best. Selenium itself support screen capture on the webdrivers they have available.

    Of course all of this depends on what you are using for your testing framework if you can share some details on your setup we will be able to give you a better answer.

提交回复
热议问题