@@ -1197,14 +1197,25 @@ class WebDriver {
1197
1197
* @return {!Promise<resolved> } A new CDP instance.
1198
1198
*/
1199
1199
async createCDPConnection ( target ) {
1200
+ let debuggerUrl = null
1201
+
1200
1202
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
+ }
1208
1219
this . _wsUrl = await this . getWsUrl ( debuggerUrl , target , caps )
1209
1220
return new Promise ( ( resolve , reject ) => {
1210
1221
try {
@@ -1945,14 +1956,10 @@ class Window {
1945
1956
* @return {!Promise<{x: number, y: number, width: number, height: number}> }
1946
1957
* A promise that will resolve to the window rect of the current window.
1947
1958
*/
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
+ )
1956
1963
}
1957
1964
1958
1965
/**
@@ -1969,19 +1976,15 @@ class Window {
1969
1976
* A promise that will resolve to the current window's updated window
1970
1977
* rect.
1971
1978
*/
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
+ )
1985
1988
}
1986
1989
1987
1990
/**
@@ -2544,7 +2547,10 @@ class WebElement {
2544
2547
keys . join ( '' )
2545
2548
)
2546
2549
} 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
+ )
2548
2554
}
2549
2555
2550
2556
return this . execute_ (
@@ -2715,14 +2721,8 @@ class WebElement {
2715
2721
* @return {!Promise<{width: number, height: number, x: number, y: number}> }
2716
2722
* A promise that will resolve with the element's rect.
2717
2723
*/
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 ) )
2726
2726
}
2727
2727
2728
2728
/**
0 commit comments