diff --git a/test/functional/apps/visualize/_tsvb_time_series.ts b/test/functional/apps/visualize/_tsvb_time_series.ts index 0a2400a367a76..e60ccd2b1f853 100644 --- a/test/functional/apps/visualize/_tsvb_time_series.ts +++ b/test/functional/apps/visualize/_tsvb_time_series.ts @@ -108,7 +108,6 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { expect(actualCount).to.be(expectedLegendValue); }); - // FLAKY: https://github.com/elastic/kibana/issues/40458 it('should show the correct count in the legend with "Human readable" duration formatter', async () => { await visualBuilder.clickSeriesOption(); await visualBuilder.changeDataFormatter('Duration'); diff --git a/test/functional/page_objects/visual_builder_page.ts b/test/functional/page_objects/visual_builder_page.ts index c64d623979313..34cd999b4cd13 100644 --- a/test/functional/page_objects/visual_builder_page.ts +++ b/test/functional/page_objects/visual_builder_page.ts @@ -239,7 +239,7 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro formatter: 'Bytes' | 'Number' | 'Percent' | 'Duration' | 'Custom' ) { const formatterEl = await find.byCssSelector('[id$="row"] .euiComboBox'); - await comboBox.setElement(formatterEl, formatter); + await comboBox.setElement(formatterEl, formatter, { clickWithMouse: true }); } /** @@ -260,11 +260,11 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro }) { if (from) { const fromCombobox = await find.byCssSelector('[id$="from-row"] .euiComboBox'); - await comboBox.setElement(fromCombobox, from); + await comboBox.setElement(fromCombobox, from, { clickWithMouse: true }); } if (to) { const toCombobox = await find.byCssSelector('[id$="to-row"] .euiComboBox'); - await comboBox.setElement(toCombobox, to); + await comboBox.setElement(toCombobox, to, { clickWithMouse: true }); } if (decimalPlaces) { const decimalPlacesInput = await find.byCssSelector('[id$="decimal"]'); diff --git a/test/functional/services/combo_box.ts b/test/functional/services/combo_box.ts index b8267f0b4cbe3..2e44e0248cabe 100644 --- a/test/functional/services/combo_box.ts +++ b/test/functional/services/combo_box.ts @@ -46,13 +46,21 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont await this.setElement(comboBox, value); } + private async clickOption(isMouseClick: boolean, element: WebElementWrapper) { + return isMouseClick ? await browser.clickMouseButton(element) : await element.click(); + } + /** * set value inside combobox element * * @param comboBoxElement * @param value */ - public async setElement(comboBoxElement: WebElementWrapper, value: string): Promise { + public async setElement( + comboBoxElement: WebElementWrapper, + value: string, + options = { clickWithMouse: false } + ): Promise { log.debug(`comboBox.setElement, value: ${value}`); const isOptionSelected = await this.isOptionSelected(comboBoxElement, value); @@ -65,21 +73,22 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont await this.openOptionsList(comboBoxElement); if (value !== undefined) { - const options = await find.allByCssSelector( + const selectOptions = await find.allByCssSelector( `.euiFilterSelectItem[title^="${value.toString().trim()}"]`, WAIT_FOR_EXISTS_TIME ); - if (options.length > 0) { - await options[0].click(); + if (selectOptions.length > 0) { + await this.clickOption(options.clickWithMouse, selectOptions[0]); } else { // if it doesn't find the item which text starts with value, it will choose the first option - await find.clickByCssSelector('.euiFilterSelectItem'); + const firstOption = await find.byCssSelector('.euiFilterSelectItem'); + await this.clickOption(options.clickWithMouse, firstOption); } } else { - await find.clickByCssSelector('.euiFilterSelectItem'); + const firstOption = await find.byCssSelector('.euiFilterSelectItem'); + await this.clickOption(options.clickWithMouse, firstOption); } - await this.closeOptionsList(comboBoxElement); } @@ -241,11 +250,11 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont value: string ): Promise { log.debug(`comboBox.isOptionSelected, value: ${value}`); - const selectedOptions = await comboBoxElement.findAllByClassName( - 'euiComboBoxPill', - WAIT_FOR_EXISTS_TIME - ); - return selectedOptions.length === 1 && (await selectedOptions[0].getVisibleText()) === value; + const $ = await comboBoxElement.parseDomContent(); + const selectedOptions = $('.euiComboBoxPill') + .toArray() + .map(option => $(option).text()); + return selectedOptions.length === 1 && selectedOptions[0] === value; } }