JANAKI RAMAYYA
JANAKI RAMAYYA

Reputation: 11

Not able to open link in new tab using ctrl + mouse click in testcafe

import { fixture, Selector } from 'testcafe';
 
fixture`Fixture import`.only
    .page('https://testcafe.io/documentation/402634/guides');
 
test('Click a button', async t => {
 
    await t.maximizeWindow()
    const ab = Selector('a[href="/documentation/402837/guides/basic-guides/assertions"]')
    await t.click(ab, {modifiers: {ctrl:true}})
    await t.wait(5000)
});

I'm trying to open a link in new tab using ctrl + click, the testcase was getting pass, not throwing any error but the link is opening in the same tab.

Upvotes: 1

Views: 297

Answers (1)

Alex Kamaev
Alex Kamaev

Reputation: 6318

TestCafe does not open new windows using the Ctrl + mouse click combination. The ctrl modifier only sets the ctrlKey property of the MouseEvent to true. If you want to open a new window, you can use the openWindow method: https://testcafe.io/documentation/402694/reference/test-api/testcontroller/openwindow

Upvotes: 1

Related Questions