0
私はchai.jsの予想動作を理解しようとしています。無効な資格情報でログインが失敗したかどうかを確認するコードがあります。これは私のコードです:私は、無効なユーザー名とパスワードを期待し、同じを得ていますので、チャイのテキスト文字列での動作はどうでしょうか?
describe('Login', function() {
before(function(done) {
driver.get('https://pluma-dev.herokuapp.com/client-sign-in').then(done);
});
it('Login with Incorrect credentials', function(done) {
driver.findElement(webdriver.By.name("username")).sendKeys("[email protected]");
driver.findElement(webdriver.By.name("password")).sendKeys("123");
driver.findElement(webdriver.By.className("client-onboarding-signin-btn")).click().then(function(){
driver.findElement(By.css(".has-error")).getText().then(function (text) {
console.log(text);
try{
expect(text).to.be.a("Invalid email or password");
done();
} catch (e) {
done(e);
}
});
});
});
});
私の理解によると、このテストケースを渡す必要があります。ただし、アサーションエラーが発生します。つまり、 1)間違った資格情報を使用してログインします。 AssertionError:無効な電子メールまたはパスワードが無効な電子メールまたはパスワードになると予想されます。
ありがとうございました:) – user2987322