Skip to content

Commit b343cd2

Browse files
authored
Remove dependency to devtools (#4563)
1 parent df82454 commit b343cd2

12 files changed

+110
-1833
lines changed

docs/helpers/WebDriver.md

+107-258
Large diffs are not rendered by default.

lib/helper/WebDriver.js

+1-182
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ const webRoot = 'body'
7272
* @prop {object} [timeouts] [WebDriver timeouts](http://webdriver.io/docs/timeouts.html) defined as hash.
7373
* @prop {boolean} [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
7474
* @prop {string} [logLevel=silent] - level of logging verbosity. Default: silent. Options: trace | debug | info | warn | error | silent. More info: https://webdriver.io/docs/configuration/#loglevel
75-
* @prop {boolean} [devtoolsProtocol=false] - enable devtools protocol. Default: false. More info: https://webdriver.io/docs/automationProtocols/#devtools-protocol.
7675
*/
7776
const config = {}
7877

@@ -180,7 +179,6 @@ const config = {}
180179
* WebDriver : {
181180
* url: "http://localhost",
182181
* browser: "chrome",
183-
* devtoolsProtocol: true,
184182
* desiredCapabilities: {
185183
* chromeOptions: {
186184
* args: [ "--headless", "--disable-gpu", "--no-sandbox" ]
@@ -614,11 +612,6 @@ class WebDriver extends Helper {
614612
delete this.options.capabilities.hostname
615613
delete this.options.capabilities.port
616614
delete this.options.capabilities.path
617-
if (this.options.devtoolsProtocol) {
618-
if (!['chrome', 'chromium'].includes(this.options.browser.toLowerCase()))
619-
throw Error('The devtools protocol is only working with Chrome or Chromium')
620-
this.options.automationProtocol = 'devtools'
621-
}
622615
this.browser = await webdriverio.remote(this.options)
623616
}
624617
} catch (err) {
@@ -649,11 +642,6 @@ class WebDriver extends Helper {
649642
this.browser.capabilities.platformName = this.browser.capabilities.platformName.toLowerCase()
650643
}
651644

652-
if (this.options.automationProtocol) {
653-
this.puppeteerBrowser = await this.browser.getPuppeteer()
654-
this.page = (await this.puppeteerBrowser.pages())[0]
655-
}
656-
657645
return this.browser
658646
}
659647

@@ -1143,10 +1131,6 @@ class WebDriver extends Helper {
11431131
assertElementExists(res, field, 'Field')
11441132
const elem = usingFirstElement(res)
11451133
highlightActiveElement.call(this, elem)
1146-
if (this.options.automationProtocol) {
1147-
const curentValue = await elem.getValue()
1148-
return elem.setValue(curentValue + value.toString())
1149-
}
11501134
return elem.addValue(value.toString())
11511135
}
11521136

@@ -1159,9 +1143,6 @@ class WebDriver extends Helper {
11591143
assertElementExists(res, field, 'Field')
11601144
const elem = usingFirstElement(res)
11611145
highlightActiveElement.call(this, elem)
1162-
if (this.options.automationProtocol) {
1163-
return elem.setValue('')
1164-
}
11651146
return elem.clearValue(getElementId(elem))
11661147
}
11671148

@@ -1231,7 +1212,7 @@ class WebDriver extends Helper {
12311212
const el = usingFirstElement(res)
12321213

12331214
// Remote Upload (when running Selenium Server)
1234-
if (this.options.remoteFileUpload && !this.options.automationProtocol) {
1215+
if (this.options.remoteFileUpload) {
12351216
try {
12361217
this.debugSection('File', 'Uploading file to remote server')
12371218
file = await this.browser.uploadFile(file)
@@ -2593,9 +2574,6 @@ class WebDriver extends Helper {
25932574
async switchTo(locator) {
25942575
this.browser.isInsideFrame = true
25952576
if (Number.isInteger(locator)) {
2596-
if (this.options.automationProtocol) {
2597-
return this.browser.switchToFrame(locator + 1)
2598-
}
25992577
return this.browser.switchToFrame(locator)
26002578
}
26012579
if (!locator) {
@@ -2734,44 +2712,6 @@ class WebDriver extends Helper {
27342712
return this.executeScript(getScrollPosition)
27352713
}
27362714

2737-
/**
2738-
* This method is **deprecated**.
2739-
*
2740-
*
2741-
* {{> setGeoLocation }}
2742-
*/
2743-
async setGeoLocation(latitude, longitude) {
2744-
if (!this.options.automationProtocol) {
2745-
console.log(`setGeoLocation deprecated:
2746-
* This command is deprecated due to using deprecated JSON Wire Protocol command. More info: https://webdriver.io/docs/api/jsonwp/#setgeolocation
2747-
* Switch to devtools protocol to use this command by setting devtoolsProtocol: true in the configuration`)
2748-
return
2749-
}
2750-
this.geoLocation = { latitude, longitude }
2751-
2752-
await this.browser.call(async () => {
2753-
const pages = await this.puppeteerBrowser.pages()
2754-
await pages[0].setGeolocation({ latitude, longitude })
2755-
})
2756-
}
2757-
2758-
/**
2759-
* This method is **deprecated**.
2760-
*
2761-
* {{> grabGeoLocation }}
2762-
*
2763-
*/
2764-
async grabGeoLocation() {
2765-
if (!this.options.automationProtocol) {
2766-
console.log(`grabGeoLocation deprecated:
2767-
* This command is deprecated due to using deprecated JSON Wire Protocol command. More info: https://webdriver.io/docs/api/jsonwp/#getgeolocation
2768-
* Switch to devtools protocol to use this command by setting devtoolsProtocol: true in the configuration`)
2769-
return
2770-
}
2771-
if (!this.geoLocation) return 'No GeoLocation is set!'
2772-
return this.geoLocation
2773-
}
2774-
27752715
/**
27762716
* {{> grabElementBoundingRect }}
27772717
*/
@@ -2810,127 +2750,6 @@ class WebDriver extends Helper {
28102750
runInWeb(fn) {
28112751
return fn()
28122752
}
2813-
2814-
/**
2815-
*
2816-
* _Note:_ Only works when devtoolsProtocol is enabled.
2817-
*
2818-
* {{> flushNetworkTraffics }}
2819-
*/
2820-
flushNetworkTraffics() {
2821-
if (!this.options.automationProtocol) {
2822-
console.log(
2823-
'* Switch to devtools protocol to use this command by setting devtoolsProtocol: true in the configuration',
2824-
)
2825-
return
2826-
}
2827-
this.requests = []
2828-
}
2829-
2830-
/**
2831-
*
2832-
* _Note:_ Only works when devtoolsProtocol is enabled.
2833-
*
2834-
* {{> stopRecordingTraffic }}
2835-
*/
2836-
stopRecordingTraffic() {
2837-
if (!this.options.automationProtocol) {
2838-
console.log(
2839-
'* Switch to devtools protocol to use this command by setting devtoolsProtocol: true in the configuration',
2840-
)
2841-
return
2842-
}
2843-
this.page.removeAllListeners('request')
2844-
this.recording = false
2845-
}
2846-
2847-
/**
2848-
*
2849-
* _Note:_ Only works when devtoolsProtocol is enabled.
2850-
*
2851-
* {{> startRecordingTraffic }}
2852-
*
2853-
*/
2854-
async startRecordingTraffic() {
2855-
if (!this.options.automationProtocol) {
2856-
console.log(
2857-
'* Switch to devtools protocol to use this command by setting devtoolsProtocol: true in the configuration',
2858-
)
2859-
return
2860-
}
2861-
this.flushNetworkTraffics()
2862-
this.recording = true
2863-
this.recordedAtLeastOnce = true
2864-
2865-
await this.page.setRequestInterception(true)
2866-
2867-
this.page.on('request', (request) => {
2868-
const information = {
2869-
url: request.url(),
2870-
method: request.method(),
2871-
requestHeaders: request.headers(),
2872-
requestPostData: request.postData(),
2873-
response: request.response(),
2874-
}
2875-
2876-
this.debugSection('REQUEST: ', JSON.stringify(information))
2877-
2878-
if (typeof information.requestPostData === 'object') {
2879-
information.requestPostData = JSON.parse(information.requestPostData)
2880-
}
2881-
request.continue()
2882-
this.requests.push(information)
2883-
})
2884-
}
2885-
2886-
/**
2887-
*
2888-
* _Note:_ Only works when devtoolsProtocol is enabled.
2889-
*
2890-
* {{> grabRecordedNetworkTraffics }}
2891-
*/
2892-
async grabRecordedNetworkTraffics() {
2893-
if (!this.options.automationProtocol) {
2894-
console.log(
2895-
'* Switch to devtools protocol to use this command by setting devtoolsProtocol: true in the configuration',
2896-
)
2897-
return
2898-
}
2899-
return grabRecordedNetworkTraffics.call(this)
2900-
}
2901-
2902-
/**
2903-
*
2904-
* _Note:_ Only works when devtoolsProtocol is enabled.
2905-
*
2906-
* {{> seeTraffic }}
2907-
*/
2908-
async seeTraffic({ name, url, parameters, requestPostData, timeout = 10 }) {
2909-
if (!this.options.automationProtocol) {
2910-
console.log(
2911-
'* Switch to devtools protocol to use this command by setting devtoolsProtocol: true in the configuration',
2912-
)
2913-
return
2914-
}
2915-
await seeTraffic.call(this, ...arguments)
2916-
}
2917-
2918-
/**
2919-
*
2920-
* _Note:_ Only works when devtoolsProtocol is enabled.
2921-
*
2922-
* {{> dontSeeTraffic }}
2923-
*
2924-
*/
2925-
dontSeeTraffic({ name, url }) {
2926-
if (!this.options.automationProtocol) {
2927-
console.log(
2928-
'* Switch to devtools protocol to use this command by setting devtoolsProtocol: true in the configuration',
2929-
)
2930-
return
2931-
}
2932-
dontSeeTraffic.call(this, ...arguments)
2933-
}
29342753
}
29352754

29362755
async function proceedSee(assertType, text, context, strict = false) {

lib/plugin/coverage.js

-3
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@ module.exports = function (config) {
143143

144144
const helper = helpers[helperName]
145145

146-
if (helperName === 'WebDriver' && !helper.config.devtoolsProtocol)
147-
throw Error('Coverage is currently supporting the WebDriver running with Devtools protocol.')
148-
149146
const v8Helper = v8CoverageHelpers[helperName]
150147

151148
const coverageOptions = {

package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"test:unit:webbapi:puppeteer": "mocha test/helper/Puppeteer_test.js",
5555
"test:unit:webbapi:webDriver": "mocha test/helper/WebDriver_test.js",
5656
"test:unit:webbapi:webDriver:noSeleniumServer": "mocha test/helper/WebDriver.noSeleniumServer_test.js",
57-
"test:unit:webbapi:webDriver:devtools": "mocha test/helper/WebDriver_devtools_test.js --exit",
5857
"test:unit:webbapi:testCafe": "mocha test/helper/TestCafe_test.js",
5958
"test:unit:expect": "mocha test/helper/Expect_test.js",
6059
"test:plugin": "mocha test/plugin/plugin_test.js",
@@ -90,7 +89,6 @@
9089
"cross-spawn": "7.0.5",
9190
"css-to-xpath": "0.1.0",
9291
"csstoxpath": "1.6.0",
93-
"devtools": "8.40.2",
9492
"envinfo": "7.14.0",
9593
"escape-string-regexp": "4.0.0",
9694
"figures": "3.2.0",
@@ -167,7 +165,7 @@
167165
"typedoc-plugin-markdown": "4.2.10",
168166
"typescript": "5.6.3",
169167
"wdio-docker-service": "1.5.0",
170-
"webdriverio": "8.39.1",
168+
"webdriverio": "8.40.6",
171169
"xml2js": "0.6.2",
172170
"xpath": "0.0.34"
173171
},

test/acceptance/codecept.WebDriver.devtools.coverage.js

-49
This file was deleted.

test/acceptance/codecept.WebDriver.devtools.js

-42
This file was deleted.

test/helper/WebDriver.noSeleniumServer_test.js

-10
Original file line numberDiff line numberDiff line change
@@ -1204,16 +1204,6 @@ describe('WebDriver - No Selenium server started', function () {
12041204
})
12051205
})
12061206

1207-
describe('GeoLocation', () => {
1208-
// deprecated JSON Wire method commands
1209-
it.skip('should set the geoLocation', async () => {
1210-
await wd.setGeoLocation(37.4043, -122.0748)
1211-
const geoLocation = await wd.grabGeoLocation()
1212-
assert.equal(geoLocation.latitude, 37.4043, 'The latitude is not properly set')
1213-
assert.equal(geoLocation.longitude, -122.0748, 'The longitude is not properly set')
1214-
})
1215-
})
1216-
12171207
describe('#grabElementBoundingRect', () => {
12181208
it('should get the element size', async () => {
12191209
await wd.amOnPage('/form/hidden')

0 commit comments

Comments
 (0)