I have two functions that I want to run one after the other finishes. I'm using webdriver.IO so I need to wait for one function to log into the page, and then I want another function to run.
Other questions here on SOF are telling me to use a promise, however I need to use a promise, however when I wrap my functions in a promise I get the error SyntaxError: await is only valid in async function.
I have a login function
const Login = async () => { const browser = await remote({ capabilities: { browserName: 'chrome' } }) const userName = await browser.$('#username') const password = await browser.$('#password') await userName.setValue(process.env.NAMEUSERNAME) await password.setValue(process.env.PASSWORD) const loginButton = await browser.$('button[type="submit"]') await loginButton.click() } Once this completes and the page loads I want to run another function. I have gotten this to work with a setTimeout however I don't want to just have a chain of setTimeout in my application
await Login(); anotherFunction()orLogin().then(() => { anotherFunction() })if the caller is not async.