Skip to content

Commit

Permalink
new example configs and fixed #325
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBAshton committed Nov 30, 2015
1 parent 43816ce commit 2485487
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 39 deletions.
1 change: 1 addition & 0 deletions lib/wraith/javascript/phantom--nojs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var system = require('system');

// @TODO - make a javascript_disabled property in YAML, and pass via command line
require('./_phantom__common.js')({
systemArgs: system.args,
javascriptEnabled: false
Expand Down
8 changes: 1 addition & 7 deletions templates/configs/component.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@ screen_widths:
- 1280

# the engine to run Wraith with.
browser:
phantomjs: "casperjs" # variant of PhantomJS that allows screenshots by element selector
#phantomjs: "phantomjs" # PhantomJS, built on top of Webkit and JavascriptCore (like Safari)
#slimerjs: "slimerjs" # SlimerJS, built on top of Gecko and SpiderMonkey (like Firefox)

# the file in charge of taking the screenshot
snap_file: "javascript/casper.js"
browser: "casperjs"

# the directory that your base screenshots will be stored in
history_dir: 'shots_base'
Expand Down
10 changes: 2 additions & 8 deletions templates/configs/multiple_domains.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,8 @@ screen_widths:
- 1024
- 1280

# the engine to run Wraith with.
browser:
#phantomjs: "casperjs" # variant of PhantomJS that allows screenshots by element selector
phantomjs: "phantomjs" # PhantomJS, built on top of Webkit and JavascriptCore (like Safari)
#slimerjs: "slimerjs" # SlimerJS, built on top of Gecko and SpiderMonkey (like Firefox)

# the file in charge of taking the screenshot
snap_file: "javascript/phantom--nojs.js"
# the engine to run Wraith with. Examples: 'phantomjs', 'casperjs', 'slimerjs'
browser: "phantomjs"

# the directory that your base screenshots will be stored in
history_dir: 'shots_base'
Expand Down
32 changes: 13 additions & 19 deletions templates/configs/spider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ domains:

# Notice the absence of a `paths` property. When no paths are provided, Wraith defaults to
# spidering mode to check your entire website.
# A list of URLs to skip when spidering.
# Ruby regular expressions can be used, if prefixed with `!ruby/regexp` as defined in the YAML Cookbook​.
# See http://www.yaml.org/YAML_for_ruby.html#regexps
spider_skips:
- /foo/bar.html # Matches /foo/bar.html explicitly
- !ruby/regexp /^\/baz\// # Matches any URLs that start with /baz

# the filename of the spider file to use. Default: spider.txt

# A list of URLs to skip when spidering.
# Ruby regular expressions can be used, if prefixed with `!ruby/regexp` as defined in the YAML Cookbook​.
# See http://www.yaml.org/YAML_for_ruby.html#regexps
spider_skips:
- /foo/bar.html # Matches /foo/bar.html explicitly
- !ruby/regexp /^\/baz\// # Matches any URLs that start with /baz

# the filename of the spider file to use. Default: spider.txt
spider_file: example_com_spider.txt
# the number of days to keep the site spider file
spider_days: 10

# the number of days to keep the site spider file
spider_days: 10

# amount of fuzz ImageMagick will use when comparing images. A higher fuzz makes the comparison less strict.
fuzz: '20%'
Expand All @@ -35,13 +35,7 @@ screen_widths:
- 1280

# the engine to run Wraith with.
browser:
#phantomjs: "casperjs" # variant of PhantomJS that allows screenshots by element selector
phantomjs: "phantomjs" # PhantomJS, built on top of Webkit and JavascriptCore (like Safari)
#slimerjs: "slimerjs" # SlimerJS, built on top of Gecko and SpiderMonkey (like Firefox)

# the file in charge of taking the screenshot
snap_file: "javascript/phantom.js"
browser: "phantomjs"

# the directory that your latest screenshots will be stored in
directory: 'shots_nojs'
Expand Down
13 changes: 10 additions & 3 deletions templates/javascript/beforeCapture--casper_example.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
module.exports = function (browserEngine) {
browserEngine.wait(2000, function() {
browserEngine.click('.ns-panel__hotspot--2');
module.exports = function (casper) {

/* you may want to test some interaction on the page */
casper.wait(2000, function() {
casper.click('.ns-panel__hotspot--2');
});

/* or you may want to see how your page looks without JavaScript */
// casper.options.pageSettings.javascriptEnabled = false;
// casper.thenOpen(casper.page.url);

}
11 changes: 9 additions & 2 deletions templates/javascript/beforeCapture--phantom_example.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
module.exports = function (browserEngine) {
browserEngine.evaluate(function(){
module.exports = function (phantom) {

/* you may want to test some interaction on the page */
phantom.evaluate(function(){
var a = document.querySelector('.ns-panel__hotspot--2');
var e = document.createEvent('MouseEvents');
e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
a.dispatchEvent(e);
waitforload = true;
});

/* or you may want to see how your page looks without JavaScript */
// phantom.settings.javascriptEnabled = false;
// phantom.open(phantom.page.url);

}

0 comments on commit 2485487

Please sign in to comment.