Last active
December 19, 2015 19:29
-
-
Save kidig/6006623 to your computer and use it in GitHub Desktop.
This is a sample of using node.js, selenium wd for testing search at yandex.ru
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wd = require('wd'), | |
assert = require('assert'), | |
colors = require('colors'), | |
browser = wd.promiseRemote(); | |
browser.on('status', function(info) { | |
console.log(info.cyan); | |
}); | |
browser.on('command', function(meth, path, data) { | |
console.log(' > ' + meth.yellow, path.grey, data || ''); | |
}); | |
browser.init({ | |
browserName: 'chrome', | |
tags: ["examples", "yandex"], | |
name: "This is a test for yandex search" | |
}).then(function() { | |
return browser.get('http://yandex.com'); | |
}).then(function() { | |
return browser.title(); | |
}).then(function(title) { | |
assert.ok(~title.indexOf("Yandex"), 'Wrong title!'); | |
return browser.elementById('searchInput'); | |
}).then(function(el) { | |
el.type("moscow city"); | |
return browser.elementByCssSelector('form .b-search__table .b-search__button'); | |
}).then(function(el) { | |
return browser.clickElement(el); | |
}).then(function(err) { | |
browser.title(function(err, title) { | |
console.log(title); | |
}); | |
}).fin(function() { | |
browser.quit(); | |
}).done(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment