selenium rc captureEntirePageScreenshotToString 触发 FileNotFoundException

发布于 2024-09-03 16:18:10 字数 437 浏览 3 评论 0原文

我正在使用 selenium rc 进行功能网站测试,最近我在 safari 和 opera 方面遇到了一个神秘的问题。 当测试失败时,我使用 captureEntirePageScreenshotToString 命令制作屏幕截图并检索 html 源。 但有时会失败并出现 FileNotFoundException: java.io.FileNotFoundException: C:\DOKUME~1\selenium\LOKALE~1\Temp\customProfileDir8aa20800ab1a46dbb3ef71d4d2d31b77\screenshots\page-screenshot-8aa20800ab1a46dbb3ef71d4d2d31b77.png

这是一个硒错误吗?我该如何解决这个问题?

我正在使用 selenium rc 独立版 2.0a4。

谢谢,

汉斯

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌︼了一个春 2024-09-10 16:18:10

因此,我一直在使用“captureScreenshotToString”方法,该方法有点不同,但仍然提供了从远程 selenium 实例获取屏幕截图的方法。

这种方法的最大不同/问题是,它要求 selenium 服务器是解锁的 Windows 会话,以便它可以访问显示缓冲区以获取物理屏幕。这给我的无头硒网格机器带来了问题,我通过远程桌面进行管理/故障排除。

为了解决这个问题,我为此 msdn 文章 使用了自动登录脚本,并设置了一个任务在远程桌面会话结束后重新启动计算机。

要设置远程桌面断开连接后自动重新启动:

  1. 打开任务计划程序
  2. 创建一个新任务(创建任务...)
  3. 将任务名称设置为“远程桌面断开连接后自动重新启动”
  4. 在常规选项卡中,更改用户到 NT AUTHORITY\SYSTEM
  5. 更改到“触发器”选项卡,单击“新建...”以创建新触发器
  6. 将“开始任务”设置为“与用户会话断开连接时”
  7. 默认情况下,它将适用于任何用户,并且来自远程计算机,这正是我们正在寻找的。
  8. 切换到“操作”选项卡,单击“新建...”以创建新操作
  9. 选择要启动程序的操作。将程序设置为“C:\Windows\System32\shutdown.exe”,然后添加“/r /f /t 5”(重新启动,强制退出应用程序,等待5秒重新启动)。

公平警告,这不是让计算机闲置的最安全方式

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

帅气尐潴 2024-09-10 16:18:10

我建议您使用 Apache Commons FileUtils 函数 makeDirs() 创建 png 图像所在目录的所有父目录。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文