How do I programatically access the current webdri

2019-04-07 15:26发布

问题:

I'm writing an e2e test suite using Protractor.

I know it's built on top of WebdriverJS, and I'm trying to using some webdriverJS functionality.

Namely, I'm trying to enqueue some behavior using the webdriverJS' promise manager, and the WebdriverJS documentation says I should use

webdriver.promise.controlFlow().execute(function myBehavior(){...});

Trouble is, I don't know how to access that "webdriver" object. There is no global variable named "webdriver".

Can someone help me on this?

EDIT:

Now that the question has been solved, I'd like to highlight the fact that one must use

browser.driver.controlFlow()

and not

browser.driver.promise.controlFlow()

despite what WebdriverJS documentation may suggest.

回答1:

The documentation says browser.driver is the underlying webdriver.

So can you try this:

browser.driver.controlFlow().execute(function myBehavior(){...});