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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…