0

I'm using Protractor (with Cucumber js) for E2E testing of an application. I'm trying to test a negative scenario with it i.e. when the user enters a duplicate value for creating an object, it should not get created, and the user should get an error message in a modal box (which disappears after 2-3 seconds). However, while testing for the visibility of the modal box upon click, protractor is throwing an error. Here's my code:

Scenario: User sets in a duplicate logical object name

        If a user enters a name which is the duplicate of an existing logical object, they should not be able
        to create the logical object

        When the user clicks on the "New" button
        Then the "New Logical Object" panel should be displayed

       Given the user enters "Part" in the "Name" field in the form
       And the user enters "Part Description" in the "Description" textarea in the form
       And the user uploads the "ProjectManagement.png" file

       When the user clicks on the "Create" button in the form
       Then there should be an error message in the form of a popup

Here's the stepdef file :

@Then(/^there should be an error message in the form of a popup$/)
    public assertPopUpError() {
        return StepDefUtil.executeInIFrame<BladePanelPage>( BladePanelPage, (page: BladePanelPage) => {
            page.assertPopUpErrorMessage();
        });
    }

The page file (BladePanelPage.ts)

/**
     * Asserts presence of popup message- for a step which fails .
     *
     *
     * @return Promise.
     */
    public assertPopUpErrorMessage(): Chai.PromisedAssertion {

        let xpathString = '//aw-pop-up-message//div[contains(@class, 'aw-modal-content')]';
        return expect(element(by.xpath(xpathString )).isPresent()).to.eventually.equal(true, 'The Element with xpath "' + xpath + '" is not displayed');
    }

aw-pop-up-message

is a custom Angular2 component.

The error message which is coming from protractor is:

E/launcher - The Element with xpath "//aw-pop-up-message//div[contains(@class, "aw-modal-content")]" is not displayed: expected false to equal true

I tried the method shown here and here, but it isn't working. Disabling animations in the protractor.config.js file also doesn't seem to work. Any help would be appreciated.

Community
  • 1
  • 1
Shubhang
  • 297
  • 1
  • 5
  • 13

1 Answers1

0

https://stackoverflow.com/a/32076359/1989583

The above answered worked for me. Turns out, this is a protractor issue, and the workaround in this answer allows me to test for the pop-up element. Thanks to @Chris Traynor for the workaround.

Note: Earlier, I was using the accepted answer for the same question, which did not work for me.

Community
  • 1
  • 1
Shubhang
  • 297
  • 1
  • 5
  • 13