TestCafe-Narbeans Ide-ReferenceError:未定义选择器

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

[大家好:我是TestCafe的新手(昨天开始),而我又面临着Page Object的下一个问题:

这是项目结构:

.
├── main.js
├── nbproject
│   ├── private
│   │   ├── private.properties
│   │   └── private.xml
│   ├── project.properties
│   └── project.xml
├── node_modules
│   └── testcafe -> ../../../../../usr/local/lib/node_modules/testcafe
├── package.json
├── page-object
│   └── First_Page.js
└── test
    └── First_Test.js

[我的页面模型是下一个:

import { selector, t } from 'testcafe';


class FirstPage {

    constructor () {

        this.userName = Selector('#txtRutTrabajador');
        this.passWord = Selector('#txtPwdTrabajador');
        this.accessButton = Selector('#submit2');
    }

    async login () {
        await t
            .typeText(this.userName, 'MyLogin')
            .typeText(this.passWord, 'Pa$$word')
            .click(this.accessButton);
    }
}

export default new FirstPage();

下一个是Test类:

/* global fixture, Fist_Page */

import First_Page from '../page-object/First_Page';

const first_Page = new First_Page();


fixture('First')
        .page('https://www.123.com');



   test( 'User should log in to system', async() => {

   await First_Page.login();    
});

另一方面,我正在使用NetBeans IDE,但我对这个IDE不太了解,因此通过终端机(Mac),我将项目的位置放在了位置并执行下一个命令:

npx testcafe firefox test/ 

testcafe firefox test/ -e

结果为下一个:

    ERROR Cannot prepare tests due to an error.

ReferenceError: Selector is not defined
    at new FirstPage (/Users/nosequeweaponer.g/NetBeansProjects/automation_test_cafe/page-object/First_Page.js:14:9)
    at Object.<anonymous> (/Users/nosequeweaponer.g/NetBeansProjects/automation_test_cafe/test/First_Test.js:11:20)
    at Function._execAsModule (/usr/local/lib/node_modules/testcafe/src/compiler/test-file/api-based.js:50:13)
    at ESNextTestFileCompiler._runCompiledCode (/usr/local/lib/node_modules/testcafe/src/compiler/test-file/api-based.js:150:42)
    at ESNextTestFileCompiler.execute (/usr/local/lib/node_modules/testcafe/src/compiler/test-file/api-based.js:174:21)
    at ESNextTestFileCompiler.compile (/usr/local/lib/node_modules/testcafe/src/compiler/test-file/api-based.js:180:21)
    at Compiler._getTests (/usr/local/lib/node_modules/testcafe/src/compiler/index.js:86:31)
    at Compiler._compileTestFiles (/usr/local/lib/node_modules/testcafe/src/compiler/index.js:98:35)
    at Compiler.getTests (/usr/local/lib/node_modules/testcafe/src/compiler/index.js:111:34)
    at Bootstrapper._getTests (/usr/local/lib/node_modules/testcafe/src/runner/bootstrapper.ts:239:21)

您能帮我吗?

javascript macos netbeans e2e-testing testcafe
1个回答
0
投票

似乎您没有使用在测试中为第一页创建的对象。试试下面的代码

test( 'User should log in to system', async t => {

       await first_Page.login();    
});
© www.soinside.com 2019 - 2024. All rights reserved.