I'm testing the login page , in the scenario when I enter an invalid logIn and Password , I'm looking to collect the span "Authentication Failed"
I select the span webElement by xpath '/html/body/div[2]/div/div/snack-bar-container/simple-snack-bar/span, when I test it on the navigator console , I receive the text inside the span . But when I use it on the test script , it doesn't work .
getSnackbar() {
return element(by.xpath('/html/body/div[2]/div/div/snack-bar-
container/simple-snack-bar/span'));
}
it(' SnackBar "Authentication Failed" Appears ', () => {
login.navigateTo();
element(by.id('username')).sendKeys('LogIn');
element(by.id('password')).sendKeys('pwd');
login.logIn();
browser.sleep(5000);
expect(login.getSnackbar().getText()).toEqual('Failed Authentication');
});
I expect to receive a positive result of the test , but I receive : " Failed to load resource: the server responded with a status of 401 (Unauthorized)".