Convert all page objects to be ES6 classes and rely on PageObjects module instead of support.

This commit is contained in:
CJ Cenizal 2016-06-27 17:22:47 -07:00
parent 0f397f2bc4
commit 91e919d1c5
8 changed files with 1317 additions and 1349 deletions

View file

@ -1,3 +1,4 @@
import bluebird, { import bluebird, {
promisify promisify
} from 'bluebird'; } from 'bluebird';

View file

@ -1,71 +1,62 @@
import { remote, defaultFindTimeout } from '../';
// in test/support/pages/shield_page.js import {
export default (function (require) { defaultFindTimeout,
// the page object is created as a constructor } from '../';
// so we can provide the remote Command object
// at runtime
var thisTime;
function ConsolePage() { export default class ConsolePage {
constructor() {
} }
ConsolePage.prototype = { init(remote) {
constructor: ConsolePage, this.remote = remote;
this.findTimeout = this.remote.setFindTimeout(defaultFindTimeout);
}
init(remote) { getServer() {
this.remote = remote; return this.findTimeout
thisTime = this.remote.setFindTimeout(defaultFindTimeout); .findByCssSelector('#kibana-body > div.content > div > div')
}, .getVisibleText();
}
getServer: function getServer() { setServer(server) {
return thisTime return this.findTimeout
.findByCssSelector('#kibana-body > div.content > div > div') .findByCssSelector('input[aria-label="Server Name"]')
.getVisibleText(); .clearValue()
}, .type(server);
}
setServer: function setServer(server) { getRequest() {
return thisTime return this.findTimeout
.findByCssSelector('input[aria-label="Server Name"]') .findAllByCssSelector('div.ace_line_group')
.clearValue() .then(function (editorData) {
.type(server);
},
getRequest: function getRequest() { function getEditorData(line) {
return thisTime return line.getVisibleText();
.findAllByCssSelector('div.ace_line_group') }
.then(function (editorData) {
function getEditorData(line) { var getEditorDataPromises = editorData.map(getEditorData);
return line.getVisibleText(); return Promise.all(getEditorDataPromises);
} });
}
var getEditorDataPromises = editorData.map(getEditorData); getResponse() {
return Promise.all(getEditorDataPromises); return this.findTimeout
}); .findByCssSelector('#output > div.ace_scroller > div')
}, .getVisibleText();
}
getResponse: function getResponse() { clickPlay() {
return thisTime return this.findTimeout
.findByCssSelector('#output > div.ace_scroller > div') .findByCssSelector('#editor_actions > span.ng-scope > a > i')
.getVisibleText(); .click();
}, }
clickPlay: function clickPlay() { collapseHelp() {
return thisTime return this.findTimeout
.findByCssSelector('#editor_actions > span.ng-scope > a > i') .findByCssSelector('div.config-close.remove > i')
.click(); .click();
},
collapseHelp: function collapseHelp() { }
return thisTime
.findByCssSelector('div.config-close.remove > i')
.click();
} }
};
return ConsolePage;
}());

View file

