Comprises four commands to interact with window.alert, window.confirm and window.prompt
alertOK()
setswindow.alert
to returntrue
when it is called in your applicationconfirmOK()
setswindow.confirm
to returntrue
when it is called in your applicationconfirmCancel()
setswindow.confirm
to returnfalse
when it is called in your applicationsetPromptValue(value)
setswindow.prompt
to returnvalue
when it is called in your application
Save window-dialog-commands.js
file into your project (e.g. test/e2e/
) and load it in the test/e2e/runner.html
file
<script src="../lib/angular/angular-scenario.js" ng-autotest></script>
<script src="window-dialog-commands.js"></script>
<script src="scenarios.js"></script>
Execute the relevant command in the it
block where your application is using a dialog box.
Given that your application is greeting the user with their name just after they log in you can use the alertOK
as:
it('should log in with a valid name', function() {
alertOK();
element(':submit').click();
expect... // expect user to be signed in
});
Given that your application is asking for user's confirmation when they want to logout you can then use confirmOK
and confirmCancel
in your tests as:
it('should log out upon confirmation', function() {
confirmOK();
element('#logout').click();
expect... // expect user to be logged out
});
it('shouldn\'t log out upon cancel', function() {
confirmCancel();
element('#logout').click();
expect... // expect user to be still signed in
});
Given that your application is asking the user to enter their name in a prompt you can then use setPromptValue
in your tests as:
it('should log in with a valid name', function() {
setPromptValue('Ahmet');
alertOK();
expect... // expect user to be signed in
});