Skip to content

ComboBoxElement.getOptions() may return empty array if the values are still being loaded #2067

@mvysny

Description

@mvysny

combobox-testBench 23.6.0

ComboBoxElement.getOptions() may return empty array if the values are still being loaded. Solution is to wait until Combo is ready.

Fix:

    /**
     * @return true if ComboBox is still loading items and populating its dropdown.
     */
    public boolean isLoading() {
        return getPropertyBoolean("loading");
    }

    /**
     * Wait until ComboBox is finished populating its dropdown.
     */
    public void waitWhileLoading() {
        while (isLoading()) {
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }

    @Override
    public List<String> getOptions() {
        // wait until the ComboBox dropdown is populated. Otherwise, we'll get an empty list of options.
        waitWhileLoading();
        return super.getOptions();
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions