@@ -38,6 +38,7 @@ const path = require('path')
3838const { NoSuchElementError } = require ( './error' )
3939const cdpTargets = [ 'page' , 'browser' ]
4040const Credential = require ( './virtual_authenticator' ) . Credential
41+ const webElement = require ( './webelement' )
4142
4243// Capability names that are defined in the W3C spec.
4344const W3C_CAPABILITY_NAMES = new Set ( [
@@ -618,17 +619,17 @@ class IWebDriver {
618619 * Takes a PDF of the current page. The driver makes a best effort to
619620 * return a PDF based on the provided parameters.
620621 *
621- * @param {{orientation: (string|undefined),
622- * scale: (number|undefined),
623- * background: (boolean|undefined)
624- * width: (number|undefined)
625- * height: (number|undefined)
626- * top: (number|undefined)
627- * bottom: (number|undefined)
628- * left: (number|undefined)
629- * right: (number|undefined)
630- * shrinkToFit: (boolean|undefined)
631- * pageRanges: (< Array> |undefined)}} options.
622+ * @param {{orientation:(string|undefined),
623+ * scale:(number|undefined),
624+ * background:(boolean|undefined),
625+ * width:(number|undefined),
626+ * height:(number|undefined),
627+ * top:(number|undefined),
628+ * bottom:(number|undefined),
629+ * left:(number|undefined),
630+ * right:(number|undefined),
631+ * shrinkToFit:(boolean|undefined),
632+ * pageRanges:( Array|undefined)}} options
632633 */
633634 printPage ( options ) { } // eslint-disable-line
634635}
@@ -2382,7 +2383,7 @@ class TargetLocator {
23822383
23832384const LEGACY_ELEMENT_ID_KEY = 'ELEMENT'
23842385const ELEMENT_ID_KEY = 'element-6066-11e4-a52e-4f735466cecf'
2385- const SHADOWROOT_ID_KEY = 'shadow-6066-11e4-a52e-4f735466cecf'
2386+ const SHADOW_ROOT_ID_KEY = 'shadow-6066-11e4-a52e-4f735466cecf'
23862387
23872388/**
23882389 * Represents a DOM element. WebElements can be found by searching from the
@@ -2427,27 +2428,15 @@ class WebElement {
24272428 * @throws {TypeError } if the object is not a valid encoded ID.
24282429 */
24292430 static extractId ( obj ) {
2430- if ( obj && typeof obj === 'object' ) {
2431- if ( typeof obj [ ELEMENT_ID_KEY ] === 'string' ) {
2432- return obj [ ELEMENT_ID_KEY ]
2433- } else if ( typeof obj [ LEGACY_ELEMENT_ID_KEY ] === 'string' ) {
2434- return obj [ LEGACY_ELEMENT_ID_KEY ]
2435- }
2436- }
2437- throw new TypeError ( 'object is not a WebElement ID' )
2431+ return webElement . extractId ( obj )
24382432 }
24392433
24402434 /**
24412435 * @param {? } obj the object to test.
24422436 * @return {boolean } whether the object is a valid encoded WebElement ID.
24432437 */
24442438 static isId ( obj ) {
2445- return (
2446- obj &&
2447- typeof obj === 'object' &&
2448- ( typeof obj [ ELEMENT_ID_KEY ] === 'string' ||
2449- typeof obj [ LEGACY_ELEMENT_ID_KEY ] === 'string' )
2450- )
2439+ return webElement . isId ( obj )
24512440 }
24522441
24532442 /**
@@ -2992,8 +2981,8 @@ class ShadowRoot {
29922981 */
29932982 static extractId ( obj ) {
29942983 if ( obj && typeof obj === 'object' ) {
2995- if ( typeof obj [ SHADOWROOT_ID_KEY ] === 'string' ) {
2996- return obj [ SHADOWROOT_ID_KEY ]
2984+ if ( typeof obj [ SHADOW_ROOT_ID_KEY ] === 'string' ) {
2985+ return obj [ SHADOW_ROOT_ID_KEY ]
29972986 }
29982987 }
29992988 throw new TypeError ( 'object is not a ShadowRoot ID' )
@@ -3007,7 +2996,7 @@ class ShadowRoot {
30072996 return (
30082997 obj &&
30092998 typeof obj === 'object' &&
3010- typeof obj [ SHADOWROOT_ID_KEY ] === 'string'
2999+ typeof obj [ SHADOW_ROOT_ID_KEY ] === 'string'
30113000 )
30123001 }
30133002
0 commit comments