user3484258
user3484258

Reputation: 51

Usage of var EC = protractor.ExpectedConditions gets browser stuck

I am new to protractor and I am having following code to click the user

    var EC = protractor.ExpectedConditions;
    var userlink = element(by.id('menu.user'));
    var isLinkClickable = EC.elementToBeClickable(userlink);
    browser.wait(isLinkClickable, 5000).then(function() {
        userlink.click();
    });

What I see is usage of ExpectedConditions actually blocks the test and it doesn't go ahead. If I remove it then my tests exit abruptly by coming "Element not visible". Am I using the right option?

Upvotes: 1

Views: 471

Answers (2)

Sanja Paskova
Sanja Paskova

Reputation: 1110

var EC = protractor.ExpectedConditions;
var userlink = element(by.id('menu.user'));
browser.wait(EC.elementToBeClickable(element(by.id('menu.user'))), 30000, "menu user element is not clickable").then(function() {
   userlink.click();
}

Upvotes: 1

Niyarlatotep
Niyarlatotep

Reputation: 71

"An Expectation for checking an element is visible and enabled such that you can click it." Probably your "userlink" does not becomу either enabled or visible. You can addd .catch to handle error, or add last argument to show message "browser.wait(isLinkClickable, 5000, 'Not clickable for 5 seconds')". The option is right, but perhaps locator is not right.

Upvotes: 0

Related Questions