Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback function is taking long after completing the run in the protractor testcase #5541

Open
vinny7942 opened this issue Dec 7, 2021 · 0 comments

Comments

@vinny7942
Copy link

Hello there,
I am using protractor with selenium and jasmin framework.
one of my it() testcase calls a function clearfilters which is last step of that testcase. After that function is done executing the main it() testcase took more than 7 to 10 secs to exit out of that block. But if I skip that function then it() testcase runs normally. Not sure what the issue is. Here I am attaching the video of both with and without calling that function. Below also included the snippet of the code. Can someone let me know whats the issue would be as this function will be used many times while running End to end.

it('Test#15 - Advance search Email dumps', async (done) => {
        let testId = 15;
        log.info('\n', 'Test case -' + testId + ' Advance search Email dumps');
      const openSearch = element(by.css('[data-testid="data_search_open"]'));
      let keywords_Search_Field = element(by.css('[data-testid="data_search_form"] [name="keywords"]'));
      let uploadUser_Select = element.all(by.xpath('//*[contains(@data-testid,"search_user_")]')).first();
      await advancedSearch(keywords_Search_Field, 'Elizabeth', 'text', testId + '_keywordsField');
      await openSearch.click();
      keywords_Search_Field.sendKeys(protractor.Key.CONTROL, 'a');
      keywords_Search_Field.sendKeys(protractor.Key.BACK_SPACE);
      keywords_Search_Field.sendKeys(protractor.Key.ENTER);
      await printPageInfo('keywords_clear');
      await advancedSearch(uploadUser_Select, 'Megan Greatorex', 'atpop', testId + '_uploadedByField');
      await clearFilters();
      console.log('all done');
      done();
    });

the callback function clearfilter

 async function clearFilters() {
    try {
      let filterElement = element.all(by.xpath('//*[contains(@class,"deleteIconColorPrimary")]'));
      return filterElement.isPresent().then(async (present) => {
      if (present) {
          return filterElement.count().then(async function (count) {
          for (let i = 0; i < count; i++) {
          await filterElement.get(i).click();
          await genericWait(EC.visibilityOf(element(by.css('[data-selenium="email_dump_item_0"]'))), 1000).then(async (emailDisplayed)=> {
          console.log('emailDisplayed '+emailDisplayed)
         })
         let countResult = filterElement.then(function (count) {
            return count;
         })
         if (countResult = '0') {
           console.log('All filters are removed')
           break;
         }
       }
     })
    }
    return;
    })
    } catch (error) {
      console.log(error)
    }
    }
    });

Run with the function clearfilter
If you notice in the above video, in the console after it prints "all done" message you can see it was waiting for more than 5 secs

Run without the function clearfilter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant