Add JSONWP<>W3C mapping for window/handles endpoint
MODIFY
lib/jsonwp-proxy/proxy.js
lib/jsonwp-proxy/proxy.js
@@ -27,6 +27,13 @@ const COMMAND_URLS_CONFLICTS = [
w3cConverter: (url) => url.replace(/\/screenshot\/([^\/]+)/,
'/element/$1/screenshot'),
},
+ {
+ commandNames: ['getWindowHandles', 'getWindowHandle'],
+ jsonwpConverter: (url) => url.replace(/\/window\/handle(s?)$/,
+ '/window_handle$1'),
+ w3cConverter: (url) => url.replace(/\/window_handle(s?)$/,
+ '/window/handle$1'),
+ },
];
const {MJSONWP, W3C} = BaseDriver.DRIVER_PROTOCOL;

MODIFY
lib/protocol/routes.js
lib/protocol/routes.js
@@ -45,12 +45,22 @@ const METHOD_MAP = {
'/wd/hub/session/:sessionId/timeouts/implicit_wait': {
POST: {command: 'implicitWait', payloadParams: {required: ['ms']}}
},
+ // JSONWP
'/wd/hub/session/:sessionId/window_handle': {
GET: {command: 'getWindowHandle'}
},
+ // W3C
+ '/wd/hub/session/:sessionId/window/handle': {
+ GET: {command: 'getWindowHandle'}
+ },
+ // JSONWP
'/wd/hub/session/:sessionId/window_handles': {
GET: {command: 'getWindowHandles'}
},
+ // W3C
+ '/wd/hub/session/:sessionId/window/handles': {
+ GET: {command: 'getWindowHandles'}
+ },
'/wd/hub/session/:sessionId/url': {
GET: {command: 'getUrl'},
POST: {command: 'setUrl', payloadParams: {required: ['url']}}
@@ -575,9 +585,6 @@ const METHOD_MAP = {
'/wd/hub/session/:sessionId/element/:elementId/rect': {
GET: {command: 'getElementRect'}
},
- '/wd/hub/session/:sessionId/window/handles': {
- GET: {command: 'getWindowHandles'}
- },
'/wd/hub/session/:sessionId/execute/sync': {
POST: {command: 'execute', payloadParams: {required: ['script', 'args']}}
},

MODIFY
test/protocol/routes-specs.js
test/protocol/routes-specs.js
@@ -40,7 +40,7 @@ describe('Protocol', function () {
}
let hash = shasum.digest('hex').substring(0, 8);
// Modify the hash whenever the protocol has intentionally been modified.
- hash.should.equal('b3246014');
+ hash.should.equal('034668ae');
});
});

Add JSONWP<>W3C mapping for window/handles endpoint (#251)