@@ -1197,14 +1197,25 @@ class WebDriver {
11971197 * @return {!Promise<resolved> } A new CDP instance.
11981198 */
11991199 async createCDPConnection ( target ) {
1200+ let debuggerUrl = null
1201+
12001202 const caps = await this . getCapabilities ( )
1201- const seCdp = caps [ 'map_' ] . get ( 'se:cdp' )
1202- const vendorInfo =
1203- caps [ 'map_' ] . get ( this . VENDOR_COMMAND_PREFIX + ':chromeOptions' ) ||
1204- caps [ 'map_' ] . get ( this . VENDOR_CAPABILITY_PREFIX + ':edgeOptions' ) ||
1205- caps [ 'map_' ] . get ( 'moz:debuggerAddress' ) ||
1206- new Map ( )
1207- const debuggerUrl = seCdp || vendorInfo [ 'debuggerAddress' ] || vendorInfo
1203+
1204+ if ( process . env . SELENIUM_REMOTE_URL ) {
1205+ const host = new URL ( process . env . SELENIUM_REMOTE_URL ) . host
1206+ const sessionId = await this . getSession ( ) . then ( ( session ) =>
1207+ session . getId ( )
1208+ )
1209+ debuggerUrl = `ws://${ host } /session/${ sessionId } /se/cdp`
1210+ } else {
1211+ const seCdp = caps [ 'map_' ] . get ( 'se:cdp' )
1212+ const vendorInfo =
1213+ caps [ 'map_' ] . get ( this . VENDOR_COMMAND_PREFIX + ':chromeOptions' ) ||
1214+ caps [ 'map_' ] . get ( this . VENDOR_CAPABILITY_PREFIX + ':edgeOptions' ) ||
1215+ caps [ 'map_' ] . get ( 'moz:debuggerAddress' ) ||
1216+ new Map ( )
1217+ debuggerUrl = seCdp || vendorInfo [ 'debuggerAddress' ] || vendorInfo
1218+ }
12081219 this . _wsUrl = await this . getWsUrl ( debuggerUrl , target , caps )
12091220 return new Promise ( ( resolve , reject ) => {
12101221 try {
@@ -1945,14 +1956,10 @@ class Window {
19451956 * @return {!Promise<{x: number, y: number, width: number, height: number}> }
19461957 * A promise that will resolve to the window rect of the current window.
19471958 */
1948- async getRect ( ) {
1949- try {
1950- return await this . driver_ . execute (
1951- new command . Command ( command . Name . GET_WINDOW_RECT )
1952- )
1953- } catch ( ex ) {
1954- throw ex
1955- }
1959+ getRect ( ) {
1960+ return this . driver_ . execute (
1961+ new command . Command ( command . Name . GET_WINDOW_RECT )
1962+ )
19561963 }
19571964
19581965 /**
@@ -1969,19 +1976,15 @@ class Window {
19691976 * A promise that will resolve to the current window's updated window
19701977 * rect.
19711978 */
1972- async setRect ( { x, y, width, height } ) {
1973- try {
1974- return await this . driver_ . execute (
1975- new command . Command ( command . Name . SET_WINDOW_RECT ) . setParameters ( {
1976- x,
1977- y,
1978- width,
1979- height,
1980- } )
1981- )
1982- } catch ( ex ) {
1983- throw ex
1984- }
1979+ setRect ( { x, y, width, height } ) {
1980+ return this . driver_ . execute (
1981+ new command . Command ( command . Name . SET_WINDOW_RECT ) . setParameters ( {
1982+ x,
1983+ y,
1984+ width,
1985+ height,
1986+ } )
1987+ )
19851988 }
19861989
19871990 /**
@@ -2544,7 +2547,10 @@ class WebElement {
25442547 keys . join ( '' )
25452548 )
25462549 } catch ( ex ) {
2547- console . log ( 'Error trying parse string as a file with file detector; sending keys instead' + ex )
2550+ console . log (
2551+ 'Error trying parse string as a file with file detector; sending keys instead' +
2552+ ex
2553+ )
25482554 }
25492555
25502556 return this . execute_ (
@@ -2715,14 +2721,8 @@ class WebElement {
27152721 * @return {!Promise<{width: number, height: number, x: number, y: number}> }
27162722 * A promise that will resolve with the element's rect.
27172723 */
2718- async getRect ( ) {
2719- try {
2720- return await this . execute_ (
2721- new command . Command ( command . Name . GET_ELEMENT_RECT )
2722- )
2723- } catch ( err ) {
2724- throw err ;
2725- }
2724+ getRect ( ) {
2725+ return this . execute_ ( new command . Command ( command . Name . GET_ELEMENT_RECT ) )
27262726 }
27272727
27282728 /**
0 commit comments