0

I have a scenario where there are 2 dropdowns each having some value and then there is an Add button. so we need to select 1 value from one dropdown and then 1 value from other dropdown, then click on add button and then again select another value from both dropdown. However, when i select the value of 1 dropdown then it throws me an error message -

Element is not clickable at the time

Below is the code:

activityPage.activitiesTab.click()
        browser.driver.sleep(2000);
        activityPage.newActivity.click();
        browser.driver.sleep(2000);
        activityPage.entityDropdown.click();
        browser.driver.sleep(2000);
        activityPage.entitesList(function (items) {
            for (var i = 1; i < items.length; ++i) {
                items[i].click()                        
                    browser.driver.sleep(2000);
                    activityPage.activityDropdown.click()
                    activityPage.entitesList(function (activitiesName) {
                        for (var j = 1; j < activitiesName.length; ++j) {
                            activitiesName[j].click();
                            activityPage.activityDropdown.click()
                            browser.driver.sleep(2000);
                            activityPage.entityDropdown.click();
                            items[i].click()
                        }


                });

            }
        });
giri-sh
  • 6,934
  • 2
  • 25
  • 50
anuvrat singh
  • 411
  • 1
  • 7
  • 20

1 Answers1

1

The issue is, like usually, that everything in protractor is a promise, therefore you cannot simply call things in for loop. It will basically run all the loops immediately, not waiting for any async promise resolving.

Here is a nice answer that explains it more thoroughly: https://stackoverflow.com/a/27910350/2374517

Community
  • 1
  • 1
cvakiitho
  • 1,377
  • 13
  • 27