From dca0c2c55c61d301d0a0a093eb331d78b27799d8 Mon Sep 17 00:00:00 2001 From: KobeNguyenT <7845001+kobenguyent@users.noreply.github.com> Date: Wed, 3 Jan 2024 13:45:52 +0100 Subject: [PATCH] fix: deprecate some JSON Wire Protocol commands (#4104) --- docs/helpers/WebDriver.md | 4 ++++ lib/helper/WebDriver.js | 14 +++++++++----- test/helper/WebDriver_test.js | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/helpers/WebDriver.md b/docs/helpers/WebDriver.md index f0b40a105..1570f6f89 100644 --- a/docs/helpers/WebDriver.md +++ b/docs/helpers/WebDriver.md @@ -1200,6 +1200,8 @@ Returns **([Promise][25]<DOMRect> | [Promise][25]<[number][22]>)** Element ### grabGeoLocation +This method is **deprecated**. + Return the current geo location Resumes test execution, so **should be used inside async function with `await`** operator. @@ -2018,6 +2020,8 @@ Returns **void** automatically synchronized promise through #recorder ### setGeoLocation +This method is **deprecated**. + Set the current geo location ```js diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index 5da7ce8a1..6fa263b02 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -2448,21 +2448,25 @@ class WebDriver extends Helper { } /** + * This method is **deprecated**. + * + * * {{> setGeoLocation }} */ async setGeoLocation(latitude, longitude, altitude = null) { - if (altitude) { - return this.browser.setGeoLocation({ latitude, longitude }); - } - return this.browser.setGeoLocation({ latitude, longitude, altitude }); + console.log(`setGeoLocation deprecated: + * This command is deprecated due to using deprecated JSON Wire Protocol command. More info: https://webdriver.io/docs/api/jsonwp/#setgeolocation`); } /** + * This method is **deprecated**. + * * {{> grabGeoLocation }} * */ async grabGeoLocation() { - return this.browser.getGeoLocation(); + console.log(`grabGeoLocation deprecated: + * This command is deprecated due to using deprecated JSON Wire Protocol command. More info: https://webdriver.io/docs/api/jsonwp/#getgeolocation`); } /** diff --git a/test/helper/WebDriver_test.js b/test/helper/WebDriver_test.js index d83fedc16..d374aa939 100644 --- a/test/helper/WebDriver_test.js +++ b/test/helper/WebDriver_test.js @@ -1163,7 +1163,8 @@ describe('WebDriver', function () { }); describe('GeoLocation', () => { - it('should set the geoLocation', async () => { + // deprecated JSON Wire method commands + it.skip('should set the geoLocation', async () => { await wd.setGeoLocation(37.4043, -122.0748); const geoLocation = await wd.grabGeoLocation(); assert.equal(geoLocation.latitude, 37.4043, 'The latitude is not properly set');