Understanding the transporter flow and WebDriverJS
Can anyone help me understand how WebDriverJS / Protractor works in this case?
function MyPageObject(buttonElementFinder) {
this.getButtonByIndex = function(index) {
return {
myButton: buttonElementFinder.get(index)
}
}
}
1. describe('My button', function() {
2.
3. it('should contain the text foo', function() {
4. var myElementFinder = element.all(by.css('.foo'));
5. var pageObject = new MyPageObject(myElementFinder);
6. var button = pageObject.getButtonByIndex(0);
7. expect(button.text()).toBe('foo');
8. });
9.
10. });
Does the WebDriverJS control flow have an action added to it on line 6 because of the .get
ElementFinder
s method ?
I'm guessing I expect
also add another item to the control flow on line 7?
Edit: I have updated code to use element.all
.
source to share
var myElementFinder = element.all(by.css('.foo'));
myElementFinder is an ElementArrayFinder and is just an object. Nothing happens here.
var pageObject = new MyPageObject(myElementFinder);
Evident.
var button = pageObject.getButtonByIndex(0);
This will return the ElementFinder from buttonElementFinder.get. Nothing happens here.
expect(button.text()).toBe('foo');
button.text()
returns a promise from Webdriver.schedule
, which in turn uses a control flow that is fetched with webdriver.promise.controlFlow()
, which provides an execution function.
source to share