I have a hard time trying to understand how the control flow in the transporter works in relation to how the JS event loop works. Here is what I know so far:
The protractor control protocol stores commands that return promises to the queue. The first team will be in front of the queue, and the last team will be on the back. No team will be executed until the team before it fulfills its promise.
The JS event loop stores an asynchronous task (for specific callbacks). Callbacks are not executed until all functions on the stack are complete and the stack is empty. Before starting each callback, it checks to see if it is empty or not.
so let's take this code for example. The code basically presses the search button and an api request is executed. Then, after returning the data, it is checked whether the field in which the returned data is stored exists.
elem('#searchButton').click();
browser.wait(ExpectedConditions.presenceOf(elem('#resultDataField'),3000));
expect(elem('#resultDataField').isPresent()).toBeTruthy();
So, with this code, I can make it work. But I do not know how it turns out. How is the event loop applied in this scenario?
source
share