I do have a register process/form which passes email
, password
, confirmPass
and a tc
checkbox which has a boolean value.
When the user submits the form, an open dialogue with a text opens and in the other hand an email is being sent to the user to confirm his registration. Everything works fine.
To run an E2E protractor test for this process I wrote wrote the following code:
it("Should register the user and send confirmation email", () => {
page.getInputFields().userEmailInput.sendKeys("myFirstName.myLastName@domain-xxx.com");
page.getInputFields().userPassInput.sendKeys('!Q2w3e4r');
page.getInputFields().userConfirmPass.sendKeys('!Q2w3e4r');
element(by.tagName('mat-checkbox')).click();
expect( page
.getInputFields()
.userEmailInput.getAttribute("value") ).toEqual("myFirstName.myLastName@domain-xxx.com");
expect(page
.getInputFields()
.userPassInput.getAttribute("value") ).toEqual('!Q2w3e4r');
expect(page
.getInputFields()
.userConfirmPass.getAttribute('value') ).toEqual('!Q2w3e4r');
element( by.tagName('mat-checkbox') ).isSelected().then(function(selected) {
if (selected) {
element( by.name('mat-checkbox') ).click();
expect( page.getInputFields().userAccept.isSelected() ).toBe(true);
page
.getInputFields()
.submitButton.click();
}
});
});
The test also runs without error(s). But my issue is that I'am expecting after the test that I get the confirmation email in my inbox, which prove me in the other hand that the test was 100% successful, but I just don't get the confirmation email which means that the test isn't really running as expected.
submitButton
and I'am not testing it (in my code)?One thing I still have to mention is that the button is disabled if user data are missing and the tc (checkbox) isn't checked.
Issue is fixed and here is the working code:
it("Should register the user and send confirmation email", () => {
page.getInputFields().userEmailInput.sendKeys("myFirstName.myLastName@domain-xxx.com");
page.getInputFields().userPassInput.sendKeys('!Q2w3e4r');
page.getInputFields().userConfirmPass.sendKeys('!Q2w3e4r');
element(by.tagName('mat-checkbox')).click();
expect( page
.getInputFields()
.userEmailInput.getAttribute("value") ).toEqual("myFirstName.myLastName@domain-xxx.com");
expect( page
.getInputFields()
.userPassInput.getAttribute("value") ).toEqual('!Q2w3e4r');
expect( page
.getInputFields()
.userConfirmPass.getAttribute('value') ).toEqual('!Q2w3e4r');
browser.wait(protractor.ExpectedConditions.elementToBeClickable( element( by.name('submitForm') ) ), 100000)
.then ( () => {
browser.actions().mouseMove( element( by.name('submitForm') ) ).click().perform();
}).then ( () => {
browser.sleep(500);
browser.actions().mouseMove( element( by.name('submitForm') ) ).click().perform();
});
});
The following posting was very helpful!