selenium-webdriver 4.17.0 → 4.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +236 -196
- package/bidi/addInterceptParameters.js +86 -0
- package/bidi/browsingContext.js +144 -37
- package/bidi/browsingContextInspector.js +13 -40
- package/bidi/evaluateResult.js +4 -10
- package/bidi/filterBy.js +2 -6
- package/bidi/index.js +31 -29
- package/bidi/input.js +1 -4
- package/bidi/interceptPhase.js +24 -0
- package/bidi/logInspector.js +15 -20
- package/bidi/network.js +178 -0
- package/bidi/networkInspector.js +8 -2
- package/bidi/networkTypes.js +22 -49
- package/bidi/protocolType.js +3 -9
- package/bidi/protocolValue.js +6 -25
- package/bidi/realmInfo.js +2 -10
- package/bidi/scriptManager.js +20 -59
- package/bidi/urlPattern.js +58 -0
- package/bin/linux/selenium-manager +0 -0
- package/bin/macos/selenium-manager +0 -0
- package/bin/windows/selenium-manager.exe +0 -0
- package/chrome.js +1 -8
- package/chromium.js +27 -109
- package/common/driverFinder.js +1 -1
- package/common/seleniumManager.js +9 -18
- package/devtools/CDPConnection.js +1 -3
- package/edge.js +1 -3
- package/example/chrome_android.js +2 -5
- package/example/chrome_mobile_emulation.js +2 -4
- package/example/google_search.js +1 -3
- package/example/headless.js +4 -10
- package/example/logging.js +3 -9
- package/firefox.js +55 -109
- package/http/index.js +7 -10
- package/ie.js +5 -15
- package/index.js +7 -29
- package/io/exec.js +1 -2
- package/io/index.js +3 -3
- package/io/zip.js +8 -30
- package/lib/by.js +2 -9
- package/lib/capabilities.js +3 -9
- package/lib/command.js +3 -3
- package/lib/error.js +2 -9
- package/lib/http.js +34 -131
- package/lib/input.js +10 -34
- package/lib/logging.js +3 -11
- package/lib/promise.js +2 -7
- package/lib/select.js +3 -9
- package/lib/until.js +28 -49
- package/lib/util.js +1 -4
- package/lib/virtual_authenticator.js +4 -22
- package/lib/webdriver.js +118 -297
- package/lib/webelement.js +1 -5
- package/net/index.js +1 -4
- package/package.json +2 -1
- package/remote/index.js +9 -24
- package/remote/util.js +6 -19
- package/safari.js +3 -8
- package/testing/index.js +6 -11
package/lib/webdriver.js
CHANGED
|
@@ -42,7 +42,7 @@ const webElement = require('./webelement')
|
|
|
42
42
|
const { isObject } = require('./util')
|
|
43
43
|
const BIDI = require('../bidi')
|
|
44
44
|
const { PinnedScript } = require('./pinnedScript')
|
|
45
|
-
const JSZip = require('jszip')
|
|
45
|
+
const JSZip = require('jszip')
|
|
46
46
|
|
|
47
47
|
// Capability names that are defined in the W3C spec.
|
|
48
48
|
const W3C_CAPABILITY_NAMES = new Set([
|
|
@@ -148,11 +148,7 @@ async function toWireValue(obj) {
|
|
|
148
148
|
return value
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
if (
|
|
152
|
-
typeof value === 'boolean' ||
|
|
153
|
-
typeof value === 'number' ||
|
|
154
|
-
typeof value === 'string'
|
|
155
|
-
) {
|
|
151
|
+
if (typeof value === 'boolean' || typeof value === 'number' || typeof value === 'string') {
|
|
156
152
|
return value
|
|
157
153
|
}
|
|
158
154
|
|
|
@@ -236,9 +232,7 @@ function fromWireValue(driver, value) {
|
|
|
236
232
|
* @return {string} The resolved message
|
|
237
233
|
*/
|
|
238
234
|
function resolveWaitMessage(message) {
|
|
239
|
-
return message
|
|
240
|
-
? `${typeof message === 'function' ? message() : message}\n`
|
|
241
|
-
: ''
|
|
235
|
+
return message ? `${typeof message === 'function' ? message() : message}\n` : ''
|
|
242
236
|
}
|
|
243
237
|
|
|
244
238
|
/**
|
|
@@ -776,8 +770,8 @@ class WebDriver {
|
|
|
776
770
|
this.session_ = Promise.reject(
|
|
777
771
|
new error.NoSuchSessionError(
|
|
778
772
|
'This driver instance does not have a valid session ID ' +
|
|
779
|
-
'(did you call WebDriver.quit()?) and may no longer be used.'
|
|
780
|
-
)
|
|
773
|
+
'(did you call WebDriver.quit()?) and may no longer be used.',
|
|
774
|
+
),
|
|
781
775
|
)
|
|
782
776
|
|
|
783
777
|
// Only want the session rejection to bubble if accessed.
|
|
@@ -804,14 +798,12 @@ class WebDriver {
|
|
|
804
798
|
return this.execute(
|
|
805
799
|
new command.Command(command.Name.EXECUTE_SCRIPT)
|
|
806
800
|
.setParameter('script', script.executionScript())
|
|
807
|
-
.setParameter('args', args)
|
|
801
|
+
.setParameter('args', args),
|
|
808
802
|
)
|
|
809
803
|
}
|
|
810
804
|
|
|
811
805
|
return this.execute(
|
|
812
|
-
new command.Command(command.Name.EXECUTE_SCRIPT)
|
|
813
|
-
.setParameter('script', script)
|
|
814
|
-
.setParameter('args', args)
|
|
806
|
+
new command.Command(command.Name.EXECUTE_SCRIPT).setParameter('script', script).setParameter('args', args),
|
|
815
807
|
)
|
|
816
808
|
}
|
|
817
809
|
|
|
@@ -825,14 +817,12 @@ class WebDriver {
|
|
|
825
817
|
return this.execute(
|
|
826
818
|
new command.Command(command.Name.EXECUTE_ASYNC_SCRIPT)
|
|
827
819
|
.setParameter('script', script.executionScript())
|
|
828
|
-
.setParameter('args', args)
|
|
820
|
+
.setParameter('args', args),
|
|
829
821
|
)
|
|
830
822
|
}
|
|
831
823
|
|
|
832
824
|
return this.execute(
|
|
833
|
-
new command.Command(command.Name.EXECUTE_ASYNC_SCRIPT)
|
|
834
|
-
.setParameter('script', script)
|
|
835
|
-
.setParameter('args', args)
|
|
825
|
+
new command.Command(command.Name.EXECUTE_ASYNC_SCRIPT).setParameter('script', script).setParameter('args', args),
|
|
836
826
|
)
|
|
837
827
|
}
|
|
838
828
|
|
|
@@ -860,20 +850,14 @@ class WebDriver {
|
|
|
860
850
|
let timeoutMessage = resolveWaitMessage(message)
|
|
861
851
|
reject(
|
|
862
852
|
new error.TimeoutError(
|
|
863
|
-
`${timeoutMessage}Timed out waiting for promise to resolve after ${
|
|
864
|
-
|
|
865
|
-
}ms`
|
|
866
|
-
)
|
|
853
|
+
`${timeoutMessage}Timed out waiting for promise to resolve after ${Date.now() - start}ms`,
|
|
854
|
+
),
|
|
867
855
|
)
|
|
868
856
|
} catch (ex) {
|
|
869
857
|
reject(
|
|
870
858
|
new error.TimeoutError(
|
|
871
|
-
`${
|
|
872
|
-
|
|
873
|
-
}\nTimed out waiting for promise to resolve after ${
|
|
874
|
-
Date.now() - start
|
|
875
|
-
}ms`
|
|
876
|
-
)
|
|
859
|
+
`${ex.message}\nTimed out waiting for promise to resolve after ${Date.now() - start}ms`,
|
|
860
|
+
),
|
|
877
861
|
)
|
|
878
862
|
}
|
|
879
863
|
}, timeout)
|
|
@@ -887,7 +871,7 @@ class WebDriver {
|
|
|
887
871
|
function (error) {
|
|
888
872
|
clearTimer()
|
|
889
873
|
reject(error)
|
|
890
|
-
}
|
|
874
|
+
},
|
|
891
875
|
)
|
|
892
876
|
})
|
|
893
877
|
}
|
|
@@ -899,10 +883,7 @@ class WebDriver {
|
|
|
899
883
|
}
|
|
900
884
|
|
|
901
885
|
if (typeof fn !== 'function') {
|
|
902
|
-
throw TypeError(
|
|
903
|
-
'Wait condition must be a promise-like object, function, or a ' +
|
|
904
|
-
'Condition object'
|
|
905
|
-
)
|
|
886
|
+
throw TypeError('Wait condition must be a promise-like object, function, or a ' + 'Condition object')
|
|
906
887
|
}
|
|
907
888
|
|
|
908
889
|
const driver = this
|
|
@@ -926,17 +907,9 @@ class WebDriver {
|
|
|
926
907
|
} else if (timeout && elapsed >= timeout) {
|
|
927
908
|
try {
|
|
928
909
|
let timeoutMessage = resolveWaitMessage(message)
|
|
929
|
-
reject(
|
|
930
|
-
new error.TimeoutError(
|
|
931
|
-
`${timeoutMessage}Wait timed out after ${elapsed}ms`
|
|
932
|
-
)
|
|
933
|
-
)
|
|
910
|
+
reject(new error.TimeoutError(`${timeoutMessage}Wait timed out after ${elapsed}ms`))
|
|
934
911
|
} catch (ex) {
|
|
935
|
-
reject(
|
|
936
|
-
new error.TimeoutError(
|
|
937
|
-
`${ex.message}\nWait timed out after ${elapsed}ms`
|
|
938
|
-
)
|
|
939
|
-
)
|
|
912
|
+
reject(new error.TimeoutError(`${ex.message}\nWait timed out after ${elapsed}ms`))
|
|
940
913
|
}
|
|
941
914
|
} else {
|
|
942
915
|
setTimeout(pollCondition, pollTimeout)
|
|
@@ -952,12 +925,11 @@ class WebDriver {
|
|
|
952
925
|
result.then(function (value) {
|
|
953
926
|
if (!(value instanceof WebElement)) {
|
|
954
927
|
throw TypeError(
|
|
955
|
-
'WebElementCondition did not resolve to a WebElement: ' +
|
|
956
|
-
Object.prototype.toString.call(value)
|
|
928
|
+
'WebElementCondition did not resolve to a WebElement: ' + Object.prototype.toString.call(value),
|
|
957
929
|
)
|
|
958
930
|
}
|
|
959
931
|
return value
|
|
960
|
-
})
|
|
932
|
+
}),
|
|
961
933
|
)
|
|
962
934
|
}
|
|
963
935
|
return result
|
|
@@ -970,9 +942,7 @@ class WebDriver {
|
|
|
970
942
|
|
|
971
943
|
/** @override */
|
|
972
944
|
getWindowHandle() {
|
|
973
|
-
return this.execute(
|
|
974
|
-
new command.Command(command.Name.GET_CURRENT_WINDOW_HANDLE)
|
|
975
|
-
)
|
|
945
|
+
return this.execute(new command.Command(command.Name.GET_CURRENT_WINDOW_HANDLE))
|
|
976
946
|
}
|
|
977
947
|
|
|
978
948
|
/** @override */
|
|
@@ -1011,9 +981,7 @@ class WebDriver {
|
|
|
1011
981
|
let cmd = null
|
|
1012
982
|
|
|
1013
983
|
if (locator instanceof RelativeBy) {
|
|
1014
|
-
cmd = new command.Command(
|
|
1015
|
-
command.Name.FIND_ELEMENTS_RELATIVE
|
|
1016
|
-
).setParameter('args', locator.marshall())
|
|
984
|
+
cmd = new command.Command(command.Name.FIND_ELEMENTS_RELATIVE).setParameter('args', locator.marshall())
|
|
1017
985
|
} else {
|
|
1018
986
|
locator = by.checkedLocator(locator)
|
|
1019
987
|
}
|
|
@@ -1042,9 +1010,7 @@ class WebDriver {
|
|
|
1042
1010
|
async normalize_(webElementPromise) {
|
|
1043
1011
|
let result = await webElementPromise
|
|
1044
1012
|
if (result.length === 0) {
|
|
1045
|
-
throw new NoSuchElementError(
|
|
1046
|
-
'Cannot locate an element with provided parameters'
|
|
1047
|
-
)
|
|
1013
|
+
throw new NoSuchElementError('Cannot locate an element with provided parameters')
|
|
1048
1014
|
} else {
|
|
1049
1015
|
return result[0]
|
|
1050
1016
|
}
|
|
@@ -1072,9 +1038,7 @@ class WebDriver {
|
|
|
1072
1038
|
async findElements(locator) {
|
|
1073
1039
|
let cmd = null
|
|
1074
1040
|
if (locator instanceof RelativeBy) {
|
|
1075
|
-
cmd = new command.Command(
|
|
1076
|
-
command.Name.FIND_ELEMENTS_RELATIVE
|
|
1077
|
-
).setParameter('args', locator.marshall())
|
|
1041
|
+
cmd = new command.Command(command.Name.FIND_ELEMENTS_RELATIVE).setParameter('args', locator.marshall())
|
|
1078
1042
|
} else {
|
|
1079
1043
|
locator = by.checkedLocator(locator)
|
|
1080
1044
|
}
|
|
@@ -1216,9 +1180,7 @@ class WebDriver {
|
|
|
1216
1180
|
let self = this
|
|
1217
1181
|
resultObj = self.validatePrintPageParams(keys, params)
|
|
1218
1182
|
|
|
1219
|
-
return this.execute(
|
|
1220
|
-
new command.Command(command.Name.PRINT_PAGE).setParameters(resultObj)
|
|
1221
|
-
)
|
|
1183
|
+
return this.execute(new command.Command(command.Name.PRINT_PAGE).setParameters(resultObj))
|
|
1222
1184
|
}
|
|
1223
1185
|
|
|
1224
1186
|
/**
|
|
@@ -1232,9 +1194,7 @@ class WebDriver {
|
|
|
1232
1194
|
|
|
1233
1195
|
if (process.env.SELENIUM_REMOTE_URL) {
|
|
1234
1196
|
const host = new URL(process.env.SELENIUM_REMOTE_URL).host
|
|
1235
|
-
const sessionId = await this.getSession().then((session) =>
|
|
1236
|
-
session.getId()
|
|
1237
|
-
)
|
|
1197
|
+
const sessionId = await this.getSession().then((session) => session.getId())
|
|
1238
1198
|
debuggerUrl = `ws://${host}/session/${sessionId}/se/cdp`
|
|
1239
1199
|
} else {
|
|
1240
1200
|
const seCdp = caps['map_'].get('se:cdp')
|
|
@@ -1248,9 +1208,7 @@ class WebDriver {
|
|
|
1248
1208
|
this._wsUrl = await this.getWsUrl(debuggerUrl, target, caps)
|
|
1249
1209
|
return new Promise((resolve, reject) => {
|
|
1250
1210
|
try {
|
|
1251
|
-
this._wsConnection = new WebSocket(
|
|
1252
|
-
this._wsUrl.replace('localhost', '127.0.0.1')
|
|
1253
|
-
)
|
|
1211
|
+
this._wsConnection = new WebSocket(this._wsUrl.replace('localhost', '127.0.0.1'))
|
|
1254
1212
|
this._cdpConnection = new cdp.CdpConnection(this._wsConnection)
|
|
1255
1213
|
} catch (err) {
|
|
1256
1214
|
reject(err)
|
|
@@ -1269,11 +1227,7 @@ class WebDriver {
|
|
|
1269
1227
|
const page = targets.find((info) => info.type === 'page')
|
|
1270
1228
|
if (page) {
|
|
1271
1229
|
this.targetID = page.targetId
|
|
1272
|
-
this._cdpConnection.execute(
|
|
1273
|
-
'Target.attachToTarget',
|
|
1274
|
-
{ targetId: this.targetID, flatten: true },
|
|
1275
|
-
null
|
|
1276
|
-
)
|
|
1230
|
+
this._cdpConnection.execute('Target.attachToTarget', { targetId: this.targetID, flatten: true }, null)
|
|
1277
1231
|
} else {
|
|
1278
1232
|
reject('Unable to find Page target.')
|
|
1279
1233
|
}
|
|
@@ -1325,10 +1279,7 @@ class WebDriver {
|
|
|
1325
1279
|
let path
|
|
1326
1280
|
if (target === 'page' && caps['map_'].get('browserName') !== 'firefox') {
|
|
1327
1281
|
path = '/json'
|
|
1328
|
-
} else if (
|
|
1329
|
-
target === 'page' &&
|
|
1330
|
-
caps['map_'].get('browserName') === 'firefox'
|
|
1331
|
-
) {
|
|
1282
|
+
} else if (target === 'page' && caps['map_'].get('browserName') === 'firefox') {
|
|
1332
1283
|
path = '/json/list'
|
|
1333
1284
|
} else {
|
|
1334
1285
|
path = '/json/version'
|
|
@@ -1380,14 +1331,14 @@ class WebDriver {
|
|
|
1380
1331
|
{
|
|
1381
1332
|
handleAuthRequests: true,
|
|
1382
1333
|
},
|
|
1383
|
-
null
|
|
1334
|
+
null,
|
|
1384
1335
|
)
|
|
1385
1336
|
await connection.execute(
|
|
1386
1337
|
'Network.setCacheDisabled',
|
|
1387
1338
|
{
|
|
1388
1339
|
cacheDisabled: true,
|
|
1389
1340
|
},
|
|
1390
|
-
null
|
|
1341
|
+
null,
|
|
1391
1342
|
)
|
|
1392
1343
|
}
|
|
1393
1344
|
|
|
@@ -1425,7 +1376,7 @@ class WebDriver {
|
|
|
1425
1376
|
{
|
|
1426
1377
|
cacheDisabled: true,
|
|
1427
1378
|
},
|
|
1428
|
-
null
|
|
1379
|
+
null,
|
|
1429
1380
|
)
|
|
1430
1381
|
}
|
|
1431
1382
|
/**
|
|
@@ -1501,7 +1452,7 @@ class WebDriver {
|
|
|
1501
1452
|
{
|
|
1502
1453
|
name: '__webdriver_attribute',
|
|
1503
1454
|
},
|
|
1504
|
-
null
|
|
1455
|
+
null,
|
|
1505
1456
|
)
|
|
1506
1457
|
|
|
1507
1458
|
let mutationListener = ''
|
|
@@ -1509,18 +1460,10 @@ class WebDriver {
|
|
|
1509
1460
|
// Depending on what is running the code it could appear in 2 different places which is why we try
|
|
1510
1461
|
// here and then the other location
|
|
1511
1462
|
mutationListener = fs
|
|
1512
|
-
.readFileSync(
|
|
1513
|
-
'./javascript/node/selenium-webdriver/lib/atoms/mutation-listener.js',
|
|
1514
|
-
'utf-8'
|
|
1515
|
-
)
|
|
1463
|
+
.readFileSync('./javascript/node/selenium-webdriver/lib/atoms/mutation-listener.js', 'utf-8')
|
|
1516
1464
|
.toString()
|
|
1517
1465
|
} catch {
|
|
1518
|
-
mutationListener = fs
|
|
1519
|
-
.readFileSync(
|
|
1520
|
-
path.resolve(__dirname, './atoms/mutation-listener.js'),
|
|
1521
|
-
'utf-8'
|
|
1522
|
-
)
|
|
1523
|
-
.toString()
|
|
1466
|
+
mutationListener = fs.readFileSync(path.resolve(__dirname, './atoms/mutation-listener.js'), 'utf-8').toString()
|
|
1524
1467
|
}
|
|
1525
1468
|
|
|
1526
1469
|
this.executeScript(mutationListener)
|
|
@@ -1530,7 +1473,7 @@ class WebDriver {
|
|
|
1530
1473
|
{
|
|
1531
1474
|
source: mutationListener,
|
|
1532
1475
|
},
|
|
1533
|
-
null
|
|
1476
|
+
null,
|
|
1534
1477
|
)
|
|
1535
1478
|
|
|
1536
1479
|
this._wsConnection.on('message', async (message) => {
|
|
@@ -1572,15 +1515,12 @@ class WebDriver {
|
|
|
1572
1515
|
{
|
|
1573
1516
|
expression: pinnedScript.creationScript(),
|
|
1574
1517
|
},
|
|
1575
|
-
null
|
|
1518
|
+
null,
|
|
1576
1519
|
)
|
|
1577
1520
|
|
|
1578
|
-
let result = await connection.send(
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
source: pinnedScript.creationScript(),
|
|
1582
|
-
}
|
|
1583
|
-
)
|
|
1521
|
+
let result = await connection.send('Page.addScriptToEvaluateOnNewDocument', {
|
|
1522
|
+
source: pinnedScript.creationScript(),
|
|
1523
|
+
})
|
|
1584
1524
|
|
|
1585
1525
|
pinnedScript.scriptId = result['result']['identifier']
|
|
1586
1526
|
|
|
@@ -1609,7 +1549,7 @@ class WebDriver {
|
|
|
1609
1549
|
{
|
|
1610
1550
|
expression: script.removalScript(),
|
|
1611
1551
|
},
|
|
1612
|
-
null
|
|
1552
|
+
null,
|
|
1613
1553
|
)
|
|
1614
1554
|
|
|
1615
1555
|
await connection.execute(
|
|
@@ -1617,7 +1557,7 @@ class WebDriver {
|
|
|
1617
1557
|
{
|
|
1618
1558
|
identifier: script.scriptId,
|
|
1619
1559
|
},
|
|
1620
|
-
null
|
|
1560
|
+
null,
|
|
1621
1561
|
)
|
|
1622
1562
|
|
|
1623
1563
|
delete this.pinnedScripts_[script.handle]
|
|
@@ -1638,9 +1578,7 @@ class WebDriver {
|
|
|
1638
1578
|
*/
|
|
1639
1579
|
async addVirtualAuthenticator(options) {
|
|
1640
1580
|
this.authenticatorId_ = await this.execute(
|
|
1641
|
-
new command.Command(command.Name.ADD_VIRTUAL_AUTHENTICATOR).setParameters(
|
|
1642
|
-
options.toDict()
|
|
1643
|
-
)
|
|
1581
|
+
new command.Command(command.Name.ADD_VIRTUAL_AUTHENTICATOR).setParameters(options.toDict()),
|
|
1644
1582
|
)
|
|
1645
1583
|
}
|
|
1646
1584
|
|
|
@@ -1650,9 +1588,10 @@ class WebDriver {
|
|
|
1650
1588
|
*/
|
|
1651
1589
|
async removeVirtualAuthenticator() {
|
|
1652
1590
|
await this.execute(
|
|
1653
|
-
new command.Command(
|
|
1654
|
-
|
|
1655
|
-
|
|
1591
|
+
new command.Command(command.Name.REMOVE_VIRTUAL_AUTHENTICATOR).setParameter(
|
|
1592
|
+
'authenticatorId',
|
|
1593
|
+
this.authenticatorId_,
|
|
1594
|
+
),
|
|
1656
1595
|
)
|
|
1657
1596
|
this.authenticatorId_ = null
|
|
1658
1597
|
}
|
|
@@ -1664,9 +1603,7 @@ class WebDriver {
|
|
|
1664
1603
|
async addCredential(credential) {
|
|
1665
1604
|
credential = credential.toDict()
|
|
1666
1605
|
credential['authenticatorId'] = this.authenticatorId_
|
|
1667
|
-
await this.execute(
|
|
1668
|
-
new command.Command(command.Name.ADD_CREDENTIAL).setParameters(credential)
|
|
1669
|
-
)
|
|
1606
|
+
await this.execute(new command.Command(command.Name.ADD_CREDENTIAL).setParameters(credential))
|
|
1670
1607
|
}
|
|
1671
1608
|
|
|
1672
1609
|
/**
|
|
@@ -1675,10 +1612,7 @@ class WebDriver {
|
|
|
1675
1612
|
*/
|
|
1676
1613
|
async getCredentials() {
|
|
1677
1614
|
let credential_data = await this.execute(
|
|
1678
|
-
new command.Command(command.Name.GET_CREDENTIALS).setParameter(
|
|
1679
|
-
'authenticatorId',
|
|
1680
|
-
this.virtualAuthenticatorId()
|
|
1681
|
-
)
|
|
1615
|
+
new command.Command(command.Name.GET_CREDENTIALS).setParameter('authenticatorId', this.virtualAuthenticatorId()),
|
|
1682
1616
|
)
|
|
1683
1617
|
var credential_list = []
|
|
1684
1618
|
for (var i = 0; i < credential_data.length; i++) {
|
|
@@ -1700,7 +1634,7 @@ class WebDriver {
|
|
|
1700
1634
|
await this.execute(
|
|
1701
1635
|
new command.Command(command.Name.REMOVE_CREDENTIAL)
|
|
1702
1636
|
.setParameter('credentialId', credential_id)
|
|
1703
|
-
.setParameter('authenticatorId', this.authenticatorId_)
|
|
1637
|
+
.setParameter('authenticatorId', this.authenticatorId_),
|
|
1704
1638
|
)
|
|
1705
1639
|
}
|
|
1706
1640
|
|
|
@@ -1709,10 +1643,7 @@ class WebDriver {
|
|
|
1709
1643
|
*/
|
|
1710
1644
|
async removeAllCredentials() {
|
|
1711
1645
|
await this.execute(
|
|
1712
|
-
new command.Command(command.Name.REMOVE_ALL_CREDENTIALS).setParameter(
|
|
1713
|
-
'authenticatorId',
|
|
1714
|
-
this.authenticatorId_
|
|
1715
|
-
)
|
|
1646
|
+
new command.Command(command.Name.REMOVE_ALL_CREDENTIALS).setParameter('authenticatorId', this.authenticatorId_),
|
|
1716
1647
|
)
|
|
1717
1648
|
}
|
|
1718
1649
|
|
|
@@ -1724,52 +1655,50 @@ class WebDriver {
|
|
|
1724
1655
|
await this.execute(
|
|
1725
1656
|
new command.Command(command.Name.SET_USER_VERIFIED)
|
|
1726
1657
|
.setParameter('authenticatorId', this.authenticatorId_)
|
|
1727
|
-
.setParameter('isUserVerified', verified)
|
|
1658
|
+
.setParameter('isUserVerified', verified),
|
|
1728
1659
|
)
|
|
1729
1660
|
}
|
|
1730
1661
|
|
|
1731
1662
|
async getDownloadableFiles() {
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1663
|
+
const caps = await this.getCapabilities()
|
|
1664
|
+
if (!caps['map_'].get('se:downloadsEnabled')) {
|
|
1665
|
+
throw new error.WebDriverError('Downloads must be enabled in options')
|
|
1666
|
+
}
|
|
1736
1667
|
|
|
1737
|
-
|
|
1668
|
+
return (await this.execute(new command.Command(command.Name.GET_DOWNLOADABLE_FILES))).names
|
|
1738
1669
|
}
|
|
1739
1670
|
|
|
1740
1671
|
async downloadFile(fileName, targetDirectory) {
|
|
1741
|
-
const caps = await this.getCapabilities()
|
|
1672
|
+
const caps = await this.getCapabilities()
|
|
1742
1673
|
if (!caps['map_'].get('se:downloadsEnabled')) {
|
|
1743
|
-
throw new Error('Downloads must be enabled in options')
|
|
1674
|
+
throw new Error('Downloads must be enabled in options')
|
|
1744
1675
|
}
|
|
1745
1676
|
|
|
1746
|
-
const response = await this.execute(
|
|
1747
|
-
new command.Command(command.Name.DOWNLOAD_FILE).setParameter('name', fileName)
|
|
1748
|
-
);
|
|
1677
|
+
const response = await this.execute(new command.Command(command.Name.DOWNLOAD_FILE).setParameter('name', fileName))
|
|
1749
1678
|
|
|
1750
|
-
const base64Content = response.contents
|
|
1679
|
+
const base64Content = response.contents
|
|
1751
1680
|
|
|
1752
1681
|
if (!targetDirectory.endsWith('/')) {
|
|
1753
|
-
targetDirectory += '/'
|
|
1682
|
+
targetDirectory += '/'
|
|
1754
1683
|
}
|
|
1755
1684
|
|
|
1756
|
-
fs.mkdirSync(targetDirectory, { recursive: true })
|
|
1757
|
-
const zipFilePath = path.join(targetDirectory, `${fileName}.zip`)
|
|
1758
|
-
fs.writeFileSync(zipFilePath, Buffer.from(base64Content, 'base64'))
|
|
1685
|
+
fs.mkdirSync(targetDirectory, { recursive: true })
|
|
1686
|
+
const zipFilePath = path.join(targetDirectory, `${fileName}.zip`)
|
|
1687
|
+
fs.writeFileSync(zipFilePath, Buffer.from(base64Content, 'base64'))
|
|
1759
1688
|
|
|
1760
|
-
const zipData = fs.readFileSync(zipFilePath)
|
|
1689
|
+
const zipData = fs.readFileSync(zipFilePath)
|
|
1761
1690
|
await JSZip.loadAsync(zipData)
|
|
1762
|
-
.then(zip => {
|
|
1691
|
+
.then((zip) => {
|
|
1763
1692
|
// Iterate through each file in the zip archive
|
|
1764
1693
|
Object.keys(zip.files).forEach(async (fileName) => {
|
|
1765
|
-
const fileData = await zip.files[fileName].async('nodebuffer')
|
|
1766
|
-
fs.writeFileSync(`${targetDirectory}/${fileName}`, fileData)
|
|
1767
|
-
console.log(`File extracted: ${fileName}`)
|
|
1768
|
-
})
|
|
1694
|
+
const fileData = await zip.files[fileName].async('nodebuffer')
|
|
1695
|
+
fs.writeFileSync(`${targetDirectory}/${fileName}`, fileData)
|
|
1696
|
+
console.log(`File extracted: ${fileName}`)
|
|
1697
|
+
})
|
|
1698
|
+
})
|
|
1699
|
+
.catch((error) => {
|
|
1700
|
+
console.error('Error unzipping file:', error)
|
|
1769
1701
|
})
|
|
1770
|
-
.catch(error => {
|
|
1771
|
-
console.error("Error unzipping file:", error);
|
|
1772
|
-
});
|
|
1773
1702
|
}
|
|
1774
1703
|
|
|
1775
1704
|
async deleteDownloadableFiles() {
|
|
@@ -1778,9 +1707,7 @@ class WebDriver {
|
|
|
1778
1707
|
throw new error.WebDriverError('Downloads must be enabled in options')
|
|
1779
1708
|
}
|
|
1780
1709
|
|
|
1781
|
-
return await this.execute(
|
|
1782
|
-
new command.Command(command.Name.DELETE_DOWNLOADABLE_FILES)
|
|
1783
|
-
)
|
|
1710
|
+
return await this.execute(new command.Command(command.Name.DELETE_DOWNLOADABLE_FILES))
|
|
1784
1711
|
}
|
|
1785
1712
|
}
|
|
1786
1713
|
|
|
@@ -1812,9 +1739,7 @@ class Navigation {
|
|
|
1812
1739
|
* has been loaded.
|
|
1813
1740
|
*/
|
|
1814
1741
|
to(url) {
|
|
1815
|
-
return this.driver_.execute(
|
|
1816
|
-
new command.Command(command.Name.GET).setParameter('url', url)
|
|
1817
|
-
)
|
|
1742
|
+
return this.driver_.execute(new command.Command(command.Name.GET).setParameter('url', url))
|
|
1818
1743
|
}
|
|
1819
1744
|
|
|
1820
1745
|
/**
|
|
@@ -1898,9 +1823,7 @@ class Options {
|
|
|
1898
1823
|
|
|
1899
1824
|
// We do not allow ';' in value.
|
|
1900
1825
|
if (/;/.test(value)) {
|
|
1901
|
-
throw new error.InvalidArgumentError(
|
|
1902
|
-
'Invalid cookie value "' + value + '"'
|
|
1903
|
-
)
|
|
1826
|
+
throw new error.InvalidArgumentError('Invalid cookie value "' + value + '"')
|
|
1904
1827
|
}
|
|
1905
1828
|
|
|
1906
1829
|
if (typeof expiry === 'number') {
|
|
@@ -1912,14 +1835,12 @@ class Options {
|
|
|
1912
1835
|
|
|
1913
1836
|
if (sameSite && !['Strict', 'Lax', 'None'].includes(sameSite)) {
|
|
1914
1837
|
throw new error.InvalidArgumentError(
|
|
1915
|
-
`Invalid sameSite cookie value '${sameSite}'. It should be one of "Lax", "Strict" or "None"
|
|
1838
|
+
`Invalid sameSite cookie value '${sameSite}'. It should be one of "Lax", "Strict" or "None"`,
|
|
1916
1839
|
)
|
|
1917
1840
|
}
|
|
1918
1841
|
|
|
1919
1842
|
if (sameSite === 'None' && !secure) {
|
|
1920
|
-
throw new error.InvalidArgumentError(
|
|
1921
|
-
'Invalid cookie configuration: SameSite=None must be Secure'
|
|
1922
|
-
)
|
|
1843
|
+
throw new error.InvalidArgumentError('Invalid cookie configuration: SameSite=None must be Secure')
|
|
1923
1844
|
}
|
|
1924
1845
|
|
|
1925
1846
|
return this.driver_.execute(
|
|
@@ -1932,7 +1853,7 @@ class Options {
|
|
|
1932
1853
|
httpOnly: !!httpOnly,
|
|
1933
1854
|
expiry: expiry,
|
|
1934
1855
|
sameSite: sameSite,
|
|
1935
|
-
})
|
|
1856
|
+
}),
|
|
1936
1857
|
)
|
|
1937
1858
|
}
|
|
1938
1859
|
|
|
@@ -1943,9 +1864,7 @@ class Options {
|
|
|
1943
1864
|
* when all cookies have been deleted.
|
|
1944
1865
|
*/
|
|
1945
1866
|
deleteAllCookies() {
|
|
1946
|
-
return this.driver_.execute(
|
|
1947
|
-
new command.Command(command.Name.DELETE_ALL_COOKIES)
|
|
1948
|
-
)
|
|
1867
|
+
return this.driver_.execute(new command.Command(command.Name.DELETE_ALL_COOKIES))
|
|
1949
1868
|
}
|
|
1950
1869
|
|
|
1951
1870
|
/**
|
|
@@ -1957,9 +1876,7 @@ class Options {
|
|
|
1957
1876
|
* when the cookie has been deleted.
|
|
1958
1877
|
*/
|
|
1959
1878
|
deleteCookie(name) {
|
|
1960
|
-
return this.driver_.execute(
|
|
1961
|
-
new command.Command(command.Name.DELETE_COOKIE).setParameter('name', name)
|
|
1962
|
-
)
|
|
1879
|
+
return this.driver_.execute(new command.Command(command.Name.DELETE_COOKIE).setParameter('name', name))
|
|
1963
1880
|
}
|
|
1964
1881
|
|
|
1965
1882
|
/**
|
|
@@ -1970,9 +1887,7 @@ class Options {
|
|
|
1970
1887
|
* resolved with the cookies visible to the current browsing context.
|
|
1971
1888
|
*/
|
|
1972
1889
|
getCookies() {
|
|
1973
|
-
return this.driver_.execute(
|
|
1974
|
-
new command.Command(command.Name.GET_ALL_COOKIES)
|
|
1975
|
-
)
|
|
1890
|
+
return this.driver_.execute(new command.Command(command.Name.GET_ALL_COOKIES))
|
|
1976
1891
|
}
|
|
1977
1892
|
|
|
1978
1893
|
/**
|
|
@@ -1987,15 +1902,10 @@ class Options {
|
|
|
1987
1902
|
*/
|
|
1988
1903
|
async getCookie(name) {
|
|
1989
1904
|
try {
|
|
1990
|
-
const cookie = await this.driver_.execute(
|
|
1991
|
-
new command.Command(command.Name.GET_COOKIE).setParameter('name', name)
|
|
1992
|
-
)
|
|
1905
|
+
const cookie = await this.driver_.execute(new command.Command(command.Name.GET_COOKIE).setParameter('name', name))
|
|
1993
1906
|
return cookie
|
|
1994
1907
|
} catch (err) {
|
|
1995
|
-
if (
|
|
1996
|
-
!(err instanceof error.UnknownCommandError) &&
|
|
1997
|
-
!(err instanceof error.UnsupportedOperationError)
|
|
1998
|
-
) {
|
|
1908
|
+
if (!(err instanceof error.UnknownCommandError) && !(err instanceof error.UnsupportedOperationError)) {
|
|
1999
1909
|
throw err
|
|
2000
1910
|
}
|
|
2001
1911
|
|
|
@@ -2061,10 +1971,7 @@ class Options {
|
|
|
2061
1971
|
valid = true
|
|
2062
1972
|
cmd.setParameter(key, value)
|
|
2063
1973
|
} else if (typeof value !== 'undefined') {
|
|
2064
|
-
throw TypeError(
|
|
2065
|
-
'invalid timeouts configuration:' +
|
|
2066
|
-
` expected "${key}" to be a number, got ${typeof value}`
|
|
2067
|
-
)
|
|
1974
|
+
throw TypeError('invalid timeouts configuration:' + ` expected "${key}" to be a number, got ${typeof value}`)
|
|
2068
1975
|
}
|
|
2069
1976
|
}
|
|
2070
1977
|
setParam('implicit', implicit)
|
|
@@ -2112,11 +2019,7 @@ class Options {
|
|
|
2112
2019
|
* @return {!Promise<void>}
|
|
2113
2020
|
*/
|
|
2114
2021
|
function legacyTimeout(driver, type, ms) {
|
|
2115
|
-
return driver.execute(
|
|
2116
|
-
new command.Command(command.Name.SET_TIMEOUT)
|
|
2117
|
-
.setParameter('type', type)
|
|
2118
|
-
.setParameter('ms', ms)
|
|
2119
|
-
)
|
|
2022
|
+
return driver.execute(new command.Command(command.Name.SET_TIMEOUT).setParameter('type', type).setParameter('ms', ms))
|
|
2120
2023
|
}
|
|
2121
2024
|
|
|
2122
2025
|
/**
|
|
@@ -2226,9 +2129,7 @@ class Window {
|
|
|
2226
2129
|
* A promise that will resolve to the window rect of the current window.
|
|
2227
2130
|
*/
|
|
2228
2131
|
getRect() {
|
|
2229
|
-
return this.driver_.execute(
|
|
2230
|
-
new command.Command(command.Name.GET_WINDOW_RECT)
|
|
2231
|
-
)
|
|
2132
|
+
return this.driver_.execute(new command.Command(command.Name.GET_WINDOW_RECT))
|
|
2232
2133
|
}
|
|
2233
2134
|
|
|
2234
2135
|
/**
|
|
@@ -2252,7 +2153,7 @@ class Window {
|
|
|
2252
2153
|
y,
|
|
2253
2154
|
width,
|
|
2254
2155
|
height,
|
|
2255
|
-
})
|
|
2156
|
+
}),
|
|
2256
2157
|
)
|
|
2257
2158
|
}
|
|
2258
2159
|
|
|
@@ -2266,10 +2167,7 @@ class Window {
|
|
|
2266
2167
|
*/
|
|
2267
2168
|
maximize() {
|
|
2268
2169
|
return this.driver_.execute(
|
|
2269
|
-
new command.Command(command.Name.MAXIMIZE_WINDOW).setParameter(
|
|
2270
|
-
'windowHandle',
|
|
2271
|
-
'current'
|
|
2272
|
-
)
|
|
2170
|
+
new command.Command(command.Name.MAXIMIZE_WINDOW).setParameter('windowHandle', 'current'),
|
|
2273
2171
|
)
|
|
2274
2172
|
}
|
|
2275
2173
|
|
|
@@ -2282,9 +2180,7 @@ class Window {
|
|
|
2282
2180
|
* has completed.
|
|
2283
2181
|
*/
|
|
2284
2182
|
minimize() {
|
|
2285
|
-
return this.driver_.execute(
|
|
2286
|
-
new command.Command(command.Name.MINIMIZE_WINDOW)
|
|
2287
|
-
)
|
|
2183
|
+
return this.driver_.execute(new command.Command(command.Name.MINIMIZE_WINDOW))
|
|
2288
2184
|
}
|
|
2289
2185
|
|
|
2290
2186
|
/**
|
|
@@ -2298,9 +2194,7 @@ class Window {
|
|
|
2298
2194
|
* @see <https://fullscreen.spec.whatwg.org/#fullscreen-an-element>
|
|
2299
2195
|
*/
|
|
2300
2196
|
fullscreen() {
|
|
2301
|
-
return this.driver_.execute(
|
|
2302
|
-
new command.Command(command.Name.FULLSCREEN_WINDOW)
|
|
2303
|
-
)
|
|
2197
|
+
return this.driver_.execute(new command.Command(command.Name.FULLSCREEN_WINDOW))
|
|
2304
2198
|
}
|
|
2305
2199
|
|
|
2306
2200
|
/**
|
|
@@ -2310,9 +2204,7 @@ class Window {
|
|
|
2310
2204
|
*/
|
|
2311
2205
|
async getSize(windowHandle = 'current') {
|
|
2312
2206
|
if (windowHandle !== 'current') {
|
|
2313
|
-
this.log_.warning(
|
|
2314
|
-
`Only 'current' window is supported for W3C compatible browsers.`
|
|
2315
|
-
)
|
|
2207
|
+
this.log_.warning(`Only 'current' window is supported for W3C compatible browsers.`)
|
|
2316
2208
|
}
|
|
2317
2209
|
|
|
2318
2210
|
const rect = await this.getRect()
|
|
@@ -2328,14 +2220,9 @@ class Window {
|
|
|
2328
2220
|
* @param windowHandle
|
|
2329
2221
|
* @returns {Promise<void>}
|
|
2330
2222
|
*/
|
|
2331
|
-
async setSize(
|
|
2332
|
-
{ x = 0, y = 0, width = 0, height = 0 },
|
|
2333
|
-
windowHandle = 'current'
|
|
2334
|
-
) {
|
|
2223
|
+
async setSize({ x = 0, y = 0, width = 0, height = 0 }, windowHandle = 'current') {
|
|
2335
2224
|
if (windowHandle !== 'current') {
|
|
2336
|
-
this.log_.warning(
|
|
2337
|
-
`Only 'current' window is supported for W3C compatible browsers.`
|
|
2338
|
-
)
|
|
2225
|
+
this.log_.warning(`Only 'current' window is supported for W3C compatible browsers.`)
|
|
2339
2226
|
}
|
|
2340
2227
|
|
|
2341
2228
|
await this.setRect({ x, y, width, height })
|
|
@@ -2377,19 +2264,11 @@ class Logs {
|
|
|
2377
2264
|
* type.
|
|
2378
2265
|
*/
|
|
2379
2266
|
get(type) {
|
|
2380
|
-
let cmd = new command.Command(command.Name.GET_LOG).setParameter(
|
|
2381
|
-
'type',
|
|
2382
|
-
type
|
|
2383
|
-
)
|
|
2267
|
+
let cmd = new command.Command(command.Name.GET_LOG).setParameter('type', type)
|
|
2384
2268
|
return this.driver_.execute(cmd).then(function (entries) {
|
|
2385
2269
|
return entries.map(function (entry) {
|
|
2386
2270
|
if (!(entry instanceof logging.Entry)) {
|
|
2387
|
-
return new logging.Entry(
|
|
2388
|
-
entry['level'],
|
|
2389
|
-
entry['message'],
|
|
2390
|
-
entry['timestamp'],
|
|
2391
|
-
entry['type']
|
|
2392
|
-
)
|
|
2271
|
+
return new logging.Entry(entry['level'], entry['message'], entry['timestamp'], entry['type'])
|
|
2393
2272
|
}
|
|
2394
2273
|
return entry
|
|
2395
2274
|
})
|
|
@@ -2402,9 +2281,7 @@ class Logs {
|
|
|
2402
2281
|
* promise that will resolve to a list of available log types.
|
|
2403
2282
|
*/
|
|
2404
2283
|
getAvailableLogTypes() {
|
|
2405
|
-
return this.driver_.execute(
|
|
2406
|
-
new command.Command(command.Name.GET_AVAILABLE_LOG_TYPES)
|
|
2407
|
-
)
|
|
2284
|
+
return this.driver_.execute(new command.Command(command.Name.GET_AVAILABLE_LOG_TYPES))
|
|
2408
2285
|
}
|
|
2409
2286
|
}
|
|
2410
2287
|
|
|
@@ -2436,9 +2313,7 @@ class TargetLocator {
|
|
|
2436
2313
|
* @return {!WebElementPromise} The active element.
|
|
2437
2314
|
*/
|
|
2438
2315
|
activeElement() {
|
|
2439
|
-
const id = this.driver_.execute(
|
|
2440
|
-
new command.Command(command.Name.GET_ACTIVE_ELEMENT)
|
|
2441
|
-
)
|
|
2316
|
+
const id = this.driver_.execute(new command.Command(command.Name.GET_ACTIVE_ELEMENT))
|
|
2442
2317
|
return new WebElementPromise(this.driver_, id)
|
|
2443
2318
|
}
|
|
2444
2319
|
|
|
@@ -2450,9 +2325,7 @@ class TargetLocator {
|
|
|
2450
2325
|
* when the driver has changed focus to the default content.
|
|
2451
2326
|
*/
|
|
2452
2327
|
defaultContent() {
|
|
2453
|
-
return this.driver_.execute(
|
|
2454
|
-
new command.Command(command.Name.SWITCH_TO_FRAME).setParameter('id', null)
|
|
2455
|
-
)
|
|
2328
|
+
return this.driver_.execute(new command.Command(command.Name.SWITCH_TO_FRAME).setParameter('id', null))
|
|
2456
2329
|
}
|
|
2457
2330
|
|
|
2458
2331
|
/**
|
|
@@ -2476,17 +2349,10 @@ class TargetLocator {
|
|
|
2476
2349
|
frame(id) {
|
|
2477
2350
|
let frameReference = id
|
|
2478
2351
|
if (typeof id === 'string') {
|
|
2479
|
-
frameReference = this.driver_
|
|
2480
|
-
.findElement({ id })
|
|
2481
|
-
.catch((_) => this.driver_.findElement({ name: id }))
|
|
2352
|
+
frameReference = this.driver_.findElement({ id }).catch((_) => this.driver_.findElement({ name: id }))
|
|
2482
2353
|
}
|
|
2483
2354
|
|
|
2484
|
-
return this.driver_.execute(
|
|
2485
|
-
new command.Command(command.Name.SWITCH_TO_FRAME).setParameter(
|
|
2486
|
-
'id',
|
|
2487
|
-
frameReference
|
|
2488
|
-
)
|
|
2489
|
-
)
|
|
2355
|
+
return this.driver_.execute(new command.Command(command.Name.SWITCH_TO_FRAME).setParameter('id', frameReference))
|
|
2490
2356
|
}
|
|
2491
2357
|
|
|
2492
2358
|
/**
|
|
@@ -2498,9 +2364,7 @@ class TargetLocator {
|
|
|
2498
2364
|
* has completed.
|
|
2499
2365
|
*/
|
|
2500
2366
|
parentFrame() {
|
|
2501
|
-
return this.driver_.execute(
|
|
2502
|
-
new command.Command(command.Name.SWITCH_TO_FRAME_PARENT)
|
|
2503
|
-
)
|
|
2367
|
+
return this.driver_.execute(new command.Command(command.Name.SWITCH_TO_FRAME_PARENT))
|
|
2504
2368
|
}
|
|
2505
2369
|
|
|
2506
2370
|
/**
|
|
@@ -2522,7 +2386,7 @@ class TargetLocator {
|
|
|
2522
2386
|
// "name" supports the legacy drivers. "handle" is the W3C
|
|
2523
2387
|
// compliant parameter.
|
|
2524
2388
|
.setParameter('name', nameOrHandle)
|
|
2525
|
-
.setParameter('handle', nameOrHandle)
|
|
2389
|
+
.setParameter('handle', nameOrHandle),
|
|
2526
2390
|
)
|
|
2527
2391
|
}
|
|
2528
2392
|
|
|
@@ -2540,12 +2404,7 @@ class TargetLocator {
|
|
|
2540
2404
|
newWindow(typeHint) {
|
|
2541
2405
|
const driver = this.driver_
|
|
2542
2406
|
return this.driver_
|
|
2543
|
-
.execute(
|
|
2544
|
-
new command.Command(command.Name.SWITCH_TO_NEW_WINDOW).setParameter(
|
|
2545
|
-
'type',
|
|
2546
|
-
typeHint
|
|
2547
|
-
)
|
|
2548
|
-
)
|
|
2407
|
+
.execute(new command.Command(command.Name.SWITCH_TO_NEW_WINDOW).setParameter('type', typeHint))
|
|
2549
2408
|
.then(function (response) {
|
|
2550
2409
|
return driver.switchTo().window(response.handle)
|
|
2551
2410
|
})
|
|
@@ -2560,15 +2419,13 @@ class TargetLocator {
|
|
|
2560
2419
|
* @return {!AlertPromise} The open alert.
|
|
2561
2420
|
*/
|
|
2562
2421
|
alert() {
|
|
2563
|
-
const text = this.driver_.execute(
|
|
2564
|
-
new command.Command(command.Name.GET_ALERT_TEXT)
|
|
2565
|
-
)
|
|
2422
|
+
const text = this.driver_.execute(new command.Command(command.Name.GET_ALERT_TEXT))
|
|
2566
2423
|
const driver = this.driver_
|
|
2567
2424
|
return new AlertPromise(
|
|
2568
2425
|
driver,
|
|
2569
2426
|
text.then(function (text) {
|
|
2570
2427
|
return new Alert(driver, text)
|
|
2571
|
-
})
|
|
2428
|
+
}),
|
|
2572
2429
|
)
|
|
2573
2430
|
}
|
|
2574
2431
|
}
|
|
@@ -2616,9 +2473,7 @@ class WebElement {
|
|
|
2616
2473
|
* @return {!Object} The element ID for use with WebDriver's wire protocol.
|
|
2617
2474
|
*/
|
|
2618
2475
|
static buildId(id, noLegacy = false) {
|
|
2619
|
-
return noLegacy
|
|
2620
|
-
? { [ELEMENT_ID_KEY]: id }
|
|
2621
|
-
: { [ELEMENT_ID_KEY]: id, [LEGACY_ELEMENT_ID_KEY]: id }
|
|
2476
|
+
return noLegacy ? { [ELEMENT_ID_KEY]: id } : { [ELEMENT_ID_KEY]: id, [LEGACY_ELEMENT_ID_KEY]: id }
|
|
2622
2477
|
}
|
|
2623
2478
|
|
|
2624
2479
|
/**
|
|
@@ -2845,26 +2700,20 @@ class WebElement {
|
|
|
2845
2700
|
return this.execute_(
|
|
2846
2701
|
new command.Command(command.Name.SEND_KEYS_TO_ELEMENT)
|
|
2847
2702
|
.setParameter('text', keys.join(''))
|
|
2848
|
-
.setParameter('value', keys)
|
|
2703
|
+
.setParameter('value', keys),
|
|
2849
2704
|
)
|
|
2850
2705
|
}
|
|
2851
2706
|
|
|
2852
2707
|
try {
|
|
2853
|
-
keys = await this.driver_.fileDetector_.handleFile(
|
|
2854
|
-
this.driver_,
|
|
2855
|
-
keys.join('')
|
|
2856
|
-
)
|
|
2708
|
+
keys = await this.driver_.fileDetector_.handleFile(this.driver_, keys.join(''))
|
|
2857
2709
|
} catch (ex) {
|
|
2858
|
-
this.log_.severe(
|
|
2859
|
-
'Error trying parse string as a file with file detector; sending keys instead' +
|
|
2860
|
-
ex
|
|
2861
|
-
)
|
|
2710
|
+
this.log_.severe('Error trying parse string as a file with file detector; sending keys instead' + ex)
|
|
2862
2711
|
}
|
|
2863
2712
|
|
|
2864
2713
|
return this.execute_(
|
|
2865
2714
|
new command.Command(command.Name.SEND_KEYS_TO_ELEMENT)
|
|
2866
2715
|
.setParameter('text', keys)
|
|
2867
|
-
.setParameter('value', keys.split(''))
|
|
2716
|
+
.setParameter('value', keys.split('')),
|
|
2868
2717
|
)
|
|
2869
2718
|
}
|
|
2870
2719
|
|
|
@@ -2894,9 +2743,7 @@ class WebElement {
|
|
|
2894
2743
|
*/
|
|
2895
2744
|
getCssValue(cssStyleProperty) {
|
|
2896
2745
|
const name = command.Name.GET_ELEMENT_VALUE_OF_CSS_PROPERTY
|
|
2897
|
-
return this.execute_(
|
|
2898
|
-
new command.Command(name).setParameter('propertyName', cssStyleProperty)
|
|
2899
|
-
)
|
|
2746
|
+
return this.execute_(new command.Command(name).setParameter('propertyName', cssStyleProperty))
|
|
2900
2747
|
}
|
|
2901
2748
|
|
|
2902
2749
|
/**
|
|
@@ -2929,12 +2776,7 @@ class WebElement {
|
|
|
2929
2776
|
* either a string or null.
|
|
2930
2777
|
*/
|
|
2931
2778
|
getAttribute(attributeName) {
|
|
2932
|
-
return this.execute_(
|
|
2933
|
-
new command.Command(command.Name.GET_ELEMENT_ATTRIBUTE).setParameter(
|
|
2934
|
-
'name',
|
|
2935
|
-
attributeName
|
|
2936
|
-
)
|
|
2937
|
-
)
|
|
2779
|
+
return this.execute_(new command.Command(command.Name.GET_ELEMENT_ATTRIBUTE).setParameter('name', attributeName))
|
|
2938
2780
|
}
|
|
2939
2781
|
|
|
2940
2782
|
/**
|
|
@@ -2959,12 +2801,7 @@ class WebElement {
|
|
|
2959
2801
|
*/
|
|
2960
2802
|
|
|
2961
2803
|
getDomAttribute(attributeName) {
|
|
2962
|
-
return this.execute_(
|
|
2963
|
-
new command.Command(command.Name.GET_DOM_ATTRIBUTE).setParameter(
|
|
2964
|
-
'name',
|
|
2965
|
-
attributeName
|
|
2966
|
-
)
|
|
2967
|
-
)
|
|
2804
|
+
return this.execute_(new command.Command(command.Name.GET_DOM_ATTRIBUTE).setParameter('name', attributeName))
|
|
2968
2805
|
}
|
|
2969
2806
|
|
|
2970
2807
|
/**
|
|
@@ -2974,12 +2811,7 @@ class WebElement {
|
|
|
2974
2811
|
* resolved with the element's property value
|
|
2975
2812
|
*/
|
|
2976
2813
|
getProperty(propertyName) {
|
|
2977
|
-
return this.execute_(
|
|
2978
|
-
new command.Command(command.Name.GET_ELEMENT_PROPERTY).setParameter(
|
|
2979
|
-
'name',
|
|
2980
|
-
propertyName
|
|
2981
|
-
)
|
|
2982
|
-
)
|
|
2814
|
+
return this.execute_(new command.Command(command.Name.GET_ELEMENT_PROPERTY).setParameter('name', propertyName))
|
|
2983
2815
|
}
|
|
2984
2816
|
|
|
2985
2817
|
/**
|
|
@@ -3107,9 +2939,7 @@ class WebElement {
|
|
|
3107
2939
|
* resolved to the screenshot as a base-64 encoded PNG.
|
|
3108
2940
|
*/
|
|
3109
2941
|
takeScreenshot() {
|
|
3110
|
-
return this.execute_(
|
|
3111
|
-
new command.Command(command.Name.TAKE_ELEMENT_SCREENSHOT)
|
|
3112
|
-
)
|
|
2942
|
+
return this.execute_(new command.Command(command.Name.TAKE_ELEMENT_SCREENSHOT))
|
|
3113
2943
|
}
|
|
3114
2944
|
}
|
|
3115
2945
|
|
|
@@ -3194,11 +3024,7 @@ class ShadowRoot {
|
|
|
3194
3024
|
* @return {boolean} whether the object is a valid encoded WebElement ID.
|
|
3195
3025
|
*/
|
|
3196
3026
|
static isId(obj) {
|
|
3197
|
-
return
|
|
3198
|
-
obj &&
|
|
3199
|
-
typeof obj === 'object' &&
|
|
3200
|
-
typeof obj[SHADOW_ROOT_ID_KEY] === 'string'
|
|
3201
|
-
)
|
|
3027
|
+
return obj && typeof obj === 'object' && typeof obj[SHADOW_ROOT_ID_KEY] === 'string'
|
|
3202
3028
|
}
|
|
3203
3029
|
|
|
3204
3030
|
/**
|
|
@@ -3404,12 +3230,7 @@ class Alert {
|
|
|
3404
3230
|
* when this command has completed.
|
|
3405
3231
|
*/
|
|
3406
3232
|
sendKeys(text) {
|
|
3407
|
-
return this.driver_.execute(
|
|
3408
|
-
new command.Command(command.Name.SET_ALERT_TEXT).setParameter(
|
|
3409
|
-
'text',
|
|
3410
|
-
text
|
|
3411
|
-
)
|
|
3412
|
-
)
|
|
3233
|
+
return this.driver_.execute(new command.Command(command.Name.SET_ALERT_TEXT).setParameter('text', text))
|
|
3413
3234
|
}
|
|
3414
3235
|
}
|
|
3415
3236
|
|