开发者

selenium rc captureEntirePageScreenshotToString triggers FileNotFoundException

开发者 https://www.devze.com 2023-01-01 17:11 出处:网络
I\'m using selenium rc to do functional website testing and I\'ve recently experienced a mysterious issue with safari and opera.

I'm using selenium rc to do functional website testing and I've recently experienced a mysterious issue with safari and opera. When a test fails I make a screenshot using the captureEntirePageScreenshotToString command as well as retrieving the html source. Sometimes however this fails with a FileNotFoundException: java.io.FileNotFoundException: C:\DOKUME~1开发者_如何转开发\selenium\LOKALE~1\Temp\customProfileDir8aa20800ab1a46dbb3ef71d4d2d31b77\screenshots\page-screenshot-8aa20800ab1a46dbb3ef71d4d2d31b77.png

Is this a selenium bug? How can I workaround this issue?

I'm using selenium rc standalone 2.0a4.

thanks,

hans


So I've been using the 'captureScreenshotToString' method which is a little different, but still provides the means to get a screenshot from a remote selenium instance.

The large different/problem with this approach is that it requires the selenium server to be an unlocked windows session so it can access the display buffer to get at the physical screen. This has created problems with my headless selenium-grid machines, that I remote desktop into to administrate/troubleshoot.

In order to workaround that I've used an autologon script for this msdn article, and setup a task to restart the computer after a remote desktop session ends.

To setup Auto-Restart after remote desktop disconnect:

  1. Open up the task scheduler
  2. Create a new task (Create task...)
  3. Set the name of the task to be 'Auto-Restart after remote desktop disconnect'
  4. In the General tab, change the user to NT AUTHORITY\SYSTEM
  5. Change to the Triggers tab, click New... to create a new trigger
  6. Set the Begin the task to 'On disconnect from user session'
  7. By default, it will be for any user, and from remote computers, which is exactly what we are looking for.
  8. Change to the Actions tab, click New... to create a new action
  9. Select the action to be Start a program. Set the program to be 'C:\Windows\System32\shutdown.exe', and then add '/r /f /t 5' (Restart, Force quit applications, wait 5 seconds to restart).

Fair warning, this is not the most secure way to have a computer sitting around


I suggest you use the Apache Commons FileUtils function makeDirs() to create all the parent directories of the directory where the png image will be located.

0

精彩评论

暂无评论...
验证码 换一张
取 消