I am using protractor framework Jasmine runner for Angular testing. I can click on each item if it has css selector. Now one problem is there is a delete button in my app. if I click delete button, there is a window notification message which have two options ok, cancel. I cannot see any css selector for this by which I can click ok in the running test. As a result test is failed.
I am explaining with my code.
my html code
<mat-card-actions>
<button mat-raised-button color="warn" (click)="onDeleteUser(selectedUser)" class="btn btn-default t-delete-user" [disabled]="!selectedUser.userId">{{ 'Delete'}}</button>
</mat-card-actions>
My Typscript Code
onDeleteUser( user ) {
if ( window.confirm( this.translateService.instant( "DeleteUser" )) ) {
this.userService.delete( this.selectedUser ).subscribe(
succ => {
this.notificationSerice.showOK( this.translateService.instant( "UserDeleted" ) );
this.selectedUser = null;
this.selectedUserRole = null;
this.loadUserPage();
},
err => this.notificationSerice.showError( this.translateService.instant( "CouldNotDeleteUser" ))
);
}
}
In Protractor Test I wrote in this way
let deleteUser = element(by.css('.t-delete-user'));
it('Delete button is clicked and a pop up message is appeared', async () => {
await click.onto(deleteUser);
//click.onto(ok);
// but do not know how can I click ok from the window message
});
