Last active
October 20, 2015 13:03
-
-
Save just-boris/c4c23475f92e943d2037 to your computer and use it in GitHub Desktop.
JSUnderhood webdirver.io PageObject
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
"use strict"; | |
function SearchBox(selector) { | |
this.selector = selector || ".search2"; | |
this.input = this.selector + " [name=text]"; | |
this.submitButton = this.selector + " [type=submit]"; | |
} | |
module.exports = new SearchBox(); |
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
"use strict"; | |
var webdriverio = require("webdriverio"); | |
var config = require("../config"); | |
var searchPage = require("../pages/search-page"); | |
describe("webdriverio spec", function() { | |
beforeEach(function() { | |
this.webdriver = webdriverio.remote({ | |
desiredCapabilities: config.capabilities, | |
host: config.seleniumHost | |
}); | |
this.setQuery = (query) => { | |
return this.webdriver.setValue(searchPage.input, query); | |
}); | |
return this.webdriver.init().url(config.testHost); | |
}); | |
it("should open page", function() { | |
return webdriver.waitForVisible(searchPage.input); | |
}); | |
it("should show suggest", function() { | |
return this.setQuery("an elephant").waitForVisible(mainPage.suggest.selector, 3000); | |
}); | |
it("should open search result page", function() { | |
return setQuery("allure-framework").click(searchPage.submitButton) | |
.waitUntil(function() { | |
return this.getTitle().then(function(title) { | |
return title.indexOf("an elephant") === 0; | |
}); | |
}, 3000); | |
}); | |
afterEach(function() { | |
return this.webdriver.end(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment