Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit ce724b6

Browse files
committed
feat: implement driver click method
1 parent 81c5d65 commit ce724b6

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Method | Description
8383
`driver.setGeolocation(location)` | Set the browser's HTML5 geolocation. Expects `location` to be an object like `{latitude: 37.425, longitude: -122.136, altitude: 10.0}`. Not supported in all browsers.
8484
`driver.buttonDown(button)` | Presses down the pointer button (default 0 = left, can be 1 = middle, 2 = right) at location of last `element.movePointerRelativeTo()`
8585
`driver.buttonUp(button)` | Like `driver.buttonDown()`
86+
`driver.click(button)` | Like `driver.buttonDown()`
8687
`driver.close()` | Closes the WebDriver session.
8788

8889
### Element
@@ -177,7 +178,7 @@ Status | HTTP Method | Path | Summary
177178
![impl] | POST | `/session/:sessionId/accept_alert` | Accepts the currently displayed alert dialog.
178179
![impl] | POST | `/session/:sessionId/dismiss_alert` | Dismisses the currently displayed alert dialog.
179180
![impl] | POST | `/session/:sessionId/moveto` | Move the pointer by an offset of the specified element.
180-
![not-yet] | POST | `/session/:sessionId/click` | Click any pointer button (at the coordinates set by the last moveto command).
181+
![impl] | POST | `/session/:sessionId/click` | Click any pointer button (at the coordinates set by the last moveto command).
181182
![impl] | POST | `/session/:sessionId/buttondown` | Click and hold the left pointer button (at the coordinates set by the last moveto command).
182183
![impl] | POST | `/session/:sessionId/buttonup` | Releases the pointer button previously held (where the pointer is currently at).
183184
![not-yet] | POST | `/session/:sessionId/doubleclick` | Double-clicks at the current pointer coordinates (set by moveto).

lib/pointer_api.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ module.exports = function(http) {
4747
http.post('/buttonup', {
4848
button: button
4949
});
50+
},
51+
click: function(button) {
52+
if (button == null) {
53+
button = 0;
54+
}
55+
http.post('/click', {
56+
button: button
57+
});
5058
}
5159
};
5260
};

src/pointer_api.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ module.exports = (http) ->
3737
buttonUp: (button=0) ->
3838
http.post '/buttonup', { button }
3939
return
40+
41+
click: (button=0) ->
42+
http.post '/click', { button }
43+
return

0 commit comments

Comments
 (0)