java - store snapshots on server -


webdriver driver = new firefoxdriver();  driver.get("http://www.google.com/");  file scrfile = ((takesscreenshot)driver).getscreenshotas(outputtype.file);  fileutils.copyfile(scrfile, new file("c:\\tmp\\screenshot.png")); 

using code take snapshots using selenium web-driver. code stores snaphots locally on pc. if want run automatically jenkins, there way store snapshots somewhere else if runs either though jenkins or locally pc, don't have change link(("c:\tmp\screenshot.png") every time.

you make location of output file controlled setting - either command-line argument tool running code (if can modify that), or environment variable can read section of code above. have default location exists , should writable user's home directory, rather absolute path c:\tmp.

in jenkins, have step (in ant script, shell script, or whatnot) create folder called "screenshots" below $workspace, , tell tool that's going run code location 1 of methods suggested above. handy if want make screenshots part of job's output.

also, unless ever need latest file (or have downstream code consuming screenshot , expecting specific name), introduce timestamp or other variable file-naming png in code above, e.g. screenshot-2014-05-16_12-15-37.png, if run tool twice doesn't overwrite file there before.

hth


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -