Ben Aston
Ben Aston

Reputation: 55729

Accessing synchronous behavior via a Protractor instance

I would like to inject a protractor instance into my tests, and then use this to perform navigation and element selection, but it appears that the functionality hanging off the Protractor object is all asynchronous, and the functionality on browser and element is synchronous.

Is there a way to access the synchronous behavior via the Protractor object?

Also: I have seen tests that invoke the following at the start:

protractor.getInstance()

...and I have seen tests that use the globally available browser and element objects directly.

What are the important differences between these two approaches?

Upvotes: 2

Views: 353

Answers (1)

hankduan
hankduan

Reputation: 6034

Nothing in protractor is synchronous. It just looks that way before jasmine has been patched (by jasminewd) to wait for the async code so that it's easier to work with.

Please read https://code.google.com/p/selenium/wiki/WebDriverJs to see how controlflow makes everything in webdriver look synchronous. Then read https://github.com/angular/protractor/blob/master/docs/control-flow.md to see how protractor did it with jasminewd.

The link shared by @glepretre (stackoverflow.com/q/25496379/3049002) tells you the difference between ptor.get and browser.get. In short, use browser.get()

Upvotes: 1

Related Questions