javascriptangularjsprotractormodal-window

Click on a button in a Modal Window - Protractor


I'm writing protractor tests for an existing app. I have a button called 'Decline' in a modal window, and I'm trying to click it using:

element(by.buttonText('Decline')).click();

But I receive the below error:

UnknownError: unknown error: Element is not clickable at point (,). Other element would receive the click:

May be because I have another button called 'Decline' outside the modal window?

enter image description here

How do I click on the modal window's Decline button ?

Found that this is the js code that displays this Decline button.

.....
var content = {
          title: 'Decline',
          htmlBody: '<p>...</p> ',
          okButton: 'Decline',
          onOk: function() {
.....

Solution

  • My Colleague recommended this and it worked:

    Clicking on First Decline button opens up a modal,

    Sleep for some time,

    Now click on the second Decline button.

    element(by.buttonText('Decline')).click();
    browser.sleep(2000);
    element(by.cssContainingText('.btn', 'Decline')).click();
    

    Thanks for all your help :)