Skip to content

Instantly share code, notes, and snippets.

@kidig
Last active December 19, 2015 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kidig/6006623 to your computer and use it in GitHub Desktop.
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
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