Testcafe - 无法点击按钮。

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

我试图点击一个按钮,但由于一些奇怪的原因,我无法点击。下面是代码。

import { ClientFunction } from 'testcafe';
import { Selector } from 'testcafe';

fixture `Fixture`    
    .page `https://viewshape.com/shapes/12b5ntdyuf7`

test(`test`, async t => {    

    await t.maximizeWindow();
    await t.wait(3000);

    const fullScreen = Selector('.sp-controls-btn.js-sp-fullscreen-button').filterVisible();   

    //await t.debug();

    await t
        .expect(fullScreen.with({visibilityCheck: true}).exists)
        .ok({timeout: 30000})
        .hover(fullScreen)
        .click(fullScreen);
    await t.wait(4000);

});

但如果我使用.debug()进入调试模式,然后在调试器中使用Next-Action选项,.click()就能工作。

我不明白这是怎么回事。为什么.click()在.debug()中可以工作,但在正常流程中却不能工作。

testing html5-canvas automated-tests e2e-testing testcafe
1个回答
3
投票

当Testcafe点击动作在一个DOM元素上执行时,它会调用元素.click()方法。在'Element'上提到的'Failed to execute 'requestFullscreen'错误意味着点击事件处理程序调用了Element.click()方法。请求全屏 方法,只能在用户交互中调用。这是浏览器的安全限制,没有办法克服。

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