How to use the promise function from selenium-webdriver

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

0
1
2
3
4
5
6
7
8
9
const webdriver = require('selenium-webdriver');
const async = require('async');


function driversetup(nemo) {
  var d = webdriver.promise.defer();
  async.waterfall([function setup(cb) {
    nemo.driver = new webdriver
      .Builder()
      .forBrowser('phantomjs')
fork icon91
star icon259
watch icon22

64
65
66
67
68
69
70
71
72
73
if (!webdriver.Capabilities[elem]) {
  return console.warn('No such browser: %s', elem);
}

var lastPromise = global.testPromise || webdriver.promise.fulfilled();
var testComplete = webdriver.promise.defer();
global.testPromise = testComplete.promise;

//create a driver per test file
lastPromise.then(function () {
fork icon8
star icon134
watch icon14

+ 23 other calls in file

31
32
33
34
35
36
37
38
39
40
FormAuthenticator.prototype.get = function(url){

  var that = this;

  if (!this.user || !this.pass) {
    return webdriver.promise.rejected(
      new Error('Form auth requested but user or pass is not specified'));
  }

  // webdriver statements are synchronized by webdriver flow so no need to join the promises
fork icon56
star icon120
watch icon21

60
61
62
63
64
65
66
67
68
69
    const conds = spec.map(this.createCondition, this);
    const descriptions = conds.map(c => c.description());
    const desc = ['for all of these:'].concat(descriptions).join('\n* ');

    return new Condition(desc, driver =>
      webdriver.promise.all(conds.map(c => c.fn(driver)))
      .then(values => values.every(Boolean))
    );
  }
},
fork icon0
star icon2
watch icon2

+ 3 other calls in file

63
64
65
66
67
68
69
70
71
72
};

Query.prototype.filter = function (elements) {
  const filters = this.filters;
  if (!filters) return elements;
  return webdriver.promise.filter(elements, el =>
    webdriver.promise.map(filters,
      f => f.test(el)
    )
    .then(res => res.every(Boolean))
fork icon0
star icon2
watch icon2

+ 3 other calls in file

195
196
197
198
199
200
201
202
203
204
}

minijn.addSpecs(resolvedSpecs);
// TODO: This should not be tied to the webdriver promise loop, it should use
// another promise system instead.
var runDeferred = webdriver.promise.defer();

if (config.chromeOnly) {
  if (!fs.existsSync(config.chromeDriver)) {
    if (fs.existsSync(config.chromeDriver + '.exe')) {
fork icon0
star icon1
watch icon16

+ 3 other calls in file

23
24
25
26
27
28
29
30
31
32
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;
this.Command = require('selenium-webdriver/lib/command').Command;
this.CommandName = require('selenium-webdriver/lib/command').Name;
this.utils = {
fork icon1
star icon0
watch icon2

47
48
49
50
51
52
53
54
55
56
WebDriver = webdriver.WebDriver;
WebElement = webdriver.WebElement;
WebElementPromise = webdriver.WebElementPromise;
error = webdriver.error;
logging = webdriver.logging;
promise = webdriver.promise;
until = webdriver.until;
Command = require('selenium-webdriver/lib/command').Command;
CommandName = require('selenium-webdriver/lib/command').Name;
utils = {
fork icon0
star icon0
watch icon35

+ 5 other calls in file

34
35
36
37
38
39
40
41
42
43
actions: () => webdriver.ActionSequence = webdriver.WebDriver.actions;
wait:
    (condition: webdriver.promise.Promise|webdriver.util.Condition|Function,
     opt_timeout?: number,
     opt_message?:
         string) => webdriver.promise.Promise = webdriver.WebDriver.wait;
sleep: (ms: number) => webdriver.promise.Promise = webdriver.WebDriver.sleep;
getCurrentUrl:
    () => webdriver.promise.Promise = webdriver.WebDriver.getCurrentUrl;
getTitle: () => webdriver.promise.Promise = webdriver.WebDriver.getTitle;
fork icon0
star icon0
watch icon2

+ 13 other calls in file