import {Selector,t} from "testcafe"
class LoginPage{
constructor(){
this.email= Selector("#email")
this.password= Selector("#password")
this.loginButton =Selector(".new-button")
this.link= Selector("a").withText("Welcome, System Administrator")
this.onscreenmessage = Selector("#main > div.notification.notification-error > div > p")
}
async login(username, password){
var that = this;
await t.typeText(that.email, username)
.typeText(that.password, password)
.pressKey("enter")
.expect(this.link).ok()
console.log("User is able to login successfully")
}
}
export default LoginPage
[
{
"testcasename:": "Test for Non Existing User by username",
"loginusername": "TestUser",
"loginpassword": "I love TestCafe!",
"onscreenmessage": "Invalid Login or password."
},
{
"testcasename:": "Test for Non Existing User by email",
"loginusername": "[email protected]",
"loginpassword": "TestCafe is awesome!",
"onscreenmessage": "Invalid Login or password."
},
{
"testcasename:": "Test for Valid User and invalid password",
"loginusername": "Demopreview_admin",
"loginpassword": "TestCafe is awesome!",
"onscreenmessage": "Invalid username/email or password."
}
]
import { Selector } from 'testcafe';
import {login} from "../helper"
import LoginPage from "../page-object/Login-Page"
const dataSet = require('../test/testdata/login.json')
fixture `Role based access control`
.page `https://demopreview-qa-test-myplace.net/users/sign_in`
const LoginPage = new LoginPage()
dataSet.forEach(userdata => {
test('Executing Tests '${data.testcasename'}', async t => {
await LoginPage.login(userdata.loginusername,userdata.loginpassword);
await t.expect(LoginPage.onscreenmessage.textContent).eql(userdata.onscreenmessage,'Match not found');
});
});
寻找双眼进行扫描,看看我在做什么错。
您的代码中有两个错别字: