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

Conversation

liza-mae
Copy link
Contributor

@liza-mae liza-mae commented Jun 5, 2018

This is a fix for #19679 to remove the use of .ng-scope, .ng-binding in selenium selectors that can make the tests flaky / brittle. We should move towards using data-test-subj. This is just a temporary fix to get the tests running on cloud.

@cjcenizal cjcenizal self-requested a review June 5, 2018 21:46
@liza-mae
Copy link
Contributor Author

liza-mae commented Jun 5, 2018

These were not updated but they are failing:

test/functional/page_objects/visualize_page.js: const selector = [group-name="${groupName}"] vis-editor-agg-params:not(.ng-hide) .agg-select;
test/functional/page_objects/visualize_page.js: const selector = [group-name="${groupName}"] vis-editor-agg-params:not(.ng-hide) .field-select;

Was not sure how to remove and keep the equivalent functionality.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@cjcenizal
Copy link
Contributor

jenkins test this

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

LGTM! But let's get the CI passing. It failed originally because of a flaky test, which prevented a bunch of subsequent tests from running.

@@ -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.

@@ -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.

@@ -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.

@@ -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.

@@ -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.

@@ -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.

@@ -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.

👍

@@ -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.

👍

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@liza-mae liza-mae merged commit 5ccaca4 into elastic:master Jun 7, 2018
@liza-mae liza-mae deleted the fix/issue-19679 branch June 7, 2018 18:53
@liza-mae liza-mae mentioned this pull request Dec 19, 2018
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants