How can I take a screenshot with Selenium WebDriver?

后端 未结 30 2620
不知归路
不知归路 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:26

    Ruby

    time = Time.now.strftime('%a_%e_%Y_%l_%m_%p_%M_%S')
    file_path = File.expand_path(File.dirname(__FILE__) + 'screens_shot')+'/'+time +'.png'
    #driver.save_screenshot(file_path)
    page.driver.browser.save_screenshot file_path
    

提交回复
热议问题