From 5e0c96afdfdd1470ba9fa64324ba7628501b0c8a Mon Sep 17 00:00:00 2001 From: AlexKamaev Date: Thu, 2 Feb 2023 18:35:30 +0400 Subject: [PATCH] hide status bar when clicking using CDP (closes #7483) (#7484) --- src/client/browser/index.js | 8 +++++-- src/client/driver/driver.js | 5 ++-- .../regression/gh-7483/pages/index.html | 23 +++++++++++++++++++ .../fixtures/regression/gh-7483/test.js | 9 ++++++++ .../gh-7483/testcafe-fixtures/index.js | 10 ++++++++ 5 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 test/functional/fixtures/regression/gh-7483/pages/index.html create mode 100644 test/functional/fixtures/regression/gh-7483/test.js create mode 100644 test/functional/fixtures/regression/gh-7483/testcafe-fixtures/index.js diff --git a/src/client/browser/index.js b/src/client/browser/index.js index 0711ecf5fc4..7adeb5b445c 100644 --- a/src/client/browser/index.js +++ b/src/client/browser/index.js @@ -198,14 +198,18 @@ export function closeWindow (closeWindowUrl, createXHR, windowId) { }); } -export function dispatchProxylessEvent (dispatchProxylessEventUrl, createXHR, type, options) { +export async function dispatchProxylessEvent (dispatchProxylessEventUrl, testCafeUI, createXHR, type, options) { + await testCafeUI.hide(); + const data = JSON.stringify({ //eslint-disable-line no-restricted-globals type, options, }); - return sendXHR(dispatchProxylessEventUrl, createXHR, { + await sendXHR(dispatchProxylessEventUrl, createXHR, { method: 'POST', data, }); + + await testCafeUI.show(); } diff --git a/src/client/driver/driver.js b/src/client/driver/driver.js index c24ea9e40c5..7824f41a955 100644 --- a/src/client/driver/driver.js +++ b/src/client/driver/driver.js @@ -19,7 +19,7 @@ import { import { cursor } from './deps/testcafe-automation'; -import { StatusBar } from './deps/testcafe-ui'; +import testCafeUI from './deps/testcafe-ui'; import { CHECK_IFRAME_DRIVER_LINK_DELAY, @@ -1174,6 +1174,7 @@ export default class Driver extends serviceUtils.EventEmitter { browser.dispatchProxylessEvent, browser.dispatchProxylessEvent, this.communicationUrls.dispatchProxylessEvent, + testCafeUI, hammerhead.createNativeXHR) : null; const executor = new ActionExecutor(command, { @@ -1898,7 +1899,7 @@ export default class Driver extends serviceUtils.EventEmitter { }); this.nativeDialogsTracker = new NativeDialogTracker(this.contextStorage, { proxyless, dialogHandler }); - this.statusBar = new StatusBar(this.runInfo.userAgent, this.runInfo.fixtureName, this.runInfo.testName, this.contextStorage); + this.statusBar = new testCafeUI.StatusBar(this.runInfo.userAgent, this.runInfo.fixtureName, this.runInfo.testName, this.contextStorage); const self = this; diff --git a/test/functional/fixtures/regression/gh-7483/pages/index.html b/test/functional/fixtures/regression/gh-7483/pages/index.html new file mode 100644 index 00000000000..2dfd75b28b6 --- /dev/null +++ b/test/functional/fixtures/regression/gh-7483/pages/index.html @@ -0,0 +1,23 @@ + + + + + + + + + +
+ + + diff --git a/test/functional/fixtures/regression/gh-7483/test.js b/test/functional/fixtures/regression/gh-7483/test.js new file mode 100644 index 00000000000..e5b41daf6dd --- /dev/null +++ b/test/functional/fixtures/regression/gh-7483/test.js @@ -0,0 +1,9 @@ +const { onlyInProxyless } = require('../../../utils/skip-in'); + +describe('[Regression](GH-7483)', function () { + onlyInProxyless('Should click on the element if the element is behind the Status Bar', function () { + return runTests('testcafe-fixtures/index.js'); + }); +}); + + diff --git a/test/functional/fixtures/regression/gh-7483/testcafe-fixtures/index.js b/test/functional/fixtures/regression/gh-7483/testcafe-fixtures/index.js new file mode 100644 index 00000000000..ff51a3ecd38 --- /dev/null +++ b/test/functional/fixtures/regression/gh-7483/testcafe-fixtures/index.js @@ -0,0 +1,10 @@ +import { Selector } from 'testcafe'; + +fixture `Should click on the element if the element is behind the Status Bar` + .page('../pages/index.html'); + +test('Click the button behind the StatusBar', async t => { + await t.click('button'); + + await t.expect(Selector('#logger').innerText).eql('OK'); +});