数据驱动测试未通过1个参数

问题描述 投票:0回答:1

1。登录页面的我的页面模型:

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

2。我的登录数据集

[
    {
        "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."
    }
]

3。这是我的测试的编写方式-基本上遍历json文件,并希望看到测试用例名称出现在日志中。但是将其定义为未定义。

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');
    });
});

寻找双眼进行扫描,看看我在做什么错。

testcafe
1个回答
0
投票

您的代码中有两个错别字:

© www.soinside.com 2019 - 2024. All rights reserved.