How to use d.timeouts method in Appium Base Driver

Best JavaScript code snippet using appium-base-driver

Run Appium Base Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

test-timeouts.js

Source: test-timeouts.js Github

copy
1var common = require('../common');
2var assert = common.assert;
3var retry = require(common.dir.lib + '/retry');
4
5(function testDefaultValues() {
6  var timeouts = retry.timeouts();
7
8  assert.equal(timeouts.length, 10);
9  assert.equal(timeouts[0], 1000);
10  assert.equal(timeouts[1], 2000);
11  assert.equal(timeouts[2], 4000);
12})();
13
14(function testDefaultValuesWithRandomize() {
15  var minTimeout = 5000;
16  var timeouts = retry.timeouts({
17    minTimeout: minTimeout,
18    randomize: true
19  });
20
21  assert.equal(timeouts.length, 10);
22  assert.ok(timeouts[0] > minTimeout);
23  assert.ok(timeouts[1] > timeouts[0]);
24  assert.ok(timeouts[2] > timeouts[1]);
25})();
26
27(function testPassedTimeoutsAreUsed() {
28  var timeoutsArray = [1000, 2000, 3000];
29  var timeouts = retry.timeouts(timeoutsArray);
30  assert.deepEqual(timeouts, timeoutsArray);
31  assert.notStrictEqual(timeouts, timeoutsArray);
32})();
33
34(function testTimeoutsAreWithinBoundaries() {
35  var minTimeout = 1000;
36  var maxTimeout = 10000;
37  var timeouts = retry.timeouts({
38    minTimeout: minTimeout,
39    maxTimeout: maxTimeout
40  });
41  for (var i = 0; i < timeouts; i++) {
42    assert.ok(timeouts[i] >= minTimeout);
43    assert.ok(timeouts[i] <= maxTimeout);
44  }
45})();
46
47(function testTimeoutsAreIncremental() {
48  var timeouts = retry.timeouts();
49  var lastTimeout = timeouts[0];
50  for (var i = 0; i < timeouts; i++) {
51    assert.ok(timeouts[i] > lastTimeout);
52    lastTimeout = timeouts[i];
53  }
54})();
55
56(function testTimeoutsAreIncrementalForFactorsLessThanOne() {
57  var timeouts = retry.timeouts({
58    retries: 3,
59    factor: 0.5
60  });
61
62  var expected = [250, 500, 1000];
63  assert.deepEqual(expected, timeouts);
64})();
65
66(function testRetries() {
67  var timeouts = retry.timeouts({retries: 2});
68  assert.strictEqual(timeouts.length, 2);
69})();
70
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Appium Base Driver on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)