Tim
Tim

Reputation: 1433

protractor test angular bootstrap dropdowns

I have an angular-bootstrap dropdown which works as expected. When I click on the dropdown button in a protractor e2e test, the dropdown does not open. I tried browser.sleep(), browser.waitForAngular(), and browser.wait(function () {return childItem.isDisplayed();}, 1500);. The button will be clicked (css changes), the test runner waits for some time, but the dropdown does not show up. When I try to e.g. getText() from the childItem, I get

ElementNotVisibleError: Element is not currently visible and so may not be interacted with

How can I test angular-bootstrap dropdowns in my e2e tests?

Upvotes: 1

Views: 449

Answers (1)

Hans Poppe
Hans Poppe

Reputation: 323

I made a function that waits for when it is present in the HTML and after that checks if the element is vissible. Hopefully this is a possible fix for your wait problem.

this.waitUntilReady = function (elm) {
        browser.wait(function () {
            return elm.isPresent();
        },10000);
        browser.wait(function () {
            return elm.isDisplayed();
        },10000);
    };

usage:

waitUntillReady(element(by.id('superId')));

Upvotes: 2

Related Questions