I have a page that has elements that become visible as you scroll down. I am trying to execute a test to make sure the elements are not there until the scroll is to the bottom of the elements, but I can't seem to figure out how to pass the size from one call (elementIdSize()
) to the scroll offset of the next call (scroll()
). Admittedly my brain does not yet get the concept of "promises" past simple call chaining.
I tried something like this:
this.browser
.setViewportSize({width: 1000, height: 600})
.element(selector)
.then(function(e) {
console.log('then element: ', e);
element = e;
})
.elementIdSize(element.id)
.then(function(size) {
console.log('Size: ', size);
})
.call(callback);
Which I was hoping would use the passed-in selector to get the element, set the element in the then()
, then call elementIdSize()
on the element's ID, but the var element
is never set from the element()
call, and the objects I am getting back don't seem to be what I am trying to get anyway. I feel this is some simple piece of knowledge I am missing here that will make all this "click".
I am using the APIs here for looking up the Webdriver calls, but the documentation doesn't give much details.