-1

I am using browser.sleep(10000); in my JavaScript code using Protractor frame work.However,when i execute my script multiple time some times it gets passed or failed for not identifying the object.

Is there an alternative method to check whether the page is loaded and element is visible and enabled so that script does not fail during execution.

cnishina
  • 5,016
  • 1
  • 23
  • 40
shankarbkp
  • 17
  • 2
  • 2
    Check the official documentation -- http://www.protractortest.org/#/api?view=ProtractorExpectedConditions.prototype.visibilityOf – Grasshopper Apr 21 '17 at 12:09
  • http://stackoverflow.com/questions/30205235/protractor-waiting-for-element-to-be-in-dom – Gunderson Apr 21 '17 at 15:14
  • 1
    Possible duplicate of [Protractor waiting for element to be in DOM](http://stackoverflow.com/questions/30205235/protractor-waiting-for-element-to-be-in-dom) – Gunderson Apr 21 '17 at 15:14
  • 1
    Also, agree that the official documentation is what you need. If you are on an Angular / AngularJS page you shouldn't need arbitrary sleeps. – cnishina Apr 21 '17 at 16:30

1 Answers1

0

FWIW, I have a blog post on how I deal with page loading. Basically, I have wrapper methods that I use to go to() a page, and then test that I'm at() that page, using ExpectedConditions. I also have working, example code up on github.

Brine
  • 3,733
  • 1
  • 21
  • 38