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, {
promisify
} from 'bluebird';

View file

@ -1,71 +1,62 @@
import { remote, defaultFindTimeout } from '../';
// in test/support/pages/shield_page.js
export default (function (require) {
// the page object is created as a constructor
// so we can provide the remote Command object
// at runtime
var thisTime;
import {
defaultFindTimeout,
} from '../';
function ConsolePage() {
export default class ConsolePage {
constructor() {
}
ConsolePage.prototype = {
constructor: ConsolePage,
init(remote) {
this.remote = remote;
this.findTimeout = this.remote.setFindTimeout(defaultFindTimeout);
}
init(remote) {
this.remote = remote;
thisTime = this.remote.setFindTimeout(defaultFindTimeout);
},
getServer() {
return this.findTimeout
.findByCssSelector('#kibana-body > div.content > div > div')
.getVisibleText();
}
getServer: function getServer() {
return thisTime
.findByCssSelector('#kibana-body > div.content > div > div')
.getVisibleText();
},
setServer(server) {
return this.findTimeout
.findByCssSelector('input[aria-label="Server Name"]')
.clearValue()
.type(server);
}
setServer: function setServer(server) {
return thisTime
.findByCssSelector('input[aria-label="Server Name"]')
.clearValue()
.type(server);
},
getRequest() {
return this.findTimeout
.findAllByCssSelector('div.ace_line_group')
.then(function (editorData) {
getRequest: function getRequest() {
return thisTime
.findAllByCssSelector('div.ace_line_group')
.then(function (editorData) {
function getEditorData(line) {
return line.getVisibleText();
}
function getEditorData(line) {
return line.getVisibleText();
}
var getEditorDataPromises = editorData.map(getEditorData);
return Promise.all(getEditorDataPromises);
});
}
var getEditorDataPromises = editorData.map(getEditorData);
return Promise.all(getEditorDataPromises);
});
},
getResponse() {
return this.findTimeout
.findByCssSelector('#output > div.ace_scroller > div')
.getVisibleText();
}
getResponse: function getResponse() {
return thisTime
.findByCssSelector('#output > div.ace_scroller > div')
.getVisibleText();
},
clickPlay() {
return this.findTimeout
.findByCssSelector('#editor_actions > span.ng-scope > a > i')
.click();
}
clickPlay: function clickPlay() {
return thisTime
.findByCssSelector('#editor_actions > span.ng-scope > a > i')
.click();
},
collapseHelp() {
return this.findTimeout
.findByCssSelector('div.config-close.remove > i')
.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 () {
var thisTime;
import {
defaultFindTimeout,
} from '../';
function DashboardPage() {
import PageObjects from './';
export default class DashboardPage {
constructor() {
}
DashboardPage.prototype = {
constructor: DashboardPage,
init(remote) {
this.remote = remote;
this.findTimeout = this.remote.setFindTimeout(defaultFindTimeout);
}
init(remote) {
this.remote = remote;
thisTime = this.remote.setFindTimeout(defaultFindTimeout);
},
clickNewDashboard() {
return this.findTimeout
.findByCssSelector('button.ng-scope[aria-label="New Dashboard"]')
.click();
}
clickNewDashboard: function clickNewDashboard() {
return thisTime
.findByCssSelector('button.ng-scope[aria-label="New Dashboard"]')
.click();
},
clickAddVisualization() {
return this.findTimeout
.findByCssSelector('button.ng-scope[aria-label="Add a panel to the dashboard"]')
.click();
}
clickAddVisualization: function clickAddVisualization() {
return thisTime
.findByCssSelector('button.ng-scope[aria-label="Add a panel to the dashboard"]')
.click();
},
filterVizNames(vizName) {
return this.findTimeout
.findByCssSelector('input[placeholder="Visualizations Filter..."]')
.click()
.pressKeys(vizName);
}
filterVizNames: function filterVizNames(vizName) {
return thisTime
.findByCssSelector('input[placeholder="Visualizations Filter..."]')
clickVizNameLink(vizName) {
return this.findTimeout
.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()
.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) {
return thisTime
.findByLinkText(vizName)
.click();
},
getPanelTitles() {
PageObjects.common.debug('in getPanelTitles');
return this.findTimeout
.findAllByCssSelector('span.panel-title')
.then(function (titleObjects) {
closeAddVizualizationPanel: function closeAddVizualizationPanel() {
common.debug('-------------close panel');
return thisTime
.findByCssSelector('i.fa fa-chevron-up')
.click();
},
function getTitles(chart) {
return chart.getAttribute('title');
}
addVisualization: function addVisualization(vizName) {
var self = this;
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();
});
},
var getTitlePromises = titleObjects.map(getTitles);
return Promise.all(getTitlePromises);
});
}
saveDashboard: function saveDashboard(dashName) {
var self = this;
return thisTime
.findByCssSelector('button.ng-scope[aria-label="Save Dashboard"]')
.click()
.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();
});
});
},
getPanelData() {
PageObjects.common.debug('in getPanelData');
return this.findTimeout
.findAllByCssSelector('li.gs-w')
.then(function (titleObjects) {
clickDashboardByLinkText: function clickDashboardByLinkText(dashName) {
return thisTime
.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: function loadSavedDashboard(dashName) {
var self = this;
return thisTime
.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};
function getTitles(chart) {
var obj = {};
return chart.getAttribute('data-col')
.then(theData => {
obj = {dataCol:theData};
return chart;
})
.then(chart => {
return chart.getAttribute('data-row')
.then(theData => {
obj.dataRow = theData;
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);
return Promise.all(getTitlePromises);
});
}
var getTitlePromises = titleObjects.map(getTitles);
return Promise.all(getTitlePromises);
});
}
};
return DashboardPage;
}());
}

View file

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

View file

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

View file

@ -1,387 +1,384 @@
import Bluebird from 'bluebird';
import { common, remote, defaultFindTimeout, headerPage } from '../';
export default (function () {
function SettingsPage() {
import Bluebird from 'bluebird';
import {
defaultFindTimeout,
} from '../';
import PageObjects from './';
export default class SettingsPage {
constructor() {
}
SettingsPage.prototype = {
constructor: SettingsPage,
init(remote) {
this.remote = remote;
}
init(remote) {
this.remote = remote;
},
clickNavigation() {
// TODO: find better way to target the element
return this.remote.findDisplayedByCssSelector('.app-link:nth-child(5) a').click();
}
clickNavigation: function () {
// TODO: find better way to target the element
return this.remote.findDisplayedByCssSelector('.app-link:nth-child(5) a').click();
},
clickLinkText(text) {
return this.remote.findDisplayedByLinkText(text).click();
}
clickLinkText: function (text) {
return this.remote.findDisplayedByLinkText(text).click();
},
clickKibanaSettings() {
return this.clickLinkText('Advanced Settings');
}
clickKibanaSettings: function () {
return this.clickLinkText('Advanced Settings');
},
clickKibanaIndicies() {
return this.clickLinkText('Index Patterns');
}
clickKibanaIndicies: function () {
return this.clickLinkText('Index Patterns');
},
clickExistingData() {
return this.clickLinkText('Existing Data');
}
clickExistingData: function () {
return this.clickLinkText('Existing Data');
},
getAdvancedSettings(propertyName) {
PageObjects.common.debug('in setAdvancedSettings');
return PageObjects.common.findTestSubject('advancedSetting&' + propertyName + ' currentValue')
.getVisibleText();
}
getAdvancedSettings: function getAdvancedSettings(propertyName) {
common.debug('in setAdvancedSettings');
return common.findTestSubject('advancedSetting&' + propertyName + ' currentValue')
.getVisibleText();
},
setAdvancedSettings(propertyName, propertyValue) {
var self = this;
setAdvancedSettings: function setAdvancedSettings(propertyName, propertyValue) {
var self = this;
return PageObjects.common.findTestSubject('advancedSetting&' + propertyName + ' editButton')
.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')
.click()
.then(function () {
return headerPage.getSpinnerDone();
})
.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(propertyName) {
var self = this;
PageObjects.common.debug('in setAdvancedSettings');
return PageObjects.common.findTestSubject('advancedSetting&' + propertyName + ' currentValue')
.getVisibleText();
}
getAdvancedSettings: function getAdvancedSettings(propertyName) {
var self = this;
common.debug('in setAdvancedSettings');
return common.findTestSubject('advancedSetting&' + propertyName + ' currentValue')
.getVisibleText();
},
navigateTo() {
return PageObjects.common.navigateToApp('settings');
}
navigateTo: function () {
return common.navigateToApp('settings');
},
getTimeBasedEventsCheckbox() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('input[ng-model="index.isTimeBased"]');
}
getTimeBasedEventsCheckbox: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('input[ng-model="index.isTimeBased"]');
},
getTimeBasedIndexPatternCheckbox(timeout) {
timeout = timeout || defaultFindTimeout;
// 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) {
timeout = timeout || defaultFindTimeout;
// fail faster since we're sometimes checking that it doesn't exist
return this.remote.setFindTimeout(timeout)
.findByCssSelector('input[ng-model="index.nameIsPattern"]');
},
getIndexPatternField() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('[ng-model="index.name"]');
}
getIndexPatternField: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('[ng-model="index.name"]');
},
getTimeFieldNameField() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findDisplayedByCssSelector('select[ng-model="index.timeField"]');
}
getTimeFieldNameField: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findDisplayedByCssSelector('select[ng-model="index.timeField"]');
},
selectTimeFieldOption: function (selection) {
var self = this;
// open dropdown
return self.getTimeFieldNameField().click()
.then(function () {
// close dropdown, keep focus
return self.getTimeFieldNameField().click();
})
.then(function () {
return headerPage.getSpinnerDone();
})
.then(function () {
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);
});
selectTimeFieldOption(selection) {
// open dropdown
return this.getTimeFieldNameField().click()
.then(() => {
// close dropdown, keep focus
return this.getTimeFieldNameField().click();
})
.then(() => {
return PageObjects.header.getSpinnerDone();
})
.then(() => {
return PageObjects.common.try(() => {
return this.getTimeFieldOption(selection).click()
.then(() => {
return this.getTimeFieldOption(selection).isSelected();
})
.then(selected => {
if (!selected) throw new Error('option not selected: ' + selected);
});
});
},
});
}
getTimeFieldOption: function (selection) {
return this.remote.setFindTimeout(defaultFindTimeout)
.findDisplayedByCssSelector('option[label="' + selection + '"]').click();
},
getTimeFieldOption(selection) {
return this.remote.setFindTimeout(defaultFindTimeout)
.findDisplayedByCssSelector('option[label="' + selection + '"]').click();
}
getCreateButton: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findDisplayedByCssSelector('[type="submit"]');
},
getCreateButton() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findDisplayedByCssSelector('[type="submit"]');
}
clickDefaultIndexButton: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button.btn.btn-warning.ng-scope').click()
.then(function () {
return headerPage.getSpinnerDone();
});
},
clickDefaultIndexButton() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button.btn.btn-warning.ng-scope').click()
.then(() => {
return PageObjects.header.getSpinnerDone();
});
}
clickDeletePattern: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button.btn.btn-danger.ng-scope').click();
},
clickDeletePattern() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('button.btn.btn-danger.ng-scope').click();
}
getIndexPageHeading: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('h1.title.ng-binding.ng-isolate-scope');
},
getIndexPageHeading() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('h1.title.ng-binding.ng-isolate-scope');
}
getConfigureHeader: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('h1');
},
getTableHeader: function () {
return this.remote.setFindTimeout(defaultFindTimeout)
.findAllByCssSelector('table.table.table-condensed thead tr th');
},
getConfigureHeader() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('h1');
}
getTableHeader() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findAllByCssSelector('table.table.table-condensed thead tr th');
}
sortBy: function (columnName) {
return this.remote.setFindTimeout(defaultFindTimeout)
.findAllByCssSelector('table.table.table-condensed thead tr th span')
.then(function (chartTypes) {
function getChartType(chart) {
return chart.getVisibleText()
.then(function (chartString) {
if (chartString === columnName) {
return chart.click()
.then(function () {
return headerPage.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);
}
sortBy(columnName) {
return this.remote.setFindTimeout(defaultFindTimeout)
.findAllByCssSelector('table.table.table-condensed thead tr th span')
.then(function (chartTypes) {
function getChartType(chart) {
return chart.getVisibleText()
.then(function (chartString) {
if (chartString === columnName) {
return chart.click()
.then(function () {
return PageObjects.header.getSpinnerDone();
});
}
});
}
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 () {
var self = this;
var alertText;
return common.try(function () {
return self.clickDeletePattern()
.then(function () {
return self.remote.getAlertText();
})
.then(function (text) {
alertText = text;
})
.then(function () {
return self.remote.acceptAlert();
getPageSize() {
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;
});
}
});
})
.then(function () {
return common.try(function () {
return self.remote.getCurrentUrl()
}
var getChartTypesPromises = chartTypes.map(getChartType);
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) {
if (currentUrl.match(/indices\/.+\?/)) {
throw new Error('Index pattern not removed');
PageObjects.common.log('currentUrl', currentUrl);
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
export default (function (require) {
// the page object is created as a constructor
// so we can provide the remote Command object
// at runtime
function ShieldPage() {
import {
defaultFindTimeout,
} from '../';
export default class ShieldPage {
constructor() {
}
ShieldPage.prototype = {
constructor: ShieldPage,
init(remote) {
this.remote = remote;
}
init(remote) {
this.remote = remote;
},
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();
});
}
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