ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

ui5-select: How to select a <Option> from <Select> in E2E tests?

Open CristianDDias opened this issue 6 years ago • 3 comments

Describe the bug I'm using ui5-webcomponents-react and Cypress for E2E tests. I'm trying to select a <Option> from <Select> but it's not possible. I've seen that when you click on a select component, it creates a ui5-static-area and ui5-static-area-item, where the select options are placed. But I couldn't find a way to link this ui5-static-area-item with the current <Select> | <Option> components. I tried to click on the <Option> component, but it didn't dispatch any event.

Expected behavior A way to programmatically dispatch a click event on the <Select> | <Option> components so that I can create my E2E tests.

Context

  • UI5 Web Components version: 1.0.0-rc.7
  • OS/Platform: Windows
  • Browser: Chrome

CristianDDias avatar Jun 02 '20 17:06 CristianDDias

I've found the same issue using MultiComboBox and trying to select the MultiComboBoxItem, should I create another issue for that?

SrSatierf avatar Jun 15 '20 19:06 SrSatierf

Hi @CristianDDias

Although it's not pretty, you can select the items like this: if mySelect holds a reference to your select, then:

mySelect.staticAreaItem.staticAreaItemDomRef.shadowRoot.querySelectorAll("ui5-responsive-popover ui5-list ui5-li")

is going to give you a list of all the list items.

However, this selector might break if the internal implementation changes.

I'll keep this issue open until we figure out a more elegant way to provide this.

Regards and sorry for the long delay, Vladi

vladitasev avatar Jul 08 '20 12:07 vladitasev

Thank you @vladitasev!

CristianDDias avatar Jul 08 '20 14:07 CristianDDias