Website screenshot automation

I was given the terrible task of doing this.

  • Launch the website.
  • Take a screenshot
  • Fill out the details of the form, click "Next"
  • Take a screenshot
  • ...
  • ...
  • ...

Rinsing. Reiteration.

Now, with various combinations, these are up to 300 screenshots.

And I have to do it for 4 different browsers. Chrome, Firefox, IE 6 and IE 7.

I can’t use tools that will capture a screenshot and store them, such as SnagIT. I need to take a screenshot, copy it to a Word document and take a second screenshot and transfer it to a Word document.

I thought I would write a tiny utility that would help me do this. Here is the specification of the requirements that I endure for her -

  • An executable file that once launched itself in the system tray.
  • , (Print Scrn) Word, ( , ).
  • .

, : # (Winforms), .

#, . , , . , Print Scrn.

, ? . , .

!

+3
4

WatiN firefox. , , , .

, - .org .

+3

, AutoIt, , , , .

+2

, , .

- WatiN Selenium. , - http://www.vikramlakhotia.com/Capturing_the_image_of_the_screen_using_C.aspx. Word Office. , .:)

Good luck. Let me know how it works.

+1
source

So, you can do this with both cucumbers and Capybara, but the path of the cucumber is much easier. First, create two folders in the project file: (1) failed_png and (2) success_png. Then in the env.rb file, paste the following code:

After do |scenario|
  take_screenshot(@browser, scenario)
end

def take_screenshot(browser, scenario)
  if scenario.failed?
    scenario_name = scenario.name.gsub /[^\w\-]/, ' '
    time = Time.now.strftime("%Y-%m-%d %H%M")
    screenshot_path = './failed_png/' + time + ' - ' + scenario_name + '.png'
  else
    scenario_name = scenario.name.gsub /[^\w\-]/, ' '
    time = Time.now.strftime("%Y-%m-%d %H%M")
    screenshot_path = './success_png/' + time + ' - ' + scenario_name + '.png'
  end
  browser.save_screenshot(screenshot_path)
end

This takes a screenshot after each script and places it either in the SUCCESS folder or in the FAILED folder corresponding to the timestamp on it.

For a complete env.rb file and additional documentation, see my blog at whitneytaylorimura.wordpress.com

0
source

All Articles