Gather screenshots using ruby/watir-webdriver and use them with if exists(path to image taken by webdriver)

Asked by Jeff Ducharme

Would like to be able to gather screenshots using ruby/watir-webdriver to save images to a file then insert the path to them into sikuli using variables, i.e. if exists(path to image taken by webdriver) is this sort of thing possible?

webdriver has some simple method for saving a screenshot
browser.screenshot.save 'testscreenshot.png'

this I should be able to then set as a variable and save the list of variables to a spreadsheet

how do i then pass these variables (paths to image) into my sikuli script

this would be most helpful for completely automating a screenshot comparison test at our company

(btw, we have a framework based on watir-webdriver that includes sikuli support, meaning we can call out sikuli tests from within a webdriver test"

Goal, to have a script to open a webpage, navigate to an element I need a screenshot of, take screenshot, save path as variable to be using in our sikuli script, size browser, take another SH, repeat process with a couple times at various sizes.

then later, another script would set the initial sikuli script variables for the baseline tests.

then another webdriver script to open the image in a browser and call the associated sikuli script with the baseline image to verify the images still match.

p.s. I know this is alot but I think I just need to know a couple things. Can sikuli read a spreadsheet file? Can I set the path to an image in, lets say the exist function, to a variable in the sikuli IDE?

needless to say I'm newer with python and sikuli, any help would be absolutely amazing

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

Why being so complicated using a spreadsheet (but which would be possible to read from Sikuli using xlrd) ;-)

Just make a simple textfile:

# images.py
img1 = "path-to-image-1.png"
img2 = "path-to-image-2.png"
.... and more of those

In your using script just say:
from images import *

where the folder containing images.py must be in sys.path.

The rest is done by Jython ;-)

Revision history for this message
RaiMan (raimund-hocke) said :
#2

The magic behind you should know from Ruby: we simply make a valid Python script, that is imported into another script.

About importing things in Sikuli and reuse images:
http://sikuli.org/docx/globals.html#importing-other-sikuli-scripts-reuse-code-and-images

Revision history for this message
Jeff Ducharme (loyh-jeff) said :
#3

Wonderful. I will try this first thing Monday morning but it looks very promising. This could save me endless hours taking my baseline comparison screenshots for this project by automating the entire process start to finish. Thank you very much for the help RaiMan.