How to use the WebElementPromise function from selenium-webdriver

Find comprehensive JavaScript selenium-webdriver.WebElementPromise code examples handpicked from public code repositorys.

51
52
53
54
55
56
57
58
59
60
  const fwd = scope.driver_ || scope;
  const el = this.filters
    ? this.all(scope).then(matches => this.assert(matches[0]))
    : scope.findElement(this.by).catch(() => this.assert());

  const elementPromise = new webdriver.WebElementPromise(fwd, el);
  return fwd._decorateElement(elementPromise);
};

Query.prototype.findAll = function (scope) {
fork icon0
star icon2
watch icon2

20
21
22
23
24
25
26
27
28
29
this.FileDetector = webdriver.FileDetector;
this.Key = webdriver.Key;
this.Session = webdriver.Session;
this.WebDriver = webdriver.WebDriver;
this.WebElement = webdriver.WebElement;
this.WebElementPromise = webdriver.WebElementPromise;
this.error = webdriver.error;
this.logging = webdriver.logging;
this.promise = webdriver.promise;
this.until = webdriver.until;
fork icon1
star icon0
watch icon2

146
147
148
149
150
151
152
153
154
155
if (!selector) {
  return null;
}

// eslint-disable-next-line no-async-promise-executor
return new WebElementPromise(this.driver, new Promise(async (resolve, reject) => {
  if (selector instanceof Promise) {
    try {
      selector = await selector;
    } catch (error) {
fork icon0
star icon0
watch icon0

+ 5 other calls in file

13
14
15
16
17
18
19
20
21
22
    await this.driver.wait(until.elementIsEnabled(element), this.milisecondsTimeout);
    await this.driver.sleep(this.milisecondsDelay);
    const el = await this.driver.findElement(_locator);
    return el;
  };
  return new WebElementPromise(this.driver, _getElement(locator));
}  

async elementExists(locator) {
  try {
fork icon0
star icon0
watch icon0

44
45
46
47
48
49
50
51
52
53
FileDetector = webdriver.FileDetector;
Key = webdriver.Key;
Session = webdriver.Session;
WebDriver = webdriver.WebDriver;
WebElement = webdriver.WebElement;
WebElementPromise = webdriver.WebElementPromise;
error = webdriver.error;
logging = webdriver.logging;
promise = webdriver.promise;
until = webdriver.until;
fork icon0
star icon0
watch icon35

+ 5 other calls in file

51
52
53
54
55
56
57
58
59
60
  const selene = scope.driver_ || scope;
  const el = this.filters
    ? this.all(scope).then(matches => this.assert(matches[0]))
    : scope.findElement(this.by).catch(() => this.assert());

  const elementPromise = new webdriver.WebElementPromise(selene, el);
  return selene._decorateElement(elementPromise);
};

Query.prototype.findAll = function (scope) {
fork icon0
star icon0
watch icon1