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

Commit f55ff40

Browse files
authored
Merge pull request #45 from groupon/pr-44
Implement driver click method
2 parents 81c5d65 + 51ac055 commit f55ff40

File tree

8 files changed

+20
-7
lines changed

8 files changed

+20
-7
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/element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ module.exports = Element = (function() {
171171
})();
172172

173173
elementOrNull = Element.elementOrNull = function(create) {
174-
var error, error1;
174+
var error;
175175
try {
176176
return create();
177177
} catch (error1) {

lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module.exports = WebDriver = (function() {
113113
};
114114

115115
WebDriver.prototype.evaluate = function(clientFunctionString) {
116-
var args, error, error1, friendlyError, response;
116+
var args, error, friendlyError, response;
117117
if (arguments.length > 1) {
118118
clientFunctionString = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
119119
}
@@ -135,7 +135,7 @@ module.exports = WebDriver = (function() {
135135
};
136136

137137
WebDriver.prototype.evaluateAsync = function(clientFunctionString) {
138-
var args, error, error1, friendlyError, response;
138+
var args, error, friendlyError, response;
139139
if (arguments.length > 1) {
140140
clientFunctionString = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
141141
}

lib/json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3131
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232
*/
3333
module.exports.tryParse = function(jsonString) {
34-
var error, error1;
34+
var error;
3535
try {
3636
return JSON.parse(jsonString);
3737
} catch (error1) {

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
};

lib/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ module.exports = function(arg) {
8989
connectTimeout = CONNECT_TIMEOUT;
9090
}
9191
return function(url, method, data) {
92-
var body, elapsed, err, error, headers, ref1, requestBody, response, startTime;
92+
var body, elapsed, err, headers, ref1, requestBody, response, startTime;
9393
if (method == null) {
9494
method = 'GET';
9595
}

lib/session.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ json = require('./json');
3939
parseResponseData = require('./parse_response');
4040

4141
module.exports = function(request, serverUrl, desiredCapabilities) {
42-
var capabilities, data, error, error1, response, sessionId, url;
42+
var capabilities, data, error, response, sessionId, url;
4343
url = serverUrl + "/session";
4444
data = {
4545
desiredCapabilities: desiredCapabilities

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)