I am currently experimenting with determining if an element is positioned at the bottom of a page in Protractor/Webdriver using promises. However, I feel like my current approach is quite messy and there must be a cleaner way to achieve this.
describe('Element', function(){
it('should be located at the bottom', function(){
element(by.id('page').getSize().then(function(dimP){
element(by.id('element').getLocation().then(function(locE){
element(by.id('element').getSize().then(function(dimE){
expect(locE.y + dimE.height).toEqual(dimP.height);
})
});
});
})
});
Is there a more efficient way to accomplish this task? My Protractor version is 2.1.0.
I did attempt a different approach:
expect(element(by.id('page').getSize().height).toEqual(1000);
However, I received an error "Expected undefined to equal 1000." It seems like I cannot directly use return values as outlined here: https://github.com/angular/protractor/blob/master/docs/control-flow.md
(Please note that in my actual test, I utilize a page object which results in cleaner code compared to this example.)