2

I am using protractor for automating AngularJS application. There is a scenarios where I need to upload an image using the browse button and check that a progress bar is present while uploading in progress.

I am using the following code to achieve the same:

element(locator).sendKeys(pathOfTheImage);
expect(element(locatorOfProgressBar).isPresent()).toBeTruthy();

The problem here is - although the progress bar is present, the assertion fails always because element(locator).sendKeys(pathOfTheImage); command is still in progress and has not returned anything to proceed with the next command , which is the assertion point.

I have tried using turning off the Synchronisation with no success:

browser.ignoreSynchronization = true;

Any solution to this issue? How can I proceed with the next commands without waiting for the sendKeys command to succeed?

Abhishek Swain
  • 1,054
  • 8
  • 28

1 Answers1

2

I had a similar problem with catching an intermediate progress animation.

You have to set browser.ignoreSynchronization to true (this helps not to wait for angular to settle down) and use browser.wait() to explicitly wait for the animation to become visible:

element(locator).sendKeys(pathOfTheImage);
browser.ignoreSynchronization = true;

var EC = protractor.ExpectedConditions;
browser.wait(EC.visibilityOf(locatorOfProgressBar), 5000, "No progress animation is visible");

And don't forget to revert ignoreSynchronization back to false after.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • In my case locatorOfProgressBar is still not located , while upload in progress. I used the technique you suggested. – Abhishek Swain May 15 '15 at 06:38
  • @Mfsi.AbhishekSwain thanks for the update, is there a way I can reproduce your issue? (in case the site is public) – alecxe May 15 '15 at 10:43