ScreenCapture

54 views
Skip to first unread message

Joseph Adams

unread,
May 27, 2008, 6:56:22 AM5/27/08
to watir-...@googlegroups.com
hi all,

I installed a gem (ScreenCapture) on my machine but the drive crashed and I lost my setup.

I am trying to install this gem again, but cannot seem to find it.

Can anyone help?

Thanks

Joe

John Kolokotronis

unread,
May 27, 2008, 8:09:24 AM5/27/08
to Watir General
There's screen capture functionality built into Watir itself, but as
it uses Paint,
I prefer to use the Win32 Screenshot gem instead (assuming you're on
Windows
that is...):

gem install win32screenshot

Joseph Adams

unread,
May 27, 2008, 9:07:53 AM5/27/08
to watir-...@googlegroups.com
It was the paint one I used...

2008/5/27 John Kolokotronis <john...@gmail.com>:

marekj

unread,
May 27, 2008, 10:37:19 AM5/27/08
to watir-...@googlegroups.com
Perhaps this may help.
http://www.marekj.com/2008/04/21/desktop-screenshots-with-watir-win32screenshot-and-rmagick/
--
marekj

www.testr.us | semantic test objects modeling in watir

Paul Rogers

unread,
May 27, 2008, 11:11:31 AM5/27/08
to watir-...@googlegroups.com
I found Rmagick very dificult to set up.

Its probably cheaper to spend $40 on snag it ( which is what Im about to do ;-)

Paul

John Kolokotronis

unread,
May 27, 2008, 2:56:38 PM5/27/08
to Watir General
Then you don't need to install a gem...

There's a script called "screen_capture.rb" in your watir installation
folder and including that in your scripts gives you the screenshot
capability via Paint as you're used to it...

Dave McNulla

unread,
May 27, 2008, 3:58:36 PM5/27/08
to Watir General
One place to find a lot of gems:
http://mirrors.cat.pdx.edu/rubyforge/rubyforge-gems/

Dave

90kts

unread,
Jun 2, 2008, 3:31:47 AM6/2/08
to Watir General
Hmmm, wasn't happy paying for SnagIt, and had some teething problems
with those recommended gems. So I've rolled my own solution ...

First thing I did was created a small app called snapit.exe which you
can download <a href='http://90kts.com/blog/wp-content/uploads/2008/06/
snapit.exe' title='snapIt.exe by 90kts'>here</a>. If anyone is
interested in improving the code, you're welcome to get a copy of my
source code <a href='http://90kts.com/blog/wp-content/uploads/2008/06/
snapit.zip' title='snapIt Source Code'>here</a>. In short, all this
app does is take a screenshot of the entire screen, and save it to a
default location (currently C:\snapit.png). Repeated use of the app
will increment the filename by 1 i.e. snapit1.png, snapit2.png ...

You can change the default file path by passing it a parameter at
runtime
e.g. D:\snapit.exe D:\images\testcase.png

Next thing to do is call it from your watir code. In Ruby, this is as
simple as:
cmd = 'D:\\snapit.exe'
puts %x{#{cmd}}

Putting it all together with some watir as an example:
require "watir"
test_site = "http://www.90kts.com"
ie = Watir::IE.new
ie.goto test_site
ie.link(:text, "Contact").click
cmd = 'D:\\snapit.exe D:\\images\testsuite.png'
puts %x{#{cmd}}

Cheers,
Tim

Željko Filipin

unread,
Nov 22, 2012, 11:31:37 AM11/22/12
to watir-...@googlegroups.com
On Thu, Nov 22, 2012 at 5:28 PM, Alok Prasad <alok...@gmail.com> wrote:
> I tried this code but it gave me a error saying
> Errno:EINVAL:Invalid argument

Watir now has screen shots built in:

Jarmo Pertman

unread,
Nov 24, 2012, 6:02:41 AM11/24/12
to watir-...@googlegroups.com
Lose the "driver" part - this makes the code work in both of watir-webdriver and watir-classic. So you would do like this instead:
b.save_screenshot("screenshot.png")

Jarmo Pertman
-----
IT does really matter - http://itreallymatters.net


On Friday, November 23, 2012 9:23:20 PM UTC+2, MEDBEDb wrote:
I do it as simple as that: 
b.driver.save_screenshot "#{__FILE__}.png"
Where it saves renames the screen after .rb script name.
Reply all
Reply to author
Forward
0 new messages