I have encountered an issue where a function is returning undefined instead of the size of an element. Due to my limited knowledge of promises, I am struggling to rewrite it in a way that returns a resolved promise instead of undefined. How can I modify it to achieve this desired outcome?
When checking the console, I see the message:
Expected undefined to be less than undefined.
var s1 = utilitiesPageObject.getElemSize("css", "#main-content > div > div > div.col-xs-12.col-md-6.align-left");
driver.findElement(By.css('#main-content > div > div > div.col-xs-12.col-md-6.align-left > div.slide-down-container > div.slide-down-btn.btn')).click()
var s2 = utilitiesPageObject.getElemSize("css", "#main-content > div > div > div.col-xs-12.col-md-6.align-left")
expect(s1).toBeLessThan(s2);
The above code snippet is calling the getElemSize function from utilitiesPageObject.
getElemSize(css, elem){
switch(css) {
case 'css':
this.driver.findElement(By.css(elem)).getSize().getHeight.then(s => {return s});
break;
case 'xpath':
this.driver.findElement(By.xpath(elem)).getSize().getHeight.then(s => {return s});
break;
default:
return null;
}
}