How can I take a screenshot with Selenium WebDriver?

后端 未结 30 2634
不知归路
不知归路 2020-11-21 07:48

Is it possible to take a screenshot using Selenium WebDriver?

(Note: Not Selenium Remote Control)

30条回答
  •  [愿得一人]
    2020-11-21 08:35

    Ruby

    require 'rubygems'
    require 'selenium-webdriver'
    
    driver = Selenium::WebDriver.for :ie
    driver.get "https://www.google.com"
    driver.save_screenshot("./screen.png")
    

    More file types and options are available and you can see them in file takes_screenshot.rb.

提交回复
热议问题