@ -1,227 +1,222 @@
import { remote, common, defaultFindTimeout, headerPage } from '../';
export default (function () { import {
var thisTime; defaultFindTimeout,
} from '../';
function DashboardPage() { import PageObjects from './';
export default class DashboardPage {
constructor() {
} }
DashboardPage.prototype = { init(remote) {
constructor: DashboardPage, this.remote = remote;
this.findTimeout = this.remote.setFindTimeout(defaultFindTimeout);
}
init(remote) { clickNewDashboard() {
this.remote = remote; return this.findTimeout
thisTime = this.remote.setFindTimeout(defaultFindTimeout); .findByCssSelector('button.ng-scope[aria-label="New Dashboard"]')
}, .click();
}
clickNewDashboard: function clickNewDashboard() { clickAddVisualization() {
return thisTime return this.findTimeout
.findByCssSelector('button.ng-scope[aria-label="New Dashboard"]') .findByCssSelector('button.ng-scope[aria-label="Add a panel to the dashboard"]')
.click(); .click();
}, }
clickAddVisualization: function clickAddVisualization() { filterVizNames(vizName) {
return thisTime return this.findTimeout
.findByCssSelector('button.ng-scope[aria-label="Add a panel to the dashboard"]') .findByCssSelector('input[placeholder="Visualizations Filter..."]')
.click(); .click()
}, .pressKeys(vizName);
}
filterVizNames: function filterVizNames(vizName) { clickVizNameLink(vizName) {
return thisTime return this.findTimeout
.findByCssSelector('input[placeholder="Visualizations Filter..."]') .findByLinkText(vizName)
.click();
}
closeAddVizualizationPanel() {
PageObjects.common.debug('-------------close panel');
return this.findTimeout
.findByCssSelector('i.fa fa-chevron-up')
.click();
}
addVisualization(vizName) {
return this.clickAddVisualization()
.then(() => {
PageObjects.common.debug('filter visualization (' + vizName + ')');
return this.filterVizNames(vizName);
})
// this second wait is usually enough to avoid the
// 'stale element reference: element is not attached to the page document'
// on the next step
.then(() => {
return PageObjects.common.sleep(1000);
})
.then(() => {
// but wrap in a try loop since it can still happen
return PageObjects.common.try(() => {
PageObjects.common.debug('click visualization (' + vizName + ')');
return this.clickVizNameLink(vizName);
});
})
// this second click of 'Add' collapses the Add Visualization pane
.then(() => {
return this.clickAddVisualization();
});
}
saveDashboard(dashName) {
return this.findTimeout
.findByCssSelector('button.ng-scope[aria-label="Save Dashboard"]')
.click()
.then(() => {
return PageObjects.header.getSpinnerDone();
})
.then(() => {
return PageObjects.common.sleep(1000);
})
.then(() => {
PageObjects.common.debug('saveButton button clicked');
return this.findTimeout
.findById('dashboardTitle')
.type(dashName);
})
.then(() => {
return PageObjects.header.getSpinnerDone();
})
.then(() => {
return PageObjects.common.sleep(1000);
})
// click save button
.then(() => {
return PageObjects.common.try(() => {
PageObjects.common.debug('clicking final Save button for named dashboard');
return this.findTimeout
.findByCssSelector('.btn-primary')
.click();
});
})
.then(() => {
return PageObjects.header.getSpinnerDone();
})
// verify that green message at the top of the page.
// it's only there for about 5 seconds
.then(() => {
return PageObjects.common.try(() => {
PageObjects.common.debug('verify toast-message for saved dashboard');
return this.findTimeout
.findByCssSelector('kbn-truncated.toast-message.ng-isolate-scope')
.getVisibleText();
});
});
}
clickDashboardByLinkText(dashName) {
return this.findTimeout
.findByLinkText(dashName)
.click();
}
// use the search filter box to narrow the results down to a single
// entry, or at least to a single page of results
loadSavedDashboard(dashName) {
var self = this;
return this.findTimeout
.findByCssSelector('button.ng-scope[aria-label="Load Saved Dashboard"]')
.click()
.then(function filterDashboard() {
PageObjects.common.debug('Load Saved Dashboard button clicked');
return self.remote
.findByCssSelector('input[name="filter"]')
.click() .click()
.pressKeys(vizName); .type(dashName.replace('-',' '));
}, })
.then(() => {
return PageObjects.header.getSpinnerDone();
})
.then(() => {
return PageObjects.common.sleep(1000);
})
.then(function clickDashboardByLinkedText() {
return self
.clickDashboardByLinkText(dashName);
})
.then(() => {
return PageObjects.header.getSpinnerDone();
});
}
clickVizNameLink: function clickVizNameLink(vizName) { getPanelTitles() {
return thisTime PageObjects.common.debug('in getPanelTitles');
.findByLinkText(vizName) return this.findTimeout
.click(); .findAllByCssSelector('span.panel-title')
}, .then(function (titleObjects) {
closeAddVizualizationPanel: function closeAddVizualizationPanel() { function getTitles(chart) {
common.debug('-------------close panel'); return chart.getAttribute('title');
return thisTime }
.findByCssSelector('i.fa fa-chevron-up')
.click();
},
addVisualization: function addVisualization(vizName) { var getTitlePromises = titleObjects.map(getTitles);
var self = this; return Promise.all(getTitlePromises);
return this.clickAddVisualization() });
.then(function () { }
common.debug('filter visualization (' + vizName + ')');
return self.filterVizNames(vizName);
})
// this second wait is usually enough to avoid the
// 'stale element reference: element is not attached to the page document'
// on the next step
.then(function () {
return common.sleep(1000);
})
.then(function () {
// but wrap in a try loop since it can still happen
return common.try(function () {
common.debug('click visualization (' + vizName + ')');
return self.clickVizNameLink(vizName);
});
})
// this second click of 'Add' collapses the Add Visualization pane
.then(function () {
return self.clickAddVisualization();
});
},
saveDashboard: function saveDashboard(dashName) { getPanelData() {
var self = this; PageObjects.common.debug('in getPanelData');
return thisTime return this.findTimeout
.findByCssSelector('button.ng-scope[aria-label="Save Dashboard"]') .findAllByCssSelector('li.gs-w')
.click() .then(function (titleObjects) {
.then(function () {
return headerPage.getSpinnerDone();
})
.then(function () {
return common.sleep(1000);
})
.then(function () {
common.debug('saveButton button clicked');
return thisTime
.findById('dashboardTitle')
.type(dashName);
})
.then(function () {
return headerPage.getSpinnerDone();
})
.then(function () {
return common.sleep(1000);
})
// click save button
.then(function () {
return common.try(function () {
common.debug('clicking final Save button for named dashboard');
return thisTime
.findByCssSelector('.btn-primary')
.click();
});
})
.then(function () {
return headerPage.getSpinnerDone();
})
// verify that green message at the top of the page.
// it's only there for about 5 seconds
.then(function () {
return common.try(function () {
common.debug('verify toast-message for saved dashboard');
return thisTime
.findByCssSelector('kbn-truncated.toast-message.ng-isolate-scope')
.getVisibleText();
});
});
},
clickDashboardByLinkText: function clickDashboardByLinkText(dashName) { function getTitles(chart) {
return thisTime var obj = {};
.findByLinkText(dashName) return chart.getAttribute('data-col')
.click(); .then(theData => {
}, obj = {dataCol:theData};
return chart;
// use the search filter box to narrow the results down to a single })
// entry, or at least to a single page of results .then(chart => {
loadSavedDashboard: function loadSavedDashboard(dashName) { return chart.getAttribute('data-row')
var self = this; .then(theData => {
return thisTime obj.dataRow = theData;
.findByCssSelector('button.ng-scope[aria-label="Load Saved Dashboard"]')
.click()
.then(function filterDashboard() {
common.debug('Load Saved Dashboard button clicked');
return self.remote
.findByCssSelector('input[name="filter"]')
.click()
.type(dashName.replace('-',' '));
})
.then(function () {
return headerPage.getSpinnerDone();
})
.then(function () {
return common.sleep(1000);
})
.then(function clickDashboardByLinkedText() {
return self
.clickDashboardByLinkText(dashName);
})
.then(function () {
return headerPage.getSpinnerDone();
});
},
getPanelTitles: function getPanelTitles() {
common.debug('in getPanelTitles');
return thisTime
.findAllByCssSelector('span.panel-title')
.then(function (titleObjects) {
function getTitles(chart) {
return chart.getAttribute('title');
}
var getTitlePromises = titleObjects.map(getTitles);
return Promise.all(getTitlePromises);
});
},
getPanelData: function getPanelData() {
common.debug('in getPanelData');
return thisTime
.findAllByCssSelector('li.gs-w')
.then(function (titleObjects) {
function getTitles(chart) {
var obj = {};
return chart.getAttribute('data-col')
.then(function (theData) {
obj = {dataCol:theData};
return chart; return chart;
})
.then(function (chart) {
return chart.getAttribute('data-row')
.then(function (theData) {
obj.dataRow = theData;
return chart;
});
})
.then(function (chart) {
return chart.getAttribute('data-sizex')
.then(function (theData) {
obj.dataSizeX = theData;
return chart;
});
})
.then(function (chart) {
return chart.getAttribute('data-sizey')
.then(function (theData) {
obj.dataSizeY = theData;
return chart;
});
})
.then(function (chart) {
return chart.findByCssSelector('span.panel-title')
.then(function (titleElement) {
return titleElement.getAttribute('title');
})
.then(function (theData) {
obj.title = theData;
return obj;
});
}); });
} })
.then(chart => {
return chart.getAttribute('data-sizex')
.then(theData => {
obj.dataSizeX = theData;
return chart;
});
})
.then(chart => {
return chart.getAttribute('data-sizey')
.then(theData => {
obj.dataSizeY = theData;
return chart;
});
})
.then(chart => {
return chart.findByCssSelector('span.panel-title')
.then(function (titleElement) {
return titleElement.getAttribute('title');
})
.then(theData => {
obj.title = theData;
return obj;
});
});
}
var getTitlePromises = titleObjects.map(getTitles); var getTitlePromises = titleObjects.map(getTitles);
return Promise.all(getTitlePromises); return Promise.all(getTitlePromises);
}); });
} }
}; }
return DashboardPage;
}());

