Modified LogIn tests

This commit is contained in:
Tatiana Ryzhova 2019-09-11 14:21:19 +02:00
parent 0768591255
commit a3bf7d1079
5 changed files with 54 additions and 13 deletions

View file

@ -0,0 +1,7 @@
import {Selector,t} from 'testcafe';
export default class HomePage{
constructor(){
this.header = Selector ('[data-tc="home-header"]');
}
}

View file

@ -0,0 +1,17 @@
import {Selector,t} from 'testcafe';
export default class LoginPage{
constructor(){
this.mainPageURL='http://localhost:9000/';
this.email = Selector('[data-tc="email"]');
this.password = Selector('[data-tc="password"]');
this.submitButton = Selector('[data-tc="submit"]');
}
async performLogin(putEmail, putPassword){
await t
.typeText(this.email, putEmail)
.typeText(this.password, putPassword)
.click(this.submitButton);
}
}

View file

@ -0,0 +1,7 @@
import * as verifier from '../Verifications/loginPageVerifications';
fixture `Login Tests`
.page(verifier.mainPageURL);
verifier.verifyEmailAndPasswordDisplayed();
verifier.verifyIfUserCanLogin();

View file

@ -0,0 +1,23 @@
import LoginPage from '../Models/loginPageModel';
import HomePage from '../Models/homePageModel';
const loginPage = new LoginPage();
const homePage = new HomePage();
export const mainPageURL = loginPage.mainPageURL;
const USER_EMAIL = 'admin@example.com';
const USER_PASSWORD = 'admin';
export function verifyEmailAndPasswordDisplayed(){
test('Verify that Email and Password are displayed', async t =>{
await t.expect(loginPage.email.exists).ok();
await t.expect(loginPage.password.exists).ok();
})
}
export function verifyIfUserCanLogin(){
test.only('PerformLogin', async t =>{
await loginPage.performLogin(USER_EMAIL, USER_PASSWORD);
await t.expect(homePage.header.exists).ok();
} )
}

View file

@ -1,13 +0,0 @@
import { Selector } from "testcafe";
fixture("Example test").page("http://localhost:8000/dashboard/next");
test("User can log in", async t => {
await t
.typeText('[name="email"]', "admin@example.com")
.typeText('[name="password"]', "admin")
.click('[type="submit"]');
const header = await Selector('[data-tc="home-header"]').exists;
await t.expect(header).ok();
});