Skip to content Skip to sidebar Skip to footer

What Is `browser.call()` For In Protractor?

I've recently being going through the Protractor API and noticed the browser.call() method: Schedules a command to execute a custom function within the context of webdriver's cont

Solution 1:

the way protractor works is it has an internal queue where it sets the order of your functions. So if you were to call a function somewhere in your test without telling protractor, that function would be outside the queue and the actual execution of the function could happen anytime. You can check that using console.log("something") inside your tests and see that they don't execute in the order the application is written.

If you want a function to run specifically after a webdriver event (meaning you want to add it to the queue) you can call it inside the browser.call() like this

browser.previousStep();
browser.call(functionX, this, parameters...)
browser.nextStep()

The this parameter represents:

The object in whose scope to execute the function (i.e. the this object for the function).

as stated in the documentation.

Post a Comment for "What Is `browser.call()` For In Protractor?"