0

I have to automate a scenario where a user has to assign one group/row out of n(10) group/row on 1st page. All groups/rows cannot be assigned.Only those group/row can be assigned that does not throw error message(based on group review state) in banner. So we have to iterate over each group and check if error appears or not. If no error is there then assign the group/row and break the .each loop.

The code below works fine but at the end it throws the following error:

Failed: unknown error: Element is not clickable at point (333, 555).

Other element would receive the click: <div class="loading"></div"

As per the error script is trying to click checkboxOfAllGroupRow element even after loop is over.

How can we fix this issue?

this.assignGroupRow = function () {
    pageTab.click();
    filterDropdownIcon.click();
    setValuesInFilterDropDown.click()
        .then(function () {
            functionLibrary.waitForLoaderToDisappear();
            browser.sleep(3000);
            var num = -1;
            checkboxOfAllGroupRow.each(function (checkbox, index) {
                checkbox.click().then(function () {
                    assignButtonInGroupPage.click();
                    dismissableErrorMessageInBanner.isPresent()
                        .then(function (errorPresence) {
                            if (errorPresence) {
                                checkbox.click();
                                dismissableErrorCloseIconInBanner.click();

                                if (index == groupCountOnFirstPage - 1)
                                    console.log(" No groups in first page can be assigned.");
                            } else {
                                assignReasonIcon.click();
                                youIdentifiedSMEReason.click();
                                suggestSMENameTextField.click();
                                suggestSMENameInputField.sendKeys("ldapID");
                                functionLibrary.waitElementToBeVisisble(highlightedOptionInSuggestSMEDropDown);
                                highlightedOptionInSuggestSMEDropDown.click();
                                yesBtnInAssignmentOfGroupDialog.click()
                                    .then(function () {
                                        bannerMessageOnAssignmentOfGroup.getText().then(function (message) {
                                            expect(message).toContain('group selected successfully assigned');
                                            num = index;
                                            return;
                                        });
                                        console.log(errorPresence + ' inside else. dialog is present at ' + index);
                                    });
                            }
                        });
                });
            });
        });
}
Philipp Kief
  • 8,172
  • 5
  • 33
  • 43
Mfs_Dheeraj
  • 104
  • 4
  • In general, the point of testing is that you already know the results, you are just trying to recreate them. Making the test break out of the loop when a group is selected could cause a bad test to pass. You should know if the set conditions will cause a group to produce an error or not and respond accordingly – Ben Mohorc Dec 03 '18 at 21:35
  • However, if there is an unavoidable reason to need a test like this, this answer explains breaking out of a `forEach()` loop https://stackoverflow.com/questions/2641347/short-circuit-array-foreach-like-calling-break – Ben Mohorc Dec 03 '18 at 21:38

0 Answers0