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?
答案 0 :(得分:2)
我在捕获中间进度动画方面遇到了类似的问题。
您必须将browser.ignoreSynchronization
设置为true
(这有助于不等待角度稳定下来)并使用browser.wait()
明确等待动画to become visible:< / p>
element(locator).sendKeys(pathOfTheImage);
browser.ignoreSynchronization = true;
var EC = protractor.ExpectedConditions;
browser.wait(EC.visibilityOf(locatorOfProgressBar), 5000, "No progress animation is visible");
并且不要忘记在ignoreSynchronization
之后将其恢复为false
。