Skip to content

Commit

Permalink
Fixed getElementSize and getLocation commands for w3c webdriver clients
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Oct 11, 2019
1 parent 8ba496c commit fd10c9b
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/transport/webdriver/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ module.exports = lodashMerge({}, JsonWireActions, {
});
},

getElementSize(id) {
return `/element/${id}/rect`;
},

getElementLocation(id) {
return `/element/${id}/rect`;
},

///////////////////////////////////////////////////////////
// Windows
///////////////////////////////////////////////////////////
Expand Down
37 changes: 37 additions & 0 deletions test/src/api/commands/testGetElementSize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const assert = require('assert');
const MockServer = require('../../../lib/mockserver.js');
const Nightwatch = require('../../../lib/nightwatch.js');
const CommandGlobals = require('../../../lib/globals/commands.js');

describe('getElementSize', function() {
Expand Down Expand Up @@ -31,4 +32,40 @@ describe('getElementSize', function() {
this.client.start(done);
});

it('client.getElementSize() with webdriver protocol', function(done) {
Nightwatch.initClient({
selenium : {
version2: false,
start_process: false
},
webdriver:{
start_process: true
},
}).then(client => {
MockServer.addMock({
url: '/session/13521-10219-202/element/5cc459b8-36a8-3042-8b4a-258883ea642b/rect',
method: 'GET',
response: {
value: {
x: 341.5,
y: 340.95001220703125,
width: 683,
height: 60
}
}
}, true);

client.api.getElementSize('#webdriver', function(result) {
assert.deepStrictEqual(result.value, {
x: 341.5,
y: 340.95001220703125,
width: 683,
height: 60
});
});

client.start(done);
});
});

});
37 changes: 37 additions & 0 deletions test/src/api/commands/testGetLocation.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const assert = require('assert');
const MockServer = require('../../../lib/mockserver.js');
const Nightwatch = require('../../../lib/nightwatch.js');
const CommandGlobals = require('../../../lib/globals/commands.js');

describe('getLocation', function() {
Expand Down Expand Up @@ -33,4 +34,40 @@ describe('getLocation', function() {

this.client.start(done);
});

it('client.getLocation() with webdriver protocol', function(done) {
Nightwatch.initClient({
selenium : {
version2: false,
start_process: false
},
webdriver:{
start_process: true
},
}).then(client => {
MockServer.addMock({
url: '/session/13521-10219-202/element/5cc459b8-36a8-3042-8b4a-258883ea642b/rect',
method: 'GET',
response: {
value: {
x: 341.5,
y: 340.95001220703125,
width: 683,
height: 60
}
}
}, true);

client.api.getLocation('#webdriver', function(result) {
assert.deepStrictEqual(result.value, {
x: 341.5,
y: 340.95001220703125,
width: 683,
height: 60
});
});

client.start(done);
});
});
});

0 comments on commit fd10c9b

Please sign in to comment.