Skip to content

Instantly share code, notes, and snippets.

@kidig kidig/nodejs-wd-sample.js
Last active Dec 19, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.