Skip to content

Commit

Permalink
Fixed an issue where the set locateStrategy wasn't used correctly in …
Browse files Browse the repository at this point in the history
…the case of xpath
  • Loading branch information
beatfactor committed Apr 23, 2014
1 parent d574ab2 commit e64e03b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/selenium/element-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ module.exports = function(client) {
elementCommands.submitForm = 'submit';

function addElementCommand(protocolAction, extraArgs) {
var defaultUsing = client.locateStrategy || 'css selector';
var self = this;
extraArgs = extraArgs || 0;
var expectedArgs = 3 + extraArgs;
Expand All @@ -322,6 +321,7 @@ module.exports = function(client) {
args.push(noopFn);
}

var defaultUsing = client.locateStrategy || 'css selector';
if (expectedArgs - args.length === 1) {
args.unshift(defaultUsing);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/mocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
"postdata" : "{\"using\":\"css selector\",\"value\":\"#weblogin\"}",
"response" : "{\"sessionId\":\"1352110219202\",\"status\":0,\"value\":{\"ELEMENT\":\"0\"},\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":604376696}"
},
{
"url" : "/wd/hub/session/1352110219202/element",
"postdata" : "{\"using\":\"xpath\",\"value\":\"//weblogin\"}",
"response" : "{\"sessionId\":\"1352110219202\",\"status\":0,\"value\":{\"ELEMENT\":\"0\"},\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":604376696}"
},
{
"url" : "/wd/hub/session/1352110219202/buttondown",
"postdata" : "{\"button\":0}",
Expand Down
21 changes: 21 additions & 0 deletions tests/src/commands/testClick.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,28 @@ module.exports = {
test.equals(result.status, 0)
test.done();
});
},

testClickCommandWithXpath : function(test) {
var client = this.client.api;

MockServer.addMock({
"url" : "/wd/hub/session/1352110219202/element/0/click",
"response" : JSON.stringify({
sessionId: "1352110219202",
status:0
})
});

client
.useXpath()
.click('//weblogin', function callback(result) {
test.equals(result.status, 0)
})
.click('css selector', '#weblogin', function callback(result) {
test.equals(result.status, 0)
test.done();
});
},

tearDown : function(callback) {
Expand Down

0 comments on commit e64e03b

Please sign in to comment.