Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'ysono/master' into enhance-click
Conflicts: README.md lib/commands/buttonClick.js lib/commands/click.js
- Loading branch information
Showing
17 changed files
with
294 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,4 @@ | ||
module.exports = function buttonClick (cssSelector, callback) { | ||
var self = this; | ||
this.element(cssSelector, function(err,result){ | ||
|
||
if(err === null && result.value){ | ||
|
||
self.moveTo(result.value.ELEMENT, function(err,result){ | ||
|
||
if(err === null) { | ||
|
||
self.buttonDown(function(){ | ||
|
||
if(err === null) { | ||
|
||
self.buttonUp(callback); | ||
|
||
} else { | ||
callback(err, result); | ||
} | ||
|
||
}); | ||
|
||
} else { | ||
callback(err, result); | ||
} | ||
}); | ||
|
||
} else { | ||
|
||
callback(err, result); | ||
|
||
} | ||
}); | ||
}; | ||
// Deprecated but included for backward compatibility. Alias for 'click' command. | ||
module.exports = function buttonClick () { | ||
return this.click.apply(this, arguments); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var handleMouseButtonCommand = require('../helpers/handleMouseButtonCommand'); | ||
|
||
module.exports = function leftClick (cssSelector, callback) { | ||
|
||
handleMouseButtonCommand.call( | ||
this, | ||
cssSelector, | ||
'left', | ||
callback | ||
); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var handleMouseButtonCommand = require('../helpers/handleMouseButtonCommand'); | ||
|
||
module.exports = function middleClick (cssSelector, callback) { | ||
|
||
handleMouseButtonCommand.call( | ||
this, | ||
cssSelector, | ||
'middle', | ||
callback | ||
); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var handleMouseButtonCommand = require('../helpers/handleMouseButtonCommand'); | ||
|
||
module.exports = function rightClick (cssSelector, callback) { | ||
|
||
handleMouseButtonCommand.call( | ||
this, | ||
cssSelector, | ||
'right', | ||
callback | ||
); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// call must be scoped to the webdriverjs client | ||
module.exports = function(cssSelector, button, callback) { | ||
|
||
var self = this; | ||
|
||
if(typeof cssSelector === 'function') { | ||
callback = cssSelector; | ||
cssSelector = undefined; | ||
} | ||
callback = callback || function() {}; | ||
|
||
if(button === 'left' && cssSelector) { | ||
self.click(cssSelector, callback); | ||
} else if(! cssSelector) { | ||
self.buttonPress(button, callback); | ||
} else { | ||
|
||
self.element("css selector", cssSelector, function(err,result) { | ||
|
||
if(err === null && result.value) { | ||
|
||
self.moveTo(result.value.ELEMENT, function(err,result){ | ||
|
||
if(err === null) { | ||
self.buttonPress(button, callback); | ||
} else { | ||
callback(err, result); | ||
} | ||
|
||
}); | ||
|
||
} else { | ||
|
||
callback(err,result); | ||
|
||
} | ||
}); | ||
|
||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// call must be scoped to the webdriverjs client | ||
module.exports = function(requestPath, button, callback) { | ||
|
||
var buttonEnum = { | ||
left: 0, | ||
middle: 1, | ||
right: 2 | ||
}; | ||
|
||
if(typeof callback !== 'function' && typeof button === 'function') { | ||
callback = button; | ||
button = buttonEnum.left; | ||
} | ||
if(typeof button !== 'number') { | ||
button = buttonEnum[button || 'left']; | ||
} | ||
|
||
this.requestHandler.create( | ||
{ | ||
path: requestPath, | ||
method: "POST" | ||
}, | ||
{ | ||
button: button | ||
}, | ||
callback | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
module.exports = function buttonDown (callback) { | ||
var handleMouseButtonProtocol = require('../helpers/handleMouseButtonProtocol'); | ||
|
||
var requestOptions = { | ||
path:"/session/:sessionId/buttondown", | ||
method:"POST" | ||
}; | ||
module.exports = function buttonDown (button, callback) { | ||
|
||
this.requestHandler.create(requestOptions,{},callback); | ||
handleMouseButtonProtocol.call( | ||
this, | ||
"/session/:sessionId/buttondown", | ||
button, callback | ||
); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var handleMouseButtonProtocol = require('../helpers/handleMouseButtonProtocol'); | ||
|
||
module.exports = function buttonPress (button, callback) { | ||
|
||
handleMouseButtonProtocol.call( | ||
this, | ||
"/session/:sessionId/click", | ||
button, callback | ||
); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
module.exports = function buttonUp (callback) { | ||
var handleMouseButtonProtocol = require('../helpers/handleMouseButtonProtocol'); | ||
|
||
var requestOptions = { | ||
path:"/session/:sessionId/buttonup", | ||
method:"POST" | ||
}; | ||
module.exports = function buttonUp (button, callback) { | ||
|
||
this.requestHandler.create(requestOptions,{},callback); | ||
handleMouseButtonProtocol.call( | ||
this, | ||
"/session/:sessionId/buttonup", | ||
button, callback | ||
); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.