Commit 68a80b31 68a80b3114e8a199f8fe20d5a3f1283ba8571307 by Nicolas Perriault

fixed google search form selector in samples

1 parent 09669077
...@@ -7,13 +7,13 @@ casper = require('casper').create() ...@@ -7,13 +7,13 @@ casper = require('casper').create()
7 7
8 casper.start "http://google.fr/", -> 8 casper.start "http://google.fr/", ->
9 # search for 'casperjs' from google form 9 # search for 'casperjs' from google form
10 @fill "form[name=f]", q: "casperjs", true 10 @fill 'form[action="/search"]', q: "casperjs", true
11 11
12 casper.then -> 12 casper.then ->
13 # aggregate results for the 'casperjs' search 13 # aggregate results for the 'casperjs' search
14 links = @evaluate getLinks 14 links = @evaluate getLinks
15 # search for 'phantomjs' from google form 15 # search for 'phantomjs' from google form
16 @fill "form[name=f]", q: "phantomjs", true 16 @fill 'form[action="/search"]', q: "phantomjs", true
17 17
18 casper.then -> 18 casper.then ->
19 # concat results for the 'phantomjs' search 19 # concat results for the 'phantomjs' search
......
...@@ -10,14 +10,14 @@ function getLinks() { ...@@ -10,14 +10,14 @@ function getLinks() {
10 10
11 casper.start('http://google.fr/', function(self) { 11 casper.start('http://google.fr/', function(self) {
12 // search for 'casperjs' from google form 12 // search for 'casperjs' from google form
13 self.fill('form[name=f]', { q: 'casperjs' }, true); 13 self.fill('form[action="/search"]', { q: 'casperjs' }, true);
14 }); 14 });
15 15
16 casper.then(function(self) { 16 casper.then(function(self) {
17 // aggregate results for the 'casperjs' search 17 // aggregate results for the 'casperjs' search
18 links = self.evaluate(getLinks); 18 links = self.evaluate(getLinks);
19 // now search for 'phantomjs' by fillin the form again 19 // now search for 'phantomjs' by fillin the form again
20 self.fill('form[name=f]', { q: 'phantomjs' }, true); 20 self.fill('form[action="/search"]', { q: 'phantomjs' }, true);
21 }); 21 });
22 22
23 casper.then(function(self) { 23 casper.then(function(self) {
......
...@@ -30,7 +30,7 @@ casper.echo "Let the match begin between \"#{terms.join '", "'}\"!" ...@@ -30,7 +30,7 @@ casper.echo "Let the match begin between \"#{terms.join '", "'}\"!"
30 casper.start "http://google.fr/" 30 casper.start "http://google.fr/"
31 31
32 casper.each terms, (self, term) -> 32 casper.each terms, (self, term) ->
33 @then -> @fill 'form[name=f]', { q: term }, true 33 @then -> @fill 'form[action="/search"]', { q: term }, true
34 @then -> 34 @then ->
35 score = @fetchScore() 35 score = @fetchScore()
36 scores.push term: term, score: score 36 scores.push term: term, score: score
......
...@@ -2,8 +2,8 @@ casper = require('casper').create logLevel: "debug" ...@@ -2,8 +2,8 @@ casper = require('casper').create logLevel: "debug"
2 2
3 casper.start 'http://www.google.fr/', -> 3 casper.start 'http://www.google.fr/', ->
4 @test.assertTitle 'Google', 'google homepage title is the one expected' 4 @test.assertTitle 'Google', 'google homepage title is the one expected'
5 @test.assertExists 'form[name=f]', 'main form is found' 5 @test.assertExists 'form[action="/search"]', 'main form is found'
6 @fill 'form[name=f]', q: 'foo', true 6 @fill 'form[action="/search"]', q: 'foo', true
7 7
8 casper.then -> 8 casper.then ->
9 @test.assertTitle 'foo - Recherche Google', 'google title is ok' 9 @test.assertTitle 'foo - Recherche Google', 'google title is ok'
......
...@@ -4,8 +4,8 @@ var casper = require('casper').create({ ...@@ -4,8 +4,8 @@ var casper = require('casper').create({
4 4
5 casper.start('http://www.google.fr/', function(self) { 5 casper.start('http://www.google.fr/', function(self) {
6 self.test.assertTitle('Google', 'google homepage title is the one expected'); 6 self.test.assertTitle('Google', 'google homepage title is the one expected');
7 self.test.assertExists('form[name=f]', 'main form is found'); 7 self.test.assertExists('form[action="/search"]', 'main form is found');
8 self.fill('form[name=f]', { 8 self.fill('form[action="/search"]', {
9 q: 'foo' 9 q: 'foo'
10 }, true); 10 }, true);
11 }); 11 });
......