fixed getHTML() doesn't retrieve active frame contents
Showing
4 changed files
with
15 additions
and
6 deletions
... | @@ -4,7 +4,8 @@ CasperJS Changelog | ... | @@ -4,7 +4,8 @@ CasperJS Changelog |
4 | XXXX-XX-XX, v1.0.0 | 4 | XXXX-XX-XX, v1.0.0 |
5 | ------------------ | 5 | ------------------ |
6 | 6 | ||
7 | - merged PR [#322](https://github.com/n1k0/casperjs/pull/322) - Support number in withFrame() | 7 | - fixed `Casper.getHTML()` wasn't retrieving active frame contents when using `Casper.withFrame()` |
8 | - merged PR [#322](https://github.com/n1k0/casperjs/pull/322) - Support number in `Casper.withFrame()` | ||
8 | - fixed [#323](https://github.com/n1k0/casperjs/issues/323) - `thenEvaluate()` should be updated to take the same parameters as `evaluate()`, while maintaining backwards compatibility. | 9 | - fixed [#323](https://github.com/n1k0/casperjs/issues/323) - `thenEvaluate()` should be updated to take the same parameters as `evaluate()`, while maintaining backwards compatibility. |
9 | - 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. | 10 | - 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. |
10 | - `Casper.userAgent()` does not require the instance to be started anymore | 11 | - `Casper.userAgent()` does not require the instance to be started anymore | ... | ... |
... | @@ -770,7 +770,7 @@ Casper.prototype.getPageContent = function getPageContent() { | ... | @@ -770,7 +770,7 @@ Casper.prototype.getPageContent = function getPageContent() { |
770 | this.checkStarted(); | 770 | this.checkStarted(); |
771 | var contentType = utils.getPropertyPath(this, 'currentResponse.contentType'); | 771 | var contentType = utils.getPropertyPath(this, 'currentResponse.contentType'); |
772 | if (!utils.isString(contentType)) { | 772 | if (!utils.isString(contentType)) { |
773 | return this.page.content; | 773 | return this.page.frameContent; |
774 | } | 774 | } |
775 | // for some reason webkit/qtwebkit will always enclose body contents within html tags | 775 | // for some reason webkit/qtwebkit will always enclose body contents within html tags |
776 | var sanitizedHtml = this.evaluate(function checkHtml() { | 776 | var sanitizedHtml = this.evaluate(function checkHtml() { |
... | @@ -780,7 +780,7 @@ Casper.prototype.getPageContent = function getPageContent() { | ... | @@ -780,7 +780,7 @@ Casper.prototype.getPageContent = function getPageContent() { |
780 | return __utils__.findOne('body pre').textContent.trim(); | 780 | return __utils__.findOne('body pre').textContent.trim(); |
781 | } | 781 | } |
782 | }); | 782 | }); |
783 | return sanitizedHtml ? sanitizedHtml : this.page.content; | 783 | return sanitizedHtml ? sanitizedHtml : this.page.frameContent; |
784 | }; | 784 | }; |
785 | 785 | ||
786 | /** | 786 | /** |
... | @@ -931,7 +931,7 @@ Casper.prototype.getHTML = function getHTML(selector, outer) { | ... | @@ -931,7 +931,7 @@ Casper.prototype.getHTML = function getHTML(selector, outer) { |
931 | "use strict"; | 931 | "use strict"; |
932 | this.checkStarted(); | 932 | this.checkStarted(); |
933 | if (!selector) { | 933 | if (!selector) { |
934 | return this.page.content; | 934 | return this.page.frameContent; |
935 | } | 935 | } |
936 | if (!this.exists(selector)) { | 936 | if (!this.exists(selector)) { |
937 | throw new CasperError("No element matching selector found: " + selector); | 937 | throw new CasperError("No element matching selector found: " + selector); | ... | ... |
... | @@ -367,6 +367,9 @@ Tester.prototype.assertHttpStatus = function assertHttpStatus(status, message) { | ... | @@ -367,6 +367,9 @@ Tester.prototype.assertHttpStatus = function assertHttpStatus(status, message) { |
367 | */ | 367 | */ |
368 | Tester.prototype.assertMatch = Tester.prototype.assertMatches = function assertMatch(subject, pattern, message) { | 368 | Tester.prototype.assertMatch = Tester.prototype.assertMatches = function assertMatch(subject, pattern, message) { |
369 | "use strict"; | 369 | "use strict"; |
370 | if (utils.betterTypeOf(pattern) !== "regexp") { | ||
371 | throw new CasperError('Invalid regexp.'); | ||
372 | } | ||
370 | return this.assert(pattern.test(subject), message, { | 373 | return this.assert(pattern.test(subject), message, { |
371 | type: "assertMatch", | 374 | type: "assertMatch", |
372 | standard: "Subject matches the provided pattern", | 375 | standard: "Subject matches the provided pattern", |
... | @@ -609,6 +612,9 @@ Tester.prototype.assertTitle = function assertTitle(expected, message) { | ... | @@ -609,6 +612,9 @@ Tester.prototype.assertTitle = function assertTitle(expected, message) { |
609 | */ | 612 | */ |
610 | Tester.prototype.assertTitleMatch = Tester.prototype.assertTitleMatches = function assertTitleMatch(pattern, message) { | 613 | Tester.prototype.assertTitleMatch = Tester.prototype.assertTitleMatches = function assertTitleMatch(pattern, message) { |
611 | "use strict"; | 614 | "use strict"; |
615 | if (utils.betterTypeOf(pattern) !== "regexp") { | ||
616 | throw new CasperError('Invalid regexp.'); | ||
617 | } | ||
612 | var currentTitle = this.casper.getTitle(); | 618 | var currentTitle = this.casper.getTitle(); |
613 | return this.assert(pattern.test(currentTitle), message, { | 619 | return this.assert(pattern.test(currentTitle), message, { |
614 | type: "assertTitle", | 620 | type: "assertTitle", | ... | ... |
1 | /*global casper __utils__*/ | 1 | /*global casper __utils__*/ |
2 | /*jshint strict:false*/ | 2 | /*jshint strict:false*/ |
3 | casper.start('tests/site/frames.html'); | 3 | casper.start('tests/site/frames.html').wait(1000); |
4 | 4 | ||
5 | casper.withFrame('frame1', function() { | 5 | casper.withFrame('frame1', function() { |
6 | this.test.assertTitle('CasperJS frame 1'); | 6 | this.test.assertTitle('CasperJS frame 1'); |
... | @@ -9,6 +9,8 @@ casper.withFrame('frame1', function() { | ... | @@ -9,6 +9,8 @@ casper.withFrame('frame1', function() { |
9 | this.test.assertEval(function() { | 9 | this.test.assertEval(function() { |
10 | return '__utils__' in window && 'getBinary' in __utils__; | 10 | return '__utils__' in window && 'getBinary' in __utils__; |
11 | }, '__utils__ object is available in child frame'); | 11 | }, '__utils__ object is available in child frame'); |
12 | this.test.assertMatches(this.page.frameContent, /This is frame 1/); | ||
13 | this.test.assertMatches(this.getHTML(), /This is frame 1/); | ||
12 | }); | 14 | }); |
13 | 15 | ||
14 | casper.withFrame('frame2', function() { | 16 | casper.withFrame('frame2', function() { |
... | @@ -37,5 +39,5 @@ casper.withFrame(1, function() { | ... | @@ -37,5 +39,5 @@ casper.withFrame(1, function() { |
37 | 39 | ||
38 | casper.run(function() { | 40 | casper.run(function() { |
39 | this.test.assertTitle('CasperJS test frames'); | 41 | this.test.assertTitle('CasperJS test frames'); |
40 | this.test.done(14); | 42 | this.test.done(16); |
41 | }); | 43 | }); | ... | ... |
-
Please register or sign in to post a comment