I have a function that opens a selenium webdriver instance, and then another functions that will grab some info and then navigate the webdriver to a URl. I have used a promise as I was led to believe the second function would wait for the first to complete before executing the second. Here is my code for reference:
function function1(){
let driver = new Builder()
.forBrowser('firefox')
.build();
driver.get(url);
return new Promise((resolve, reject)=>{
resolve('Browser Opened')
})
}
function function2(){
** code to create URL **
driver.get(urlCreated);
}
function1().then(function2);
So this is the code, i was expecting function 2 to wait until function 1 to be completed before executed however this is not the case, am I misunderstanding promises? Can someone point me in the right direction? Thanks in advance