View file

@ -1,38 +1,38 @@
import Common from './common.js'; import {
import { defaultFindTimeout } from '../'; defaultFindTimeout
} from '../';
let thisTime; import PageObjects from './';
export default class DiscoverPage extends Common { export default class DiscoverPage {
constructor() { constructor() {
super();
} }
init(remote) { init(remote) {
super.init(remote); this.remote = remote;
thisTime = this.remote.setFindTimeout(defaultFindTimeout); this.findTimeout = this.remote.setFindTimeout(defaultFindTimeout);
} }
getQueryField() { getQueryField() {
return thisTime return this.findTimeout
.findByCssSelector('input[ng-model=\'state.query\']'); .findByCssSelector('input[ng-model=\'state.query\']');
} }
getQuerySearchButton() { getQuerySearchButton() {
return thisTime return this.findTimeout
.findByCssSelector('button[aria-label=\'Search\']'); .findByCssSelector('button[aria-label=\'Search\']');
} }
getTimespanText() { getTimespanText() {
return thisTime return this.findTimeout
.findByCssSelector('.kibana-nav-options .navbar-timepicker-time-desc pretty-duration') .findByCssSelector('.kibana-nav-options .navbar-timepicker-time-desc pretty-duration')
.getVisibleText(); .getVisibleText();
} }
getChartTimespan() { getChartTimespan() {
return thisTime return this.findTimeout
.findByCssSelector('center.small > span:nth-child(1)') .findByCssSelector('center.small > span:nth-child(1)')
.getVisibleText(); .getVisibleText();
} }
@ -40,50 +40,49 @@ export default class DiscoverPage extends Common {
saveSearch(searchName) { saveSearch(searchName) {
return this.clickSaveSearchButton() return this.clickSaveSearchButton()
.then(() => { .then(() => {
this.debug('--saveSearch button clicked'); PageObjects.common.debug('--saveSearch button clicked');
return thisTime.findDisplayedById('SaveSearch') return this.findTimeout.findDisplayedById('SaveSearch')
.pressKeys(searchName); .pressKeys(searchName);
}) })
.then(() => { .then(() => {
this.debug('--find save button'); PageObjects.common.debug('--find save button');
return this.findTestSubject('discover-save-search-btn').click(); return PageObjects.common.findTestSubject('discover-save-search-btn').click();
}); });
} }
loadSavedSearch(searchName) { loadSavedSearch(searchName) {
var self = this; return this.clickLoadSavedSearchButton()
return self.clickLoadSavedSearchButton() .then(() => {
.then(function () { this.findTimeout.findByLinkText(searchName).click();
thisTime.findByLinkText(searchName).click();
}); });
} }
clickNewSearchButton() { clickNewSearchButton() {
return thisTime return this.findTimeout
.findByCssSelector('button[aria-label="New Search"]') .findByCssSelector('button[aria-label="New Search"]')
.click(); .click();
} }
clickSaveSearchButton() { clickSaveSearchButton() {
return thisTime return this.findTimeout
.findByCssSelector('button[aria-label="Save Search"]') .findByCssSelector('button[aria-label="Save Search"]')
.click(); .click();
} }
clickLoadSavedSearchButton() { clickLoadSavedSearchButton() {
return thisTime return this.findTimeout
.findDisplayedByCssSelector('button[aria-label="Load Saved Search"]') .findDisplayedByCssSelector('button[aria-label="Load Saved Search"]')
.click(); .click();
} }
getCurrentQueryName() { getCurrentQueryName() {
return thisTime return this.findTimeout
.findByCssSelector('span.kibana-nav-info-title span') .findByCssSelector('span.kibana-nav-info-title span')
.getVisibleText(); .getVisibleText();
} }
getBarChartData() { getBarChartData() {
return thisTime return this.findTimeout
.findAllByCssSelector('rect[data-label="Count"]') .findAllByCssSelector('rect[data-label="Count"]')
.then(function (chartData) { .then(function (chartData) {
@ -101,18 +100,18 @@ export default class DiscoverPage extends Common {
} }
getChartInterval() { getChartInterval() {
return thisTime return this.findTimeout
.findByCssSelector('a[ng-click="toggleInterval()"]') .findByCssSelector('a[ng-click="toggleInterval()"]')
.getVisibleText() .getVisibleText()
.then(function (intervalText) { .then(intervalText => {
if (intervalText.length > 0) { if (intervalText.length > 0) {
return intervalText; return intervalText;
} else { } else {
return thisTime return this.findTimeout
.findByCssSelector('select[ng-model="state.interval"]') .findByCssSelector('select[ng-model="state.interval"]')
.getProperty('value') // this gets 'string:d' for Daily .getProperty('value') // this gets 'string:d' for Daily
.then(function (selectedValue) { .then(selectedValue => {
return thisTime return this.findTimeout
.findByCssSelector('option[value="' + selectedValue + '"]') .findByCssSelector('option[value="' + selectedValue + '"]')
.getVisibleText(); .getVisibleText();
}); });
@ -124,121 +123,120 @@ export default class DiscoverPage extends Common {
return this.remote.setFindTimeout(5000) return this.remote.setFindTimeout(5000)
.findByCssSelector('a[ng-click="toggleInterval()"]') .findByCssSelector('a[ng-click="toggleInterval()"]')
.click() .click()
.catch(function () { .catch(() => {
// in some cases we have the link above, but after we've made a // in some cases we have the link above, but after we've made a
// selection we just have a select list. // selection we just have a select list.
}) })
.then(function () { .then(() => {
return thisTime return this.findTimeout
.findByCssSelector('option[label="' + interval + '"]') .findByCssSelector('option[label="' + interval + '"]')
.click(); .click();
}); });
} }
getHitCount() { getHitCount() {
return thisTime return this.findTimeout
.findByCssSelector('strong.discover-info-hits') .findByCssSelector('strong.discover-info-hits')
.getVisibleText(); .getVisibleText();
} }
query(queryString) { query(queryString) {
return thisTime return this.findTimeout
.findByCssSelector('input[aria-label="Search input"]') .findByCssSelector('input[aria-label="Search input"]')
.clearValue() .clearValue()
.type(queryString) .type(queryString)
.then(function () { .then(() => {
return thisTime return this.findTimeout
.findByCssSelector('button[aria-label="Search"]') .findByCssSelector('button[aria-label="Search"]')
.click(); .click();
}); });
} }
getDocHeader() { getDocHeader() {
return thisTime return this.findTimeout
.findByCssSelector('thead.ng-isolate-scope > tr:nth-child(1)') .findByCssSelector('thead.ng-isolate-scope > tr:nth-child(1)')
.getVisibleText(); .getVisibleText();
} }
getDocTableIndex(index) { getDocTableIndex(index) {
return thisTime return this.findTimeout
.findByCssSelector('tr.discover-table-row:nth-child(' + (index) + ')') .findByCssSelector('tr.discover-table-row:nth-child(' + (index) + ')')
.getVisibleText(); .getVisibleText();
} }
clickDocSortDown() { clickDocSortDown() {
return thisTime return this.findTimeout
.findByCssSelector('.fa-sort-down') .findByCssSelector('.fa-sort-down')
.click(); .click();
} }
clickDocSortUp() { clickDocSortUp() {
return thisTime return this.findTimeout
.findByCssSelector('.fa-sort-up') .findByCssSelector('.fa-sort-up')
.click(); .click();
} }
getMarks() { getMarks() {
return thisTime return this.findTimeout
.findAllByCssSelector('mark') .findAllByCssSelector('mark')
.getVisibleText(); .getVisibleText();
} }
clickShare() { clickShare() {
return thisTime return this.findTimeout
.findByCssSelector('button[aria-label="Share Search"]') .findByCssSelector('button[aria-label="Share Search"]')
.click(); .click();
} }
clickShortenUrl() { clickShortenUrl() {
return thisTime return this.findTimeout
.findByCssSelector('button.shorten-button') .findByCssSelector('button.shorten-button')
.click(); .click();
} }
clickCopyToClipboard() { clickCopyToClipboard() {
return thisTime return this.findTimeout
.findDisplayedByCssSelector('button.clipboard-button') .findDisplayedByCssSelector('button.clipboard-button')
.click(); .click();
} }
getShareCaption() { getShareCaption() {
return thisTime return this.findTimeout
.findByCssSelector('.vis-share label') .findByCssSelector('.vis-share label')
.getVisibleText(); .getVisibleText();
} }
getSharedUrl() { getSharedUrl() {
return thisTime return this.findTimeout
.findByCssSelector('.url') .findByCssSelector('.url')
.getProperty('value'); .getProperty('value');
} }
getShortenedUrl() { getShortenedUrl() {
return thisTime return this.findTimeout
.findByCssSelector('.url') .findByCssSelector('.url')
.getProperty('value'); .getProperty('value');
} }
toggleSidebarCollapse() { toggleSidebarCollapse() {
return thisTime.findDisplayedByCssSelector('.sidebar-collapser .chevron-cont') return this.findTimeout.findDisplayedByCssSelector('.sidebar-collapser .chevron-cont')
.click(); .click();
} }
getSidebarWidth() { getSidebarWidth() {
return thisTime return this.findTimeout
.findByClassName('sidebar-list') .findByClassName('sidebar-list')
.getProperty('clientWidth'); .getProperty('clientWidth');
} }
hasNoResults() { hasNoResults() {
return this return PageObjects.common.findTestSubject('discoverNoResults')
.findTestSubject('discoverNoResults')
.then(() => true) .then(() => true)
.catch(() => false); .catch(() => false);
} }
getNoResultsTimepicker() { getNoResultsTimepicker() {
return this.findTestSubject('discoverNoResultsTimefilter'); return PageObjects.common.findTestSubject('discoverNoResultsTimefilter');
} }
hasNoResultsTimepicker() { hasNoResultsTimepicker() {

View file

@ -1,50 +1,50 @@
import Common from './common.js'; import {
import { defaultFindTimeout } from '../'; defaultFindTimeout
} from '../';
export default class HeaderPage extends Common { import PageObjects from './';
export default class HeaderPage {
constructor() { constructor() {
super();
} }
init(remote) { init(remote) {
super.init(remote); this.remote = remote;
} }
clickSelector(selector) { clickSelector(selector) {
var self = this; return this.try(() => {
return this.try(function () { return this.remote.setFindTimeout(defaultFindTimeout)
return self.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector(selector) .findByCssSelector(selector)
.then(function (tab) { .then(tab => {
return tab.click(); return tab.click();
}); });
}); });
} }
clickDiscover() { clickDiscover() {
this.debug('click Discover tab'); PageObjects.common.debug('click Discover tab');
this.clickSelector('a[href*=\'discover\']'); this.clickSelector('a[href*=\'discover\']');
} }
clickVisualize() { clickVisualize() {
this.debug('click Visualize tab'); PageObjects.common.debug('click Visualize tab');
this.clickSelector('a[href*=\'visualize\']'); this.clickSelector('a[href*=\'visualize\']');
} }
clickDashboard() { clickDashboard() {
this.debug('click Dashboard tab'); PageObjects.common.debug('click Dashboard tab');
this.clickSelector('a[href*=\'dashboard\']'); this.clickSelector('a[href*=\'dashboard\']');
} }
clickSettings() { clickSettings() {
this.debug('click Settings tab'); PageObjects.common.debug('click Settings tab');
this.clickSelector('a[href*=\'settings\']'); this.clickSelector('a[href*=\'settings\']');
} }
clickTimepicker() { clickTimepicker() {
var self = this;
return this.remote.setFindTimeout(defaultFindTimeout) return this.remote.setFindTimeout(defaultFindTimeout)
.findDisplayedByClassName('navbar-timepicker-time-desc').click(); .findDisplayedByClassName('navbar-timepicker-time-desc').click();
} }
@ -57,7 +57,6 @@ export default class HeaderPage extends Common {
} }
clickAbsoluteButton() { clickAbsoluteButton() {
var self = this;
return this.remote.setFindTimeout(defaultFindTimeout) return this.remote.setFindTimeout(defaultFindTimeout)
.findByLinkText('Absolute').click(); .findByLinkText('Absolute').click();
} }
@ -86,20 +85,19 @@ export default class HeaderPage extends Common {
}); });
} }
setAbsoluteRange(fromTime, toTime) { setAbsoluteRange(fromTime, toTime) {
this.debug('clickTimepicker'); PageObjects.common.debug('clickTimepicker');
return this.clickTimepicker() return this.clickTimepicker()
.then(() => { .then(() => {
this.debug('--Clicking Absolute button'); PageObjects.common.debug('--Clicking Absolute button');
return this.clickAbsoluteButton(); return this.clickAbsoluteButton();
}) })
.then(() => { .then(() => {
this.debug('--Setting From Time : ' + fromTime); PageObjects.common.debug('--Setting From Time : ' + fromTime);
return this.setFromTime(fromTime); return this.setFromTime(fromTime);
}) })
.then(() => { .then(() => {
this.debug('--Setting To Time : ' + toTime); PageObjects.common.debug('--Setting To Time : ' + toTime);
return this.setToTime(toTime); return this.setToTime(toTime);
}) })
.then(() => { .then(() => {
@ -114,7 +112,6 @@ export default class HeaderPage extends Common {
} }
collapseTimepicker() { collapseTimepicker() {
var self = this;
return this.remote.setFindTimeout(defaultFindTimeout) return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('.fa.fa-chevron-circle-up') .findByCssSelector('.fa.fa-chevron-circle-up')
.click(); .click();
@ -127,22 +124,18 @@ export default class HeaderPage extends Common {
} }
waitForToastMessageGone() { waitForToastMessageGone() {
var self = this; return this.remote.setFindTimeout(defaultFindTimeout)
return self.remote.setFindTimeout(defaultFindTimeout)
.waitForDeletedByCssSelector('kbn-truncated.toast-message'); .waitForDeletedByCssSelector('kbn-truncated.toast-message');
} }
clickToastOK() { clickToastOK() {
return this.remote return this.remote.setFindTimeout(defaultFindTimeout)
.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button[ng-if="notif.accept"]') .findByCssSelector('button[ng-if="notif.accept"]')
.click(); .click();
} }
getSpinnerDone() { getSpinnerDone() {
var self = this; return this.remote.setFindTimeout(defaultFindTimeout * 10)
return this.remote
.setFindTimeout(defaultFindTimeout * 10)
.findByCssSelector('.spinner.ng-hide'); .findByCssSelector('.spinner.ng-hide');
} }

View file

@ -1,387 +1,384 @@
import Bluebird from 'bluebird';
import { common, remote, defaultFindTimeout, headerPage } from '../';
export default (function () { import Bluebird from 'bluebird';
function SettingsPage() {
import {
defaultFindTimeout,
} from '../';
import PageObjects from './';
export default class SettingsPage {
constructor() {
} }
SettingsPage.prototype = { init(remote) {
constructor: SettingsPage, this.remote = remote;
}
init(remote) { clickNavigation() {
this.remote = remote; // TODO: find better way to target the element
}, return this.remote.findDisplayedByCssSelector('.app-link:nth-child(5) a').click();
}
clickNavigation: function () { clickLinkText(text) {
// TODO: find better way to target the element return this.remote.findDisplayedByLinkText(text).click();
return this.remote.findDisplayedByCssSelector('.app-link:nth-child(5) a').click(); }
},
clickLinkText: function (text) { clickKibanaSettings() {
return this.remote.findDisplayedByLinkText(text).click(); return this.clickLinkText('Advanced Settings');
}, }
clickKibanaSettings: function () { clickKibanaIndicies() {
return this.clickLinkText('Advanced Settings'); return this.clickLinkText('Index Patterns');
}, }
clickKibanaIndicies: function () { clickExistingData() {
return this.clickLinkText('Index Patterns'); return this.clickLinkText('Existing Data');
}, }
clickExistingData: function () { getAdvancedSettings(propertyName) {
return this.clickLinkText('Existing Data'); PageObjects.common.debug('in setAdvancedSettings');
}, return PageObjects.common.findTestSubject('advancedSetting&' + propertyName + ' currentValue')
.getVisibleText();
}
getAdvancedSettings: function getAdvancedSettings(propertyName) { setAdvancedSettings(propertyName, propertyValue) {
common.debug('in setAdvancedSettings'); var self = this;
return common.findTestSubject('advancedSetting&' + propertyName + ' currentValue')
.getVisibleText();
},
setAdvancedSettings: function setAdvancedSettings(propertyName, propertyValue) { return PageObjects.common.findTestSubject('advancedSetting&' + propertyName + ' editButton')
var self = this; .click()
.then(() => {
return PageObjects.header.getSpinnerDone();
})
.then(() => {
return PageObjects.common.sleep(1000);
})
.then(function setAdvancedSettingsClickPropertyValue(selectList) {
return self.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('option[label="' + propertyValue + '"]')
.click();
})
.then(() => {
return PageObjects.header.getSpinnerDone();
})
.then(function setAdvancedSettingsClickSaveButton() {
return PageObjects.common.findTestSubject('advancedSetting&' + propertyName + ' saveButton')
.click();
})
.then(() => {
return PageObjects.header.getSpinnerDone();
});
}
return common.findTestSubject('advancedSetting&' + propertyName + ' editButton') getAdvancedSettings(propertyName) {
.click() var self = this;
.then(function () { PageObjects.common.debug('in setAdvancedSettings');
return headerPage.getSpinnerDone(); return PageObjects.common.findTestSubject('advancedSetting&' + propertyName + ' currentValue')
}) .getVisibleText();
.then(function () { }
return common.sleep(1000);
})
.then(function setAdvancedSettingsClickPropertyValue(selectList) {
return self.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('option[label="' + propertyValue + '"]')
.click();
})
.then(function () {
return headerPage.getSpinnerDone();
})
.then(function setAdvancedSettingsClickSaveButton() {
return common.findTestSubject('advancedSetting&' + propertyName + ' saveButton')
.click();
})
.then(function () {
return headerPage.getSpinnerDone();
});
},
getAdvancedSettings: function getAdvancedSettings(propertyName) { navigateTo() {
var self = this; return PageObjects.common.navigateToApp('settings');
common.debug('in setAdvancedSettings'); }
return common.findTestSubject('advancedSetting&' + propertyName + ' currentValue')
.getVisibleText();
},
navigateTo: function () { getTimeBasedEventsCheckbox() {
return common.navigateToApp('settings'); return this.remote.setFindTimeout(defaultFindTimeout)
}, .findByCssSelector('input[ng-model="index.isTimeBased"]');
}
getTimeBasedEventsCheckbox: function () { getTimeBasedIndexPatternCheckbox(timeout) {
return this.remote.setFindTimeout(defaultFindTimeout) timeout = timeout || defaultFindTimeout;
.findByCssSelector('input[ng-model="index.isTimeBased"]'); // fail faster since we're sometimes checking that it doesn't exist
}, return this.remote.setFindTimeout(timeout)
.findByCssSelector('input[ng-model="index.nameIsPattern"]');
}
getTimeBasedIndexPatternCheckbox: function (timeout) { getIndexPatternField() {
timeout = timeout || defaultFindTimeout; return this.remote.setFindTimeout(defaultFindTimeout)
// fail faster since we're sometimes checking that it doesn't exist .findByCssSelector('[ng-model="index.name"]');
return this.remote.setFindTimeout(timeout) }
.findByCssSelector('input[ng-model="index.nameIsPattern"]');
},
getIndexPatternField: function () { getTimeFieldNameField() {
return this.remote.setFindTimeout(defaultFindTimeout) return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('[ng-model="index.name"]'); .findDisplayedByCssSelector('select[ng-model="index.timeField"]');
}, }
getTimeFieldNameField: function () { selectTimeFieldOption(selection) {
return this.remote.setFindTimeout(defaultFindTimeout) // open dropdown
.findDisplayedByCssSelector('select[ng-model="index.timeField"]'); return this.getTimeFieldNameField().click()
}, .then(() => {
// close dropdown, keep focus
selectTimeFieldOption: function (selection) { return this.getTimeFieldNameField().click();
var self = this; })
.then(() => {
// open dropdown return PageObjects.header.getSpinnerDone();
return self.getTimeFieldNameField().click() })
.then(function () { .then(() => {
// close dropdown, keep focus return PageObjects.common.try(() => {
return self.getTimeFieldNameField().click(); return this.getTimeFieldOption(selection).click()
}) .then(() => {
.then(function () { return this.getTimeFieldOption(selection).isSelected();
return headerPage.getSpinnerDone(); })
}) .then(selected => {
.then(function () { if (!selected) throw new Error('option not selected: ' + selected);
return common.try(function () {
return self.getTimeFieldOption(selection).click()
.then(function () {
return self.getTimeFieldOption(selection).isSelected();
})
.then(function (selected) {
if (!selected) throw new Error('option not selected: ' + selected);
});
}); });
}); });
}, });
}
getTimeFieldOption: function (selection) { getTimeFieldOption(selection) {
return this.remote.setFindTimeout(defaultFindTimeout) return this.remote.setFindTimeout(defaultFindTimeout)
.findDisplayedByCssSelector('option[label="' + selection + '"]').click(); .findDisplayedByCssSelector('option[label="' + selection + '"]').click();
}, }
getCreateButton: function () { getCreateButton() {
return this.remote.setFindTimeout(defaultFindTimeout) return this.remote.setFindTimeout(defaultFindTimeout)
.findDisplayedByCssSelector('[type="submit"]'); .findDisplayedByCssSelector('[type="submit"]');
}, }
clickDefaultIndexButton: function () { clickDefaultIndexButton() {
return this.remote.setFindTimeout(defaultFindTimeout) return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button.btn.btn-warning.ng-scope').click() .findByCssSelector('button.btn.btn-warning.ng-scope').click()
.then(function () { .then(() => {
return headerPage.getSpinnerDone(); return PageObjects.header.getSpinnerDone();
}); });
}, }
clickDeletePattern: function () { clickDeletePattern() {
return this.remote.setFindTimeout(defaultFindTimeout) return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button.btn.btn-danger.ng-scope').click(); .findByCssSelector('button.btn.btn-danger.ng-scope').click();
}, }
getIndexPageHeading: function () { getIndexPageHeading() {
return this.remote.setFindTimeout(defaultFindTimeout) return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('h1.title.ng-binding.ng-isolate-scope'); .findByCssSelector('h1.title.ng-binding.ng-isolate-scope');
}, }
getConfigureHeader: function () { getConfigureHeader() {
return this.remote.setFindTimeout(defaultFindTimeout) return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('h1'); .findByCssSelector('h1');
}, }
getTableHeader: function () { getTableHeader() {
return this.remote.setFindTimeout(defaultFindTimeout) return this.remote.setFindTimeout(defaultFindTimeout)
.findAllByCssSelector('table.table.table-condensed thead tr th'); .findAllByCssSelector('table.table.table-condensed thead tr th');
}, }
sortBy: function (columnName) { sortBy(columnName) {
return this.remote.setFindTimeout(defaultFindTimeout) return this.remote.setFindTimeout(defaultFindTimeout)
.findAllByCssSelector('table.table.table-condensed thead tr th span') .findAllByCssSelector('table.table.table-condensed thead tr th span')
.then(function (chartTypes) { .then(function (chartTypes) {
function getChartType(chart) { function getChartType(chart) {
return chart.getVisibleText() return chart.getVisibleText()
.then(function (chartString) { .then(function (chartString) {
if (chartString === columnName) { if (chartString === columnName) {
return chart.click() return chart.click()
.then(function () { .then(function () {
return headerPage.getSpinnerDone(); return PageObjects.header.getSpinnerDone();
});
}
});
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Bluebird.all(getChartTypesPromises);
});
},
getTableRow: function (rowNumber, colNumber) {
return this.remote.setFindTimeout(defaultFindTimeout)
// passing in zero-based index, but adding 1 for css 1-based indexes
.findByCssSelector('div.agg-table-paginated table.table.table-condensed tbody tr:nth-child(' +
(rowNumber + 1) + ') td.ng-scope:nth-child(' +
(colNumber + 1) + ') span.ng-binding'
);
},
getFieldsTabCount: function () {
var self = this;
var selector = 'li.kbn-management-tab.active a small';
return common.try(function () {
return self.remote.setFindTimeout(defaultFindTimeout / 10)
.findByCssSelector(selector).getVisibleText()
.then(function (theText) {
// the value has () around it, remove them
return theText.replace(/\((.*)\)/, '$1');
});
});
},
getPageSize: function () {
var selectedItemLabel = '';
return this.remote.setFindTimeout(defaultFindTimeout)
.findAllByCssSelector('select.ng-pristine.ng-valid.ng-untouched option')
.then(function (chartTypes) {
function getChartType(chart) {
var thisChart = chart;
return chart.isSelected()
.then(function (isSelected) {
if (isSelected === true) {
return thisChart.getProperty('label')
.then(function (theLabel) {
selectedItemLabel = theLabel;
});
}
});
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Bluebird.all(getChartTypesPromises);
})
.then(function () {
return selectedItemLabel;
});
},
getPageFieldCount: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findAllByCssSelector('div.agg-table-paginated table.table.table-condensed tbody tr td.ng-scope:nth-child(1) span.ng-binding');
},
goToPage: function (pageNum) {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('ul.pagination-other-pages-list.pagination-sm.ng-scope li.ng-scope:nth-child(' +
(pageNum + 1) + ') a.ng-binding'
)
.then(function (page) {
return page.click();
});
},
openControlsRow: function (row) {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('table.table.table-condensed tbody tr:nth-child(' +
(row + 1) + ') td.ng-scope div.actions a.btn.btn-xs.btn-default i.fa.fa-pencil'
)
.then(function (page) {
return page.click();
});
},
openControlsByName: function (name) {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('div.actions a.btn.btn-xs.btn-default[href$="/' + name + '"]')
.then(function (button) {
return button.click();
});
},
increasePopularity: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button.btn.btn-default[aria-label="Plus"]')
.then(function (button) {
return button.click();
})
.then(function () {
return headerPage.getSpinnerDone();
});
},
getPopularity: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('input[ng-model="editor.field.count"]')
.then(function (input) {
return input.getProperty('value');
});
},
controlChangeCancel: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button.btn.btn-primary[aria-label="Cancel"]')
.then(function (button) {
return button.click();
})
.then(function () {
return headerPage.getSpinnerDone();
});
},
controlChangeSave: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button.btn.btn-success.ng-binding[aria-label="Update Field"]')
.then(function (button) {
return button.click();
})
.then(function () {
return headerPage.getSpinnerDone();
});
},
setPageSize: function (size) {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('form.form-inline.pagination-size.ng-scope.ng-pristine.ng-valid div.form-group option[label="' + size + '"]')
.then(function (button) {
return button.click();
})
.then(function () {
return headerPage.getSpinnerDone();
});
},
createIndexPattern: function () {
var self = this;
return common.try(function () {
return self.navigateTo()
.then(function () {
return self.clickExistingData();
})
.then(function () {
return self.selectTimeFieldOption('@timestamp');
})
.then(function () {
return self.getCreateButton().click();
});
})
.then(function () {
return headerPage.getSpinnerDone();
})
.then(function () {
return common.try(function () {
return self.remote.getCurrentUrl()
.then(function (currentUrl) {
common.log('currentUrl', currentUrl);
if (!currentUrl.match(/indices\/.+\?/)) {
throw new Error('Index pattern not created');
} else {
common.debug('Index pattern created: ' + currentUrl);
}
}); });
}
}); });
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Bluebird.all(getChartTypesPromises);
});
}
getTableRow(rowNumber, colNumber) {
return this.remote.setFindTimeout(defaultFindTimeout)
// passing in zero-based index, but adding 1 for css 1-based indexes
.findByCssSelector('div.agg-table-paginated table.table.table-condensed tbody tr:nth-child(' +
(rowNumber + 1) + ') td.ng-scope:nth-child(' +
(colNumber + 1) + ') span.ng-binding'
);
}
getFieldsTabCount() {
var self = this;
var selector = 'li.kbn-management-tab.active a small';
return PageObjects.common.try(function () {
return self.remote.setFindTimeout(defaultFindTimeout / 10)
.findByCssSelector(selector).getVisibleText()
.then(function (theText) {
// the value has () around it, remove them
return theText.replace(/\((.*)\)/, '$1');
}); });
}, });
}
removeIndexPattern: function () { getPageSize() {
var self = this; var selectedItemLabel = '';
var alertText; return this.remote.setFindTimeout(defaultFindTimeout)
.findAllByCssSelector('select.ng-pristine.ng-valid.ng-untouched option')
return common.try(function () { .then(function (chartTypes) {
return self.clickDeletePattern() function getChartType(chart) {
.then(function () { var thisChart = chart;
return self.remote.getAlertText(); return chart.isSelected()
}) .then(function (isSelected) {
.then(function (text) { if (isSelected === true) {
alertText = text; return thisChart.getProperty('label')
}) .then(function (theLabel) {
.then(function () { selectedItemLabel = theLabel;
return self.remote.acceptAlert(); });
}
}); });
}) }
.then(function () {
return common.try(function () { var getChartTypesPromises = chartTypes.map(getChartType);
return self.remote.getCurrentUrl() return Bluebird.all(getChartTypesPromises);
})
.then(() => {
return selectedItemLabel;
});
}
getPageFieldCount() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findAllByCssSelector('div.agg-table-paginated table.table.table-condensed tbody tr td.ng-scope:nth-child(1) span.ng-binding');
}
goToPage(pageNum) {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('ul.pagination-other-pages-list.pagination-sm.ng-scope li.ng-scope:nth-child(' +
(pageNum + 1) + ') a.ng-binding'
)
.then(page => {
return page.click();
});
}
openControlsRow(row) {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('table.table.table-condensed tbody tr:nth-child(' +
(row + 1) + ') td.ng-scope div.actions a.btn.btn-xs.btn-default i.fa.fa-pencil'
)
.then(page => {
return page.click();
});
}
openControlsByName(name) {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('div.actions a.btn.btn-xs.btn-default[href$="/' + name + '"]')
.then(button => {
return button.click();
});
}
increasePopularity() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button.btn.btn-default[aria-label="Plus"]')
.then(button => {
return button.click();
})
.then(() => {
return PageObjects.header.getSpinnerDone();
});
}
getPopularity() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('input[ng-model="editor.field.count"]')
.then(input => {
return input.getProperty('value');
});
}
controlChangeCancel() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button.btn.btn-primary[aria-label="Cancel"]')
.then(button => {
return button.click();
})
.then(() => {
return PageObjects.header.getSpinnerDone();
});
}
controlChangeSave() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button.btn.btn-success.ng-binding[aria-label="Update Field"]')
.then(button => {
return button.click();
})
.then(() => {
return PageObjects.header.getSpinnerDone();
});
}
setPageSize(size) {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('form.form-inline.pagination-size.ng-scope.ng-pristine.ng-valid div.form-group option[label="' + size + '"]')
.then(button => {
return button.click();
})
.then(() => {
return PageObjects.header.getSpinnerDone();
});
}
createIndexPattern() {
return PageObjects.common.try(() => {
return this.navigateTo()
.then(() => {
return this.clickExistingData();
})
.then(() => {
return this.selectTimeFieldOption('@timestamp');
})
.then(() => {
return this.getCreateButton().click();
});
})
.then(() => {
return PageObjects.header.getSpinnerDone();
})
.then(() => {
return PageObjects.common.try(() => {
return this.remote.getCurrentUrl()
.then(function (currentUrl) { .then(function (currentUrl) {
if (currentUrl.match(/indices\/.+\?/)) { PageObjects.common.log('currentUrl', currentUrl);
throw new Error('Index pattern not removed');
if (!currentUrl.match(/indices\/.+\?/)) {
throw new Error('Index pattern not created');
} else {
PageObjects.common.debug('Index pattern created: ' + currentUrl);
} }
}); });
});
})
.then(function () {
return alertText;
}); });
} });
}; }
return SettingsPage; removeIndexPattern() {
}()); var alertText;
return PageObjects.common.try(() => {
return this.clickDeletePattern()
.then(() => {
return this.remote.getAlertText();
})
.then(function (text) {
alertText = text;
})
.then(() => {
return this.remote.acceptAlert();
});
})
.then(() => {
return PageObjects.common.try(() => {
return this.remote.getCurrentUrl()
.then(function (currentUrl) {
if (currentUrl.match(/indices\/.+\?/)) {
throw new Error('Index pattern not removed');
}
});
});
})
.then(() => {
return alertText;
});
}
}

View file

@ -1,37 +1,30 @@
import { remote, defaultFindTimeout } from '../';
// in test/support/pages/shield_page.js import {
export default (function (require) { defaultFindTimeout,
// the page object is created as a constructor } from '../';
// so we can provide the remote Command object
// at runtime export default class ShieldPage {
function ShieldPage() {
constructor() {
} }
ShieldPage.prototype = { init(remote) {
constructor: ShieldPage, this.remote = remote;
}
init(remote) { login(user, pwd) {
this.remote = remote; var remote = this.remote;
}, return remote.setFindTimeout(defaultFindTimeout)
.findById('username')
.type(user)
.then(function () {
return remote.findById('password')
.type(pwd);
})
.then(function () {
return remote.findByCssSelector('.btn')
.click();
});
}
login: function login(user, pwd) { }
var remote = this.remote;
return remote.setFindTimeout(defaultFindTimeout)
.findById('username')
.type(user)
.then(function () {
return remote.findById('password')
.type(pwd);
})
.then(function () {
return remote.findByCssSelector('.btn')
.click();
});
}
};
return ShieldPage;
}());

File diff suppressed because it is too large Load diff