如何使用 testcafe locate/click 选择器(按钮)

How to locate/click selector (button) using testcafe

我正在尝试使用 testcafe 测试应用程序的提交。但是,我似乎无法让 testcafe 点击“提交申请”。

到目前为止我已经尝试了以下方法:

.click(Selector('button').withText('Submit Applicaition'))
.click('#submit-application').withText('Submit Application')

还有一些选择。

我什至无法让 testcafe 找到按钮

import {Selector} from 'testcafe';

fixture `MES login`
 .page `http://mes.coeo.com.au/`;

test('FindButton', async t => {

    await t
    .wait(2000)
        .navigateTo('/le12625-senior-exploration-geologist')
    .wait(2000);

    const one = await Selector('#submit-application');

    const two = one.exists;

    await t
        .expect(two).ok()

    await t
    .wait(5000)
        .click(Selector(one));
}

谁能帮帮我,解释一下是我的testcafe脚本还是网站的构建方式,以及如何让testcafe点击按钮?

非常感谢。

Link to site

试试这个解决方案:

test('FindButton', async t => {
    const submitButton = Selector('div#submit-application');
    await t
        .navigateTo('/le12625-senior-exploration-geologist')
        .expect(submitButton.with({visibilityCheck: true}).exists)
        .ok({timeout: 30000})
        .hover(submitButton)
        .click(submitButton);

});

并在 TestCafe 命令行选项中添加 --skip-js-errors,因为当您提交时没有输入任何字段,第 console.log(this.state.data['State'].value); 行会出现错误,因为 this.state.data 是一个空对象