Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove flaky selectors: .ng-scope, .ng-binding and .ng-isolate.scope #19688

Merged
merged 1 commit into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/functional/page_objects/discover_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {

getDocHeader() {
return getRemote()
.findByCssSelector('thead.ng-isolate-scope > tr:nth-child(1)')
.findByCssSelector('thead > tr:nth-child(1)')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I only see one thead on the page, so there's no chance that this could be accidentally selecting a different thead that happens to not have .ng-isolate-scope applied.

.getVisibleText();
}

Expand Down
2 changes: 1 addition & 1 deletion test/functional/page_objects/header_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export function HeaderPageProvider({ getService, getPageObjects }) {

async getToastMessage(findTimeout = defaultFindTimeout) {
const toastMessage =
await find.displayedByCssSelector('kbn-truncated.toast-message.ng-isolate-scope', findTimeout);
await find.displayedByCssSelector('kbn-truncated.toast-message', findTimeout);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Likewise, the toaster notifications are a singleton, so there's no chance we could be accidentally selecting a different element here.

const messageText = await toastMessage.getVisibleText();
log.debug(`getToastMessage: ${messageText}`);
return messageText;
Expand Down
2 changes: 1 addition & 1 deletion test/functional/page_objects/monitoring_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function MonitoringPageProvider({ getService }) {

getToasterContents() {
return getRemote()
.findByCssSelector('div.toaster-container.ng-isolate-scope')
.findByCssSelector('div.toaster-container')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Same as above.

.getVisibleText();
}

Expand Down
12 changes: 6 additions & 6 deletions test/functional/page_objects/visualize_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function VisualizePageProvider({ getService, getPageObjects }) {
}

async getChartTypeCount() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this function is ever called, and the wizard-vis-type class doesn't actually exist in our CSS any more. Can we delete this function entirely in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though it is not used, I will leave it up to the visualization team to remove it, if they don't intend to use it.

const tags = await find.allByCssSelector('a.wizard-vis-type.ng-scope');
const tags = await find.allByCssSelector('a.wizard-vis-type');
return tags.length;
}

Expand Down Expand Up @@ -394,7 +394,7 @@ export function VisualizePageProvider({ getService, getPageObjects }) {
// clickBucket(bucketType) 'X-Axis', 'Split Area', 'Split Chart'
async clickBucket(bucketName) {
const chartTypes = await retry.try(
async () => await find.allByCssSelector('li.list-group-item.list-group-menu-item.ng-binding.ng-scope'));
async () => await find.allByCssSelector('li.list-group-item.list-group-menu-item'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This is extremely brittle, but I don't see any elements with this selector which could be inadvertently selected.

This method clicks an item in this list:

image

These items already have data-test-subj attributes on them, so we should refactor this logic to leverage them in a later PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, a later PR to address adding data-test-subj sounds best. This PR is just a quick fix to get things running on cloud.

log.debug('found bucket types ' + chartTypes.length);

async function getChartType(chart) {
Expand Down Expand Up @@ -442,7 +442,7 @@ export function VisualizePageProvider({ getService, getPageObjects }) {
const aggItem = await find.byCssSelector(`[data-test-subj="${agg}"]`);
await aggItem.click();
const fieldSelect = await find
.byCssSelector(`#visAggEditorParams${index} > [agg-param="agg.type.params[0]"] > div > div > div.ui-select-match.ng-scope > span`);
.byCssSelector(`#visAggEditorParams${index} > [agg-param="agg.type.params[0]"] > div > div > div.ui-select-match > span`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This selector's high specificity and dependence upon ui-select class names makes it unlikely it could accidentally select the wrong element.

// open field selection list
await fieldSelect.click();
// select our field
Expand Down Expand Up @@ -510,7 +510,7 @@ export function VisualizePageProvider({ getService, getPageObjects }) {
async orderBy(fieldValue) {
await find.clickByCssSelector(
'select.form-control.ng-pristine.ng-valid.ng-untouched.ng-valid-required[ng-model="agg.params.orderBy"]'
+ `option.ng-binding.ng-scope:contains("${fieldValue}")`);
+ `option:contains("${fieldValue}")`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

async selectOrderBy(fieldValue) {
Expand Down Expand Up @@ -817,12 +817,12 @@ export function VisualizePageProvider({ getService, getPageObjects }) {
}

async getMarkdownData() {
const markdown = await retry.try(async () => find.byCssSelector('visualize.ng-isolate-scope'));
const markdown = await retry.try(async () => find.byCssSelector('visualize'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 There's only one instance of <visualize> on the page at a time, so this should be fine too.

return await markdown.getVisibleText();
}

async clickColumns() {
await find.clickByCssSelector('div.schemaEditors.ng-scope > div > div > button:nth-child(2)');
await find.clickByCssSelector('div.schemaEditors > div > div > button:nth-child(2)');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

async waitForVisualization() {
Expand Down