Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Commit f8746a9

Browse files
author
Sergey Tatarintsev
committed
fix: correct implementation of doubleClick action
1. There is no `wd.doubleClick` method, there is `doubleclick` 2. It does not accept the button 3. The original code acts on incorrect element
1 parent 2aa4bb0 commit f8746a9

File tree

4 files changed

+8
-36
lines changed

4 files changed

+8
-36
lines changed

lib/browser/new-browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = class NewBrowser extends Browser {
4242
'waitFor',
4343
'moveTo',
4444
'click',
45-
'doubleClick',
45+
'doubleclick',
4646
'buttonDown',
4747
'buttonUp',
4848
'keys',

lib/tests-api/actions-builder.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,18 @@ module.exports = inherit({
116116
return this;
117117
},
118118

119-
doubleClick: function(element, button) {
120-
button = acceptMouseButton(button);
121-
119+
doubleClick: function(element) {
122120
if (isInvalidElement(element)) {
123121
throw new TypeError('.doubleClick() must receive valid element or CSS selector');
124122
}
125123

126124
this._pushAction(this.doubleClick, function(browser) {
127125
return findElement(element, browser)
128-
.then(function() {
129-
return browser.moveTo(element);
130-
})
131-
.then(function() {
132-
return browser.doubleClick(element, button);
126+
.then(function(element) {
127+
return browser.moveTo(element)
128+
.then(function() {
129+
return browser.doubleclick();
130+
});
133131
});
134132
});
135133
return this;

test/unit/browser/new-browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('browser/new-browser', () => {
6464

6565
[
6666
'sleep', 'waitForElementByCssSelector', 'waitForElementByCssSelector', 'waitFor', 'moveTo',
67-
'click', 'doubleClick', 'buttonDown', 'buttonUp', 'keys', 'type', 'tapElement', 'execute',
67+
'click', 'doubleclick', 'buttonDown', 'buttonUp', 'keys', 'type', 'tapElement', 'execute',
6868
'setWindowSize', 'getWindowSize', 'getOrientation', 'setOrientation'
6969
].forEach((method) => it(method, () => testExposedWdMethod(method)));
7070

test/unit/tests-api/actions-builder.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -110,32 +110,6 @@ describe('tests-api/actions-builder', () => {
110110
});
111111
});
112112

113-
describe('doubleClick', () => {
114-
beforeEach(() => {
115-
sandbox.stub(browser, 'doubleClick').returns(Promise.resolve());
116-
});
117-
118-
it('should use left button if not specified', () => {
119-
const doubleClick = mkAction('doubleClick', browser);
120-
121-
return doubleClick('.some-selector')
122-
.then(() => assert.calledWith(browser.doubleClick, '.some-selector', 0));
123-
});
124-
125-
it('should use passed button', () => {
126-
const doubleClick = mkAction('doubleClick', browser);
127-
128-
return doubleClick('.some-selector', 1)
129-
.then(() => assert.calledWith(browser.doubleClick, '.some-selector', 1));
130-
});
131-
132-
it('should throw on bad button (not 0, 1 or 2)', () => {
133-
const doubleClick = mkAction('doubleClick', browser);
134-
135-
assert.throws(() => doubleClick('.some-selector', 3), /Mouse button should be/);
136-
});
137-
});
138-
139113
describe('mouseDown', () => {
140114
beforeEach(() => {
141115
sandbox.stub(browser, 'buttonDown').returns(Promise.resolve());

0 commit comments

Comments
 (0)