Protractor Failed: element not interactable

k.vincent picture k.vincent · Dec 11, 2018 · Viewed 16.8k times · Source

I am running an E2E test for an Angular 7.x app. The test runs straight forward on my local machine. But when I push it on the repo (GitLab), then pipeline fails and throws following error:

USER PROFILE - Check and change PROFILE - Failed: element not interactable (Session info: chrome=71.0.3578.80) (Driver info: chromedriver=2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5),platform=Linux 4.14.74-coreos x86_64)

Test Case:

it('USER PROFILE - Check and change PROFILE', () => {

    page.navigateTo();

    browser.sleep(1000);
    expect(page.getProfileEditTagName()).toMatch('app-edit-profile');

    expect(element(by.className('logged-as')).getText()).toBe( testEmail );


    browser.actions().mouseMove( element.all( by.id('editIcon-salutation') ).get(0)).click().perform().then(function () {
        browser.sleep(4000);

        element( by.className('mat-select-arrow') ).click().then(function () {

            browser.actions().mouseMove( element.all(by.className('option-value mat-option')).get(0)).click().perform();
            browser.sleep(1000);
            browser.actions().mouseMove( element.all( by.id('saveButton-salutation') ).get(0)).click().perform();
            browser.sleep(1000);

        });
    });

});

navigateTo() is just a method in profile.po.ts:

navigateTo() {
    browser.get('/profileComponentUrl');
}

What's confusing me and where I even can't localize the bug or what's wrong, is that it works fine locally. But once I push to repo, then it fails exactly at that test case. Any Hint please?

Answer

Snehalkumar Mahale picture Snehalkumar Mahale · Dec 12, 2018

The reason element is not interactable could be - performing an action on hidden or obscured element.

You can try - 1. add sleep after by.className('mat-select-arrow') ).click(), as I can see you have not added any waits there. 2. Try to check if you running the test on your local and Jenkins machine with same screen resolution. (this could be the reason of obscured element)