Skip to content

Instantly share code, notes, and snippets.

@just-boris just-boris/search-page.js
Last active Oct 20, 2015

Embed
What would you like to do?
JSUnderhood webdirver.io PageObject
"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();
"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
You can’t perform that action at this time.