Created
December 16, 2014 22:20
-
-
Save pa-s/82ea0d486f95ddd50764 to your computer and use it in GitHub Desktop.
Hodman Article - hodmanWorld.js
This file contains hidden or 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 cabbie = require('cabbie'); | |
var hodman = require('hodman'); | |
var assert = require('assert'); | |
var driver = cabbie('http://localhost:4444/wd/hub', | |
{ browserName:'firefox' }, | |
{ mode: 'sync' }); | |
var driverAdapter = new hodman.driverAdapters.Cabbie(driver); | |
hodman.BaseObject.DRIVER_ADAPTER = driverAdapter; | |
var GooglePage = hodman.PageObject.extend( | |
{ | |
initialize: function () { | |
this.__super(); | |
this.setSelectors({ | |
"searchInput": ".gbqfif", | |
"searchButton": ".gbqfb", | |
"firstResult": "._Rm" | |
}); | |
this.addLoadSelectors(["searchInput"]); | |
}, | |
performSearch: function (searchTerm) { | |
this.setSearchTerm(searchTerm); | |
this.getElement('searchButton').mouse().click(); | |
this.waitForElements(['firstResult'], 4000); | |
return this; | |
}, | |
setSearchTerm: function (searchTerm) { | |
this.clearSearchInput(); | |
this.getElement('searchInput').sendKeys(searchTerm); | |
return this; | |
}, | |
clearSearchInput: function () { | |
this.getElement('searchInput').clear(); | |
return this; | |
} | |
}, | |
{ | |
BASE: "http://www.google.de", | |
URL: "/", | |
EXPECTED_URL: "www.google.de" | |
} | |
) | |
/* | |
* Teste básico | |
* Acesse a página do Google, | |
* procure por Yahoo Hodman, | |
* e verifique que o primeiro resultado | |
* é o link para o repositório do projeto. | |
*/ | |
var googlePage = GooglePage.navigate(3000); | |
googlePage.performSearch('Yahoo Hodman'); | |
assert.equal(googlePage.getElement('firstResult').getText(), | |
'https://github.com/yahoo/hodman', | |
'Could not find hodman link'); | |
driver.dispose(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment