@@ -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 */
7776const 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
29362755async function proceedSee ( assertType , text , context , strict = false ) {
0 commit comments