srinathbharadwaj
srinathbharadwaj

Reputation: 135

Testcafe - Unable to click on a button

I am trying to click on a button but for some weird reason, I am not able to. Here is the code.

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

});

But if I go through debug mode using .debug() and then use Next-Action option in the debugger, the .click() works.

I am not able to understand what is going on here. Why is it .click() is working in .debug() but not in normal flow.

Upvotes: 1

Views: 3497

Answers (1)

Shurygin.Sergey
Shurygin.Sergey

Reputation: 431

When the Testcafe click action is executed on a DOM element, it calls the element.click() method. Mentioned 'Failed to execute 'requestFullscreen' on 'Element' error means that click event handler calls the requestFullscreen method, which must be called inside a user interaction only. This is a browser's security restriction and there is no way to overcome it.

Upvotes: 4

Related Questions