##// END OF EJS Templates
Fixing casperjs tests to run on casperjs 1.0.x.
Brian E. Granger -
Show More
@@ -1,7 +1,4 b''
1 casper.wait_for_list = function () {
1
2 casper.waitForSelector('.list_item');
3 // casper.wait(500);
4 }
5
2
6 casper.get_list_items = function () {
3 casper.get_list_items = function () {
7 return this.evaluate(function () {
4 return this.evaluate(function () {
@@ -14,7 +11,7 b' casper.get_list_items = function () {'
14 });
11 });
15 }
12 }
16
13
17 casper.test_items = function (test, baseUrl) {
14 casper.test_items = function (baseUrl) {
18 casper.then(function () {
15 casper.then(function () {
19 var items = casper.get_list_items();
16 var items = casper.get_list_items();
20 casper.each(items, function (self, item) {
17 casper.each(items, function (self, item) {
@@ -22,9 +19,9 b' casper.test_items = function (test, baseUrl) {'
22 var followed_url = baseUrl+item.link;
19 var followed_url = baseUrl+item.link;
23 if (!followed_url.match('/\.\.$')) {
20 if (!followed_url.match('/\.\.$')) {
24 casper.thenOpen(baseUrl+item.link, function () {
21 casper.thenOpen(baseUrl+item.link, function () {
25 casper.wait_for_list();
22 casper.wait_for_dashboard();
26 test.assertEquals(this.getCurrentUrl(), followed_url, 'Testing dashboard link: '+followed_url);
23 this.test.assertEquals(this.getCurrentUrl(), followed_url, 'Testing dashboard link: '+followed_url);
27 casper.test_items(test, baseUrl);
24 casper.test_items(baseUrl);
28 this.back();
25 this.back();
29 });
26 });
30 }
27 }
@@ -33,13 +30,8 b' casper.test_items = function (test, baseUrl) {'
33 });
30 });
34 }
31 }
35
32
36 casper.test.begin('Testing dashboard navigation', function (test) {
33 casper.dashboard_test(function () {
37 var baseUrl = casper.get_notebook_server();
34 baseUrl = this.get_notebook_server()
38 casper.start(baseUrl);
35 casper.test_items(baseUrl);
39 casper.echo(baseUrl);
36 })
40 casper.wait_for_list();
37
41 casper.test_items(test, baseUrl);
42 casper.run(function() {
43 test.done();
44 });
45 });
@@ -250,6 +250,34 b' casper.notebook_test = function(test) {'
250 });
250 });
251 };
251 };
252
252
253 casper.wait_for_dashboard = function () {
254 // Wait for the dashboard list to load.
255 casper.waitForSelector('.list_item');
256 }
257
258 casper.open_dashboard = function () {
259 // Start casper by opening the dashboard page.
260 var baseUrl = this.get_notebook_server();
261 this.start(baseUrl);
262 this.wait_for_dashboard();
263 }
264
265 casper.dashboard_test = function (test) {
266 // Open the dashboard page and run a test.
267 this.open_dashboard();
268 this.then(test);
269
270 this.then(function () {
271 this.page.close();
272 this.page = null;
273 });
274
275 // Run the browser automation.
276 this.run(function() {
277 this.test.done();
278 });
279 }
280
253 casper.options.waitTimeout=10000
281 casper.options.waitTimeout=10000
254 casper.on('waitFor.timeout', function onWaitForTimeout(timeout) {
282 casper.on('waitFor.timeout', function onWaitForTimeout(timeout) {
255 this.echo("Timeout for " + casper.get_notebook_server());
283 this.echo("Timeout for " + casper.get_notebook_server());
General Comments 0
You need to be logged in to leave comments. Login now