How to use the Condition function from selenium-webdriver

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

78
79
80
81
82
83
84
85
86
87
    driver => this.findOne(scope || driver).catch(() => null)
  );
};

Query.prototype.untilSome = function (scope) {
  return new webdriver.Condition(`for ${this}`,
    driver => this.findAll(scope || driver).then(
      list => (list && list.length ? list : null)
    )
  );
fork icon0
star icon2
watch icon2

14
15
16
17
18
19
20
21
22
23
  return null;
}

function waitForCondition(driver) {
  return async function(text, fn, timeout) {
    return await driver.wait(new Condition(text, fn), timeout);
  };
}

// driver.findElement(By.xpath("//tbody/tr[1]/td[1]")).getText().then(...) can throw a stale element error:
fork icon663
star icon0
watch icon204

+ 3 other calls in file

11
12
13
14
15
16
17
18
19
20
  throw new Error('World must be defined')
}

until = until || webDriver.until
_.extend(until, {
  foundInPage: (selector) => new webDriver.Condition(`for $("${selector}") to be found in page`, co(function * (selector) {
    const driver = yield world.getDriver()
    return yield driver.findElement(By.css(selector))
      .then(() => true)
      .catch(() => false)
fork icon1
star icon3
watch icon3

+ 7 other calls in file

1
2
3
4
5
6
7
8
9
10

const URL = require('url');
const webdriver = require('selenium-webdriver');

const until = webdriver.until;
const Condition = webdriver.Condition;

const builtIns = {

  stale: until.stalenessOf,
fork icon0
star icon2
watch icon2

86
87
88
89
90
91
92
93
94
95
}

async locateElements({parentElement, selector, timeout, retryInterval}) {
  const createLocateElement = () => {
    return parentElement && parentElement.webElement ? function(locator) {
      return new Condition('for at least one element to be located ' + locator, function (driver) {
        return parentElement.webElement.findElements(locator).then(function (elements) {
          return elements.length > 0 ? elements : null;
        });
      });
fork icon0
star icon0
watch icon0

+ 2 other calls in file