I'm new to selenium and am having trouble having it wait until an element is visible.
the element that shows after entering in incorrect credentials looks like this:
<div class="jss357">User with that username does not exist</div>
async function loginFailure(driver) {
try {
await driver.get('WEBSITE')
await driver.findElement(By.name('username')).sendKeys(usernameBad)
await driver.findElement(By.name('password')).sendKeys(passwordBad)
await driver.findElement(By.css("button[type='submit']")).click()
let elm = await driver.findElement(By.xpath("//div[contains(.,'User
with that username does not exist')]"))
await driver.wait(until.elementIsVisible(elm))
} catch(e) {
console.error('loginFailure failed.error: ', e.message)
}
finally {
console.log('loginFailure finished')
}
}
loginFailure failed.error: no such element: Unable to locate element: {"method":"xpath","selector":"//div[contains(.,'User with that username does not exist')]"}