sync with master
Showing
9 changed files
with
73 additions
and
75 deletions
... | @@ -4,9 +4,12 @@ CasperJS Changelog | ... | @@ -4,9 +4,12 @@ CasperJS Changelog |
4 | XXXX-XX-XX, v1.0.0 | 4 | XXXX-XX-XX, v1.0.0 |
5 | ------------------ | 5 | ------------------ |
6 | 6 | ||
7 | - fixed [#215](https://github.com/n1k0/casperjs/issues/215) - fixed broken `--fail-fast` option creating an endless loop on error | 7 | - fixed `page.initialized` event didn't get the initialized `WebPage` instance |
8 | - fixed a bug preventing `Casper.options.onPageInitialized()` from being called | ||
9 | - fixed [#215](https://github.com/n1k0/casperjs/issues/215) - fixed broken `--fail-fast` option creating an endless loop on error | ||
8 | - fixed `Tester.renderFailureDetails()` which couldn't print failure details correctly in certain circumstances | 10 | - fixed `Tester.renderFailureDetails()` which couldn't print failure details correctly in certain circumstances |
9 | - fixed `Casper.getHTML()` wasn't retrieving active frame contents when using `Casper.withFrame()` | 11 | - fixed `Casper.getHTML()` wasn't retrieving active frame contents when using `Casper.withFrame()` |
12 | - fixed [#327](https://github.com/n1k0/casperjs/issues/327) - event handler for `page.confirm` always returns true | ||
10 | - merged PR [#322](https://github.com/n1k0/casperjs/pull/322) - Support number in `Casper.withFrame()` | 13 | - merged PR [#322](https://github.com/n1k0/casperjs/pull/322) - Support number in `Casper.withFrame()` |
11 | - fixed [#323](https://github.com/n1k0/casperjs/issues/323) - `thenEvaluate()` should be updated to take the same parameters as `evaluate()`, while maintaining backwards compatibility. | 14 | - fixed [#323](https://github.com/n1k0/casperjs/issues/323) - `thenEvaluate()` should be updated to take the same parameters as `evaluate()`, while maintaining backwards compatibility. |
12 | - merged PR [#319](https://github.com/n1k0/casperjs/pull/319), fixed [#209](https://github.com/n1k0/casperjs/issues/209) - test duration has been added to XUnit XML result file. | 15 | - merged PR [#319](https://github.com/n1k0/casperjs/pull/319), fixed [#209](https://github.com/n1k0/casperjs/issues/209) - test duration has been added to XUnit XML result file. | ... | ... |
... | @@ -810,7 +810,8 @@ Casper.prototype.getCurrentUrl = function getCurrentUrl() { | ... | @@ -810,7 +810,8 @@ Casper.prototype.getCurrentUrl = function getCurrentUrl() { |
810 | * @param String attribute The attribute name to lookup | 810 | * @param String attribute The attribute name to lookup |
811 | * @return String The requested DOM element attribute value | 811 | * @return String The requested DOM element attribute value |
812 | */ | 812 | */ |
813 | Casper.prototype.getElementAttribute = Casper.prototype.getElementAttr = function getElementAttr(selector, attribute) { | 813 | Casper.prototype.getElementAttribute = |
814 | Casper.prototype.getElementAttr = function getElementAttr(selector, attribute) { | ||
814 | "use strict"; | 815 | "use strict"; |
815 | this.checkStarted(); | 816 | this.checkStarted(); |
816 | return this.evaluate(function _evaluate(selector, attribute) { | 817 | return this.evaluate(function _evaluate(selector, attribute) { |
... | @@ -2027,9 +2028,9 @@ function createPage(casper) { | ... | @@ -2027,9 +2028,9 @@ function createPage(casper) { |
2027 | casper.emit('page.error', msg, trace); | 2028 | casper.emit('page.error', msg, trace); |
2028 | }; | 2029 | }; |
2029 | page.onInitialized = function onInitialized() { | 2030 | page.onInitialized = function onInitialized() { |
2030 | casper.emit('page.initialized', this); | 2031 | casper.emit('page.initialized', page); |
2031 | if (utils.isFunction(casper.options.onPageInitialized)) { | 2032 | if (utils.isFunction(casper.options.onPageInitialized)) { |
2032 | this.log("Post-configuring WebPage instance", "debug"); | 2033 | casper.log("Post-configuring WebPage instance", "debug"); |
2033 | casper.options.onPageInitialized.call(casper, page); | 2034 | casper.options.onPageInitialized.call(casper, page); |
2034 | } | 2035 | } |
2035 | }; | 2036 | }; | ... | ... |
... | @@ -11,7 +11,7 @@ images = [] | ... | @@ -11,7 +11,7 @@ images = [] |
11 | casper.hide = (selector) -> | 11 | casper.hide = (selector) -> |
12 | @evaluate (selector) -> | 12 | @evaluate (selector) -> |
13 | document.querySelector(selector).style.display = "none" | 13 | document.querySelector(selector).style.display = "none" |
14 | , selector: selector | 14 | , selector |
15 | 15 | ||
16 | casper.start "http://www.bbc.co.uk/", -> | 16 | casper.start "http://www.bbc.co.uk/", -> |
17 | nbLinks = @evaluate -> | 17 | nbLinks = @evaluate -> |
... | @@ -21,15 +21,16 @@ casper.start "http://www.bbc.co.uk/", -> | ... | @@ -21,15 +21,16 @@ casper.start "http://www.bbc.co.uk/", -> |
21 | @hide ".nav_left" | 21 | @hide ".nav_left" |
22 | @hide ".nav_right" | 22 | @hide ".nav_right" |
23 | @mouse.move "#promo2_carousel" | 23 | @mouse.move "#promo2_carousel" |
24 | @waitUntilVisible ".autoplay.nav_pause", -> | 24 | |
25 | @echo "Moving over pause button" | 25 | casper.waitUntilVisible ".autoplay.nav_pause", -> |
26 | @mouse.move ".autoplay.nav_pause" | 26 | @echo "Moving over pause button" |
27 | @click ".autoplay.nav_pause" | 27 | @mouse.move ".autoplay.nav_pause" |
28 | @echo "Clicked on pause button" | 28 | @click ".autoplay.nav_pause" |
29 | @waitUntilVisible ".autoplay.nav_play", -> | 29 | @echo "Clicked on pause button" |
30 | @echo "Carousel has been paused" | 30 | @waitUntilVisible ".autoplay.nav_play", -> |
31 | # hide play button | 31 | @echo "Carousel has been paused" |
32 | @hide ".autoplay" | 32 | # hide play button |
33 | @hide ".autoplay" | ||
33 | 34 | ||
34 | # Capture carrousel area | 35 | # Capture carrousel area |
35 | next = -> | 36 | next = -> | ... | ... |
... | @@ -14,9 +14,7 @@ var buildPage, next; | ... | @@ -14,9 +14,7 @@ var buildPage, next; |
14 | casper.hide = function(selector) { | 14 | casper.hide = function(selector) { |
15 | this.evaluate(function(selector) { | 15 | this.evaluate(function(selector) { |
16 | document.querySelector(selector).style.display = "none"; | 16 | document.querySelector(selector).style.display = "none"; |
17 | }, { | 17 | }, selector); |
18 | selector: selector | ||
19 | }); | ||
20 | }; | 18 | }; |
21 | 19 | ||
22 | casper.start("http://www.bbc.co.uk/", function() { | 20 | casper.start("http://www.bbc.co.uk/", function() { |
... | @@ -28,16 +26,17 @@ casper.start("http://www.bbc.co.uk/", function() { | ... | @@ -28,16 +26,17 @@ casper.start("http://www.bbc.co.uk/", function() { |
28 | this.hide(".nav_left"); | 26 | this.hide(".nav_left"); |
29 | this.hide(".nav_right"); | 27 | this.hide(".nav_right"); |
30 | this.mouse.move("#promo2_carousel"); | 28 | this.mouse.move("#promo2_carousel"); |
31 | this.waitUntilVisible(".autoplay.nav_pause", function() { | 29 | }); |
32 | this.echo("Moving over pause button"); | 30 | |
33 | this.mouse.move(".autoplay.nav_pause"); | 31 | casper.waitUntilVisible(".autoplay.nav_pause", function() { |
34 | this.click(".autoplay.nav_pause"); | 32 | this.echo("Moving over pause button"); |
35 | this.echo("Clicked on pause button"); | 33 | this.mouse.move(".autoplay.nav_pause"); |
36 | this.waitUntilVisible(".autoplay.nav_play", function() { | 34 | this.click(".autoplay.nav_pause"); |
37 | this.echo("Carousel has been paused"); | 35 | this.echo("Clicked on pause button"); |
38 | // hide play button | 36 | this.waitUntilVisible(".autoplay.nav_play", function() { |
39 | this.hide(".autoplay"); | 37 | this.echo("Carousel has been paused"); |
40 | }); | 38 | // hide play button |
39 | this.hide(".autoplay"); | ||
41 | }); | 40 | }); |
42 | }); | 41 | }); |
43 | 42 | ... | ... |
... | @@ -2,29 +2,27 @@ | ... | @@ -2,29 +2,27 @@ |
2 | A basic custom logging implementation. The idea is to (extremely) verbosely | 2 | A basic custom logging implementation. The idea is to (extremely) verbosely |
3 | log every received resource. | 3 | log every received resource. |
4 | ### | 4 | ### |
5 | |||
6 | casper = require("casper").create | 5 | casper = require("casper").create |
7 | ### | ||
8 | Every time a resource is received, a new log entry is added to the stack | ||
9 | at the 'verbose' level. | ||
10 | |||
11 | @param Object resource A phantomjs resource object | ||
12 | ### | ||
13 | onResourceReceived: (self, resource) -> | ||
14 | infos = [] | ||
15 | props = [ | ||
16 | "url" | ||
17 | "status" | ||
18 | "statusText" | ||
19 | "redirectURL" | ||
20 | "bodySize" | ||
21 | ] | ||
22 | infos.push resource[prop] for prop in props | ||
23 | infos.push "[#{header.name}: #{header.value}]" for header in resource.headers | ||
24 | @log infos.join(", "), "verbose" | ||
25 | verbose: true # we want to see the log printed out to the console | 6 | verbose: true # we want to see the log printed out to the console |
26 | logLevel: "verbose" # of course we want to see logs to our new level :) | 7 | logLevel: "verbose" # of course we want to see logs to our new level :) |
27 | 8 | ||
9 | ### | ||
10 | Every time a resource is received, a new log entry is added to the stack | ||
11 | at the 'verbose' level. | ||
12 | ### | ||
13 | casper.on 'resource.received', (resource) -> | ||
14 | infos = [] | ||
15 | props = [ | ||
16 | "url" | ||
17 | "status" | ||
18 | "statusText" | ||
19 | "redirectURL" | ||
20 | "bodySize" | ||
21 | ] | ||
22 | infos.push resource[prop] for prop in props | ||
23 | infos.push "[#{header.name}: #{header.value}]" for header in resource.headers | ||
24 | @log infos.join(", "), "verbose" | ||
25 | |||
28 | # add a new 'verbose' logging level at the lowest priority | 26 | # add a new 'verbose' logging level at the lowest priority |
29 | casper.logLevels = ["verbose"].concat casper.logLevels | 27 | casper.logLevels = ["verbose"].concat casper.logLevels |
30 | 28 | ... | ... |
... | @@ -5,37 +5,33 @@ | ... | @@ -5,37 +5,33 @@ |
5 | * A basic custom logging implementation. The idea is to (extremely) verbosely | 5 | * A basic custom logging implementation. The idea is to (extremely) verbosely |
6 | * log every received resource. | 6 | * log every received resource. |
7 | */ | 7 | */ |
8 | |||
9 | var casper = require("casper").create({ | 8 | var casper = require("casper").create({ |
10 | /* | ||
11 | Every time a resource is received, a new log entry is added to the stack at | ||
12 | the 'verbose' level. | ||
13 | */ | ||
14 | onResourceReceived: function(self, resource) { | ||
15 | var header, infos, prop, props, _i, _j, _len, _len1, _ref; | ||
16 | infos = []; | ||
17 | props = [ | ||
18 | "url", | ||
19 | "status", | ||
20 | "statusText", | ||
21 | "redirectURL", | ||
22 | "bodySize" | ||
23 | ]; | ||
24 | for (_i = 0, _len = props.length; _i < _len; _i++) { | ||
25 | prop = props[_i]; | ||
26 | infos.push(resource[prop]); | ||
27 | } | ||
28 | _ref = resource.headers; | ||
29 | for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { | ||
30 | header = _ref[_j]; | ||
31 | infos.push("[" + header.name + ": " + header.value + "]"); | ||
32 | } | ||
33 | this.log(infos.join(", "), "verbose"); | ||
34 | }, | ||
35 | verbose: true, | 9 | verbose: true, |
36 | logLevel: "verbose" | 10 | logLevel: "verbose" |
37 | }); | 11 | }); |
38 | 12 | ||
13 | /** | ||
14 | * Every time a resource is received, a new log entry is added to the stack at | ||
15 | * the 'verbose' level. | ||
16 | */ | ||
17 | casper.on('resource.received', function(resource) { | ||
18 | var infos = []; | ||
19 | var props = [ | ||
20 | "url", | ||
21 | "status", | ||
22 | "statusText", | ||
23 | "redirectURL", | ||
24 | "bodySize" | ||
25 | ]; | ||
26 | props.forEach(function(prop) { | ||
27 | infos.push(resource[prop]); | ||
28 | }); | ||
29 | resource.headers.forEach(function(header) { | ||
30 | infos.push("[" + header.name + ": " + header.value + "]"); | ||
31 | }); | ||
32 | this.log(infos.join(", "), "verbose"); | ||
33 | }); | ||
34 | |||
39 | // add a new 'verbose' logging level at the lowest priority | 35 | // add a new 'verbose' logging level at the lowest priority |
40 | casper.logLevels = ["verbose"].concat(casper.logLevels); | 36 | casper.logLevels = ["verbose"].concat(casper.logLevels); |
41 | 37 | ... | ... |
... | @@ -14,7 +14,7 @@ casper = require("casper").create verbose: true | ... | @@ -14,7 +14,7 @@ casper = require("casper").create verbose: true |
14 | 14 | ||
15 | casper.fetchScore = -> | 15 | casper.fetchScore = -> |
16 | @evaluate -> | 16 | @evaluate -> |
17 | result = document.querySelector('#resultStats').innerText | 17 | result = __utils__.findOne('#resultStats').innerText |
18 | parseInt /Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, '') | 18 | parseInt /Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, '') |
19 | 19 | ||
20 | terms = casper.cli.args # terms are passed through command-line arguments | 20 | terms = casper.cli.args # terms are passed through command-line arguments | ... | ... |
... | @@ -19,7 +19,7 @@ var casper = require("casper").create({ | ... | @@ -19,7 +19,7 @@ var casper = require("casper").create({ |
19 | 19 | ||
20 | casper.fetchScore = function() { | 20 | casper.fetchScore = function() { |
21 | return this.evaluate(function() { | 21 | return this.evaluate(function() { |
22 | var result = document.querySelector('#resultStats').innerText; | 22 | var result = __utils__.findOne('#resultStats').innerText; |
23 | return parseInt(/Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, ''), 10); | 23 | return parseInt(/Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, ''), 10); |
24 | }); | 24 | }); |
25 | }; | 25 | }; | ... | ... |
-
Please register or sign in to post a comment