简体   繁体   English

谁能建议如何使用 ruby​​ selenium 截取整个网页的屏幕截图?

[英]Can anyone suggest how to take screenshot of full webpage using ruby selenium?

I want to capture full webpage screenshot in chrome browser using ruby selenium.我想使用 ruby​​ selenium 在 chrome 浏览器中捕获完整的网页截图。 I am using Rspec testing framework.我正在使用 Rspec 测试框架。 save_screenshot<\/code> method captures screenshot only for visible area. save_screenshot<\/code>方法仅捕获可见区域的屏幕截图。 I have gone through the following link,我已经通过以下链接,

How to take a screenshot of a full browser page and its elements using selenium-webdriver\/capybara in Ruby?<\/a> 如何在 Ruby 中使用 selenium-webdriver\/capybara 截取完整的浏览器页面及其元素?<\/a>

But I don't want to use window resizing or watir gem.但我不想使用窗口大小调整或 watir gem。 Is there any other way or gem to achieve same.有没有其他方法或宝石来实现相同的目标。

"

1) You can use https://github.com/samnissen/watir-screenshot-stitch where 1)您可以使用https://github.com/samnissen/watir-screenshot-stitch在哪里

  • Directly employing geckodriver's new full page screenshot functionality (only on Firefox).直接使用 geckodriver 新的整页截图功能(仅在 Firefox 上)。
  • Screenshot stitching, paging down a given URL by the size of the viewport, capturing screenshots and adjoining them.屏幕截图拼接,按视口的大小向下翻页给定的 URL,捕获屏幕截图并与它们相邻。
  • Employing a bundled html2canvas script against the page to generate a png from a canvas element.针对页面使用捆绑的 html2canvas 脚本以从画布元素生成 png。

2) or use native instrument for your OS - https://paulhammond.org/webkit2png 2)或为您的操作系统使用本机工具 - https://paulhammond.org/webkit2png
In code will look like this在代码中看起来像这样
webkit2png https://stackoverflow.com/questions/60728482/can-anyone-suggest-how-to-take-screenshot-of-full-webpage-using-ruby-selenium

where:在哪里:
- main command - webkit2png - 主命令 - webkit2png
- link page - all else - 链接页面 - all else

It's old question, but it doesn't hurt to post this.这是个老问题,但发布这个并没有什么坏处。 Use Scrot to take screenshot, and later make gif.使用Scrot截屏,稍后制作gif。 Since OP only want screenshots, command would be:由于 OP 只想要屏幕截图,因此命令将是:

require 'screenscrot'
@screen = ScreenScrot.new
@screen.capture(:all)

暂无
暂无

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

相关问题 如何在 Ruby 中使用 selenium-webdriver/capybara 截取完整浏览器页面及其元素的屏幕截图? - How to take a screenshot of a full browser page and its elements using selenium-webdriver/capybara in Ruby? Ruby + Selenium-执行每个步骤后截屏 - Ruby + Selenium - Take a screenshot with each step executed 如何使用Ruby在Selenium Webdriver中使用屏幕快照名称中包含日期和时间的屏幕快照? - How to take screenshot in selenium webdriver with ruby with date and time included in screenshot name? 如何使用Ruby Selenium Webdriver进行操作系统级别的屏幕截图 - How to take an OS level screen capture using ruby selenium webdriver 使用selenium-webdriver / rc rails整个屏幕的ScreenShot - ScreenShot of entire webpage using selenium-webdriver/ rc rails 使用黄瓜时无法在Chrome中获取完整的浏览器页面的屏幕截图 - Unable to take screenshot of full browser page in chrome while using cucumber 以编程方式在Ruby中使用ScreenShot of Desktop? - Programmatically take ScreenShot of Desktop in Ruby? Ruby Capybara Poltergeist,如何为具有所需登录名的页面拍摄屏幕截图 - Ruby Capybara Poltergeist, how to take screenshot for a page with required login 使用Ruby自动将场景名称添加到Selenium中的屏幕快照文件名 - Automatically add Scenario name to filename of screenshot in Selenium using Ruby 使用watir扩展元素截图截屏 - Take screenshot using watir extension element screenshot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM