How to select an item from the ComboBox menu using Vaadin Testbench?

I am doing some integration tests with vaadin version 7.6.4 and Testbench (4.0.3).

I have a view with several comboboxes. One of them has this property comboBox.setTextInputAllowed(false);. For testing purposes, I want to change the default value in combobox, and I need to select another element, and then the default.

To select an item, I tried the following code:

 $(ComboBoxElement.class).selectByText("ElementName");

But it only works when comboBox.setTextInputAllowed(true);

I also tried using sendkeys()to change the selected value:

$(ComboBoxElement.class).openPopup();
$(ComboBoxElement.class).sendKeys(keys.ARROW_DOWN);
$(ComboBoxElement.class).endKeys(Keys.ENTER);

This code opens the comboBox popup correctly, but does not select any item. If I have not set focus using setFocus();

-, , , combobox setTextInputAllowed(false)?.

+4
1

, , , , , Vaadin 7.7.3 TB 4.1.0.alph1 . ( 43 atm), , , TestBench , . , , text.equals(popupSuggestions.get(0) Region - 5, .

debug

, , TB. , , .

, XPath, . Region - 1 Region - 10.

combo content

Region - 5, :

@Test
public void shouldOpenGridColumnVisibilityPopupAndSelectItems() {
    getDriver().get("http://localhost:8080/");
    ComboBoxElement combo = $(ComboBoxElement.class).first();
    combo.openPopup();
    findElement(By.xpath("//*[@id='VAADIN_COMBOBOX_OPTIONLIST']//span[text()='Region - 5']")).click();
}

:

workaround

+1

Source: https://habr.com/ru/post/1656566/


All Articles