Advertisement
kidig

nodejs-selenium-yandexru-testcase

Jul 14th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var wd = require('wd'),
  2.     assert = require('assert'),
  3.     colors = require('colors'),
  4.     browser = wd.promiseRemote();
  5.    
  6. browser.on('status', function(info) {
  7.     console.log(info.cyan);
  8. });
  9.  
  10. browser.on('command', function(meth, path, data) {
  11.     console.log(' > ' + meth.yellow, path.grey, data || '');
  12. });
  13.  
  14. browser.init({
  15.     browserName: 'chrome',
  16.     tags: ["examples"],
  17.     name: "This is an example test"
  18. }).then(function() {
  19.     return browser.get('http://yandex.ru');
  20. }).then(function() {
  21.     return browser.title();
  22. }).then(function(title) {
  23.     assert.ok(~title.indexOf("Яндекс"), 'Wrong title!');
  24.     return browser.elementById('text');
  25. }).then(function(el) {
  26.     el.type("новосибирск");
  27.     return browser.elementByCssSelector('form.b-morda-search-form input[type="submit"]');
  28. }).then(function(el) {
  29.     return browser.clickElement(el);
  30. }).then(function(err) {
  31.     browser.title(function(err, title) {
  32.         console.log(title);
  33.     });
  34. }).fin(function() {
  35.     browser.quit();
  36. }).done();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement