MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / findElement

Method findElement

javascript/selenium-webdriver/lib/webdriver.js:1007–1032  ·  view source on GitHub ↗

@override

(locator)

Source from the content-addressed store, hash-verified

1005
1006 /** @override */
1007 findElement(locator) {
1008 let id
1009 let cmd = null
1010
1011 if (locator instanceof RelativeBy) {
1012 cmd = new command.Command(command.Name.FIND_ELEMENTS_RELATIVE).setParameter('args', locator.marshall())
1013 } else {
1014 locator = by.checkedLocator(locator)
1015 }
1016
1017 if (typeof locator === 'function') {
1018 id = this.findElementInternal_(locator, this)
1019 return new WebElementPromise(this, id)
1020 } else if (cmd === null) {
1021 cmd = new command.Command(command.Name.FIND_ELEMENT)
1022 .setParameter('using', locator.using)
1023 .setParameter('value', locator.value)
1024 }
1025
1026 id = this.execute(cmd)
1027 if (locator instanceof RelativeBy) {
1028 return this.normalize_(id)
1029 } else {
1030 return new WebElementPromise(this, id)
1031 }
1032 }
1033
1034 /**
1035 * @param {!Function} webElementPromise The webElement in unresolved state

Callers

nothing calls this directly

Calls 4

findElementInternal_Method · 0.95
executeMethod · 0.95
normalize_Method · 0.95
setParameterMethod · 0.80

Tested by

no test coverage detected