По существу, element.all
возвращает объект ElementArrayFinder , но await element.all
возвращает массив ElementFinder объектов.
Ожидаемый ElementArrayFinder представляет собой простой массив Объекты ElementFinder и, следовательно, могут вызывать все существующие методы массива (например, длину). Неожиданный ElementArrayFinder - это специальный объект, определенный с помощью транспортира, и для него доступны специальные методы (например, count (), get () и first ()).
Методы, доступные для ElementArrayFinder, перечислены в API транспортира. .
Пример
Для этого примера go на страницу https://angular.io/. $([class="button hero-cta"])
находит только один элемент на этой странице
console.log (element.all ('[class = "button hero-cta"]')) вернет следующий объект ElementArrayFinder
ElementArrayFinder {
browser_: ProtractorBrowser {
controlFlow: [Function],
schedule: [Function],
setFileDetector: [Function],
getExecutor: [Function],
getSession: [Function],
getCapabilities: [Function],
quit: [Function],
actions: [Function],
touchActions: [Function],
executeScript: [Function],
executeAsyncScript: [Function],
call: [Function],
wait: [Function],
sleep: [Function],
getWindowHandle: [Function],
getAllWindowHandles: [Function],
getPageSource: [Function],
close: [Function],
getCurrentUrl: [Function],
getTitle: [Function],
findElementInternal_: [Function],
findElementsInternal_: [Function],
takeScreenshot: [Function],
manage: [Function],
switchTo: [Function],
driver: thenableWebDriverProxy {
flow_: [ControlFlow],
session_: [ManagedPromise],
executor_: [Executor],
fileDetector_: null,
onQuit_: undefined,
cancel: [Function],
then: [Function: bound then],
catch: [Function: bound then],
getNetworkConnection: [Function],
setNetworkConnection: [Function],
toggleAirplaneMode: [Function],
toggleWiFi: [Function],
toggleData: [Function],
toggleLocationServices: [Function],
getGeolocation: [Function],
setGeolocation: [Function],
getCurrentDeviceActivity: [Function],
startDeviceActivity: [Function],
getAppiumSettings: [Function],
setAppiumSettings: [Function],
getCurrentContext: [Function],
selectContext: [Function],
getScreenOrientation: [Function],
setScreenOrientation: [Function],
isDeviceLocked: [Function],
lockDevice: [Function],
unlockDevice: [Function],
installApp: [Function],
isAppInstalled: [Function],
removeApp: [Function],
pullFileFromDevice: [Function],
pullFolderFromDevice: [Function],
pushFileToDevice: [Function],
listContexts: [Function],
uploadFile: [Function],
switchToParentFrame: [Function],
fullscreen: [Function],
sendAppToBackground: [Function],
closeApp: [Function],
getAppStrings: [Function],
launchSession: [Function],
resetApp: [Function],
hideSoftKeyboard: [Function],
getDeviceTime: [Function],
openDeviceNotifications: [Function],
rotationGesture: [Function],
shakeDevice: [Function],
sendChromiumCommand: [Function],
sendChromiumCommandAndGetResult: [Function]
},
element: [Function: element] { all: [Function] },
'$': [Function],
'$$': [Function],
baseUrl: '',
getPageTimeout: 10000,
params: {},
resetUrl: 'data:text/html,<html></html>',
debugHelper: DebugHelper { browserUnderDebug_: [Circular] },
ready: ManagedPromise {
flow_: [ControlFlow],
stack_: null,
parent_: null,
callbacks_: null,
state_: 'fulfilled',
handled_: true,
value_: [Circular],
queue_: null
},
trackOutstandingTimeouts_: true,
mockModules_: [ [Object] ],
ExpectedConditions: ProtractorExpectedConditions { browser: [Circular] },
plugins_: Plugins {
setup: [Function],
onPrepare: [Function],
teardown: [Function],
postResults: [Function],
postTest: [Function],
onPageLoad: [Function],
onPageStable: [Function],
waitForPromise: [Function],
waitForCondition: [Function],
pluginObjs: [],
assertions: {},
resultsReported: false
},
allScriptsTimeout: 11000,
getProcessedConfig: [Function],
forkNewDriverInstance: [Function],
restart: [Function],
restartSync: [Function],
internalRootEl: '',
internalIgnoreSynchronization: true
},
getWebElements: [Function: getWebElements],
locator_: name(name) {
return By.css('*[name="' + escapeCss(name) + '"]');
} {
using: 'css selector',
value: '[class="button hero-cta"]'
},
actionResults_: null,
click: [Function],
sendKeys: [Function],
getTagName: [Function],
getCssValue: [Function],
getAttribute: [Function],
getText: [Function],
getSize: [Function],
getLocation: [Function],
isEnabled: [Function],
isSelected: [Function],
submit: [Function],
clear: [Function],
isDisplayed: [Function],
getId: [Function],
takeScreenshot: [Function]
}
console.log (await element.all ('[class = "button hero-cta"]')) вернет массив объектов ElementFinder
[
ElementFinder {
browser_: ProtractorBrowser {
controlFlow: [Function],
schedule: [Function],
setFileDetector: [Function],
getExecutor: [Function],
getSession: [Function],
getCapabilities: [Function],
quit: [Function],
actions: [Function],
touchActions: [Function],
executeScript: [Function],
executeAsyncScript: [Function],
call: [Function],
wait: [Function],
sleep: [Function],
getWindowHandle: [Function],
getAllWindowHandles: [Function],
getPageSource: [Function],
close: [Function],
getCurrentUrl: [Function],
getTitle: [Function],
findElementInternal_: [Function],
findElementsInternal_: [Function],
takeScreenshot: [Function],
manage: [Function],
switchTo: [Function],
driver: [thenableWebDriverProxy],
element: [Function],
'$': [Function],
'$$': [Function],
baseUrl: '',
getPageTimeout: 10000,
params: {},
resetUrl: 'data:text/html,<html></html>',
debugHelper: [DebugHelper],
ready: [ManagedPromise],
trackOutstandingTimeouts_: true,
mockModules_: [Array],
ExpectedConditions: [ProtractorExpectedConditions],
plugins_: [Plugins],
allScriptsTimeout: 11000,
getProcessedConfig: [Function],
forkNewDriverInstance: [Function],
restart: [Function],
restartSync: [Function],
internalRootEl: '',
internalIgnoreSynchronization: true
},
then: null,
parentElementArrayFinder: ElementArrayFinder {
browser_: [ProtractorBrowser],
getWebElements: [Function: getWebElements],
locator_: [name(name) {
return By.css('*[name="' + escapeCss(name) + '"]');
}],
actionResults_: null,
click: [Function],
sendKeys: [Function],
getTagName: [Function],
getCssValue: [Function],
getAttribute: [Function],
getText: [Function],
getSize: [Function],
getLocation: [Function],
isEnabled: [Function],
isSelected: [Function],
submit: [Function],
clear: [Function],
isDisplayed: [Function],
getId: [Function],
takeScreenshot: [Function]
},
elementArrayFinder_: ElementArrayFinder {
browser_: [ProtractorBrowser],
getWebElements: [Function: getWebElements],
locator_: [name(name) {
return By.css('*[name="' + escapeCss(name) + '"]');
}],
actionResults_: null,
click: [Function],
sendKeys: [Function],
getTagName: [Function],
getCssValue: [Function],
getAttribute: [Function],
getText: [Function],
getSize: [Function],
getLocation: [Function],
isEnabled: [Function],
isSelected: [Function],
submit: [Function],
clear: [Function],
isDisplayed: [Function],
getId: [Function],
takeScreenshot: [Function]
},
click: [Function],
sendKeys: [Function],
getTagName: [Function],
getCssValue: [Function],
getAttribute: [Function],
getText: [Function],
getSize: [Function],
getLocation: [Function],
isEnabled: [Function],
isSelected: [Function],
submit: [Function],
clear: [Function],
isDisplayed: [Function],
getId: [Function],
takeScreenshot: [Function]
}
]
.
1 spec, 0 failures
Finished in 3.881 seconds
[13:33:25] I/local - Shutting down selenium standalone server.
[13:33:25] I/launcher - 0 instance(s) of WebDriver still running
[13:33:25] I/launcher - chrome #01 passed
C:\ProtractorProjects\ddg>