diff --git a/src/client/automation/playback/drag/base.js b/src/client/automation/playback/drag/base.js index 862191e6451..34e5c2e187d 100644 --- a/src/client/automation/playback/drag/base.js +++ b/src/client/automation/playback/drag/base.js @@ -92,7 +92,7 @@ export default class DragAutomationBase extends VisibleElementAutomation { }); } - _mouseup () { + _mouseup (draggedElement) { return cursor .buttonUp() .then(() => { @@ -126,7 +126,7 @@ export default class DragAutomationBase extends VisibleElementAutomation { }) .then(element => { //B231323 - if (topElement && element === topElement && !this.dragAndDropState.enabled) + if (topElement && element === topElement && !this.dragAndDropState.enabled && element === draggedElement) eventSimulator.click(topElement, options); }); }); @@ -152,6 +152,6 @@ export default class DragAutomationBase extends VisibleElementAutomation { return Promise.all([delay(this.automationSettings.mouseActionStepDelay), this._mousedown(eventArgs)]); }) .then(() => this._drag()) - .then(() => this._mouseup()); + .then(() => this._mouseup(eventArgs.element)); } } diff --git a/test/functional/fixtures/regression/gh-8250/pages/index.html b/test/functional/fixtures/regression/gh-8250/pages/index.html new file mode 100644 index 00000000000..174a0ff9340 --- /dev/null +++ b/test/functional/fixtures/regression/gh-8250/pages/index.html @@ -0,0 +1,11 @@ + + + + + gh-8250 + + +

Example

+ + + diff --git a/test/functional/fixtures/regression/gh-8250/test.js b/test/functional/fixtures/regression/gh-8250/test.js new file mode 100644 index 00000000000..2d51acd015f --- /dev/null +++ b/test/functional/fixtures/regression/gh-8250/test.js @@ -0,0 +1,5 @@ +describe('[Regression](GH-8250)', function () { + it('Click should not be called after dragToElement', function () { + return runTests('testcafe-fixtures/index.js', 'Click should not be called', { only: 'chrome' }); + }); +}); diff --git a/test/functional/fixtures/regression/gh-8250/testcafe-fixtures/index.js b/test/functional/fixtures/regression/gh-8250/testcafe-fixtures/index.js new file mode 100644 index 00000000000..4ccdff3b9de --- /dev/null +++ b/test/functional/fixtures/regression/gh-8250/testcafe-fixtures/index.js @@ -0,0 +1,12 @@ +import { Selector } from 'testcafe'; + +fixture('GH-8250- Click should not be called after dragToElement') + .page`http://localhost:3000/fixtures/regression/gh-8250/pages/index.html`; + +test('Click should not be called', async t => { + const h1Label = Selector('h1').withText('Example'); + const radioInput = Selector('#example'); + + await t.dragToElement(h1Label, radioInput); + await t.expect(radioInput.checked).eql(false); +});