How to use spinTitleNotEquals method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

helpers.js

Source: helpers.js Github

copy
1import { retry, retryInterval } from 'asyncbox';
2import { HOST, PORT } from '../helpers/session';
3import { util } from 'appium-support';
4import _ from 'lodash';
5
6
7const LOCAL_BASE_END_POINT = `http://${process.env.REAL_DEVICE ? util.localIp() : HOST}:${PORT}`;
8const REMOTE_BASE_END_POINT = `http://127.0.0.1:4443`;
9const BASE_END_POINT = process.env.CLOUD ? REMOTE_BASE_END_POINT : LOCAL_BASE_END_POINT;
10const TEST_END_POINT = `${BASE_END_POINT}/test`;
11const GUINEA_PIG_PAGE = `${TEST_END_POINT}/guinea-pig`;
12const GUINEA_PIG_SCROLLABLE_PAGE = `${GUINEA_PIG_PAGE}-scrollable`;
13const GUINEA_PIG_APP_BANNER_PAGE = `${GUINEA_PIG_PAGE}-app-banner`;
14const GUINEA_PIG_FRAME_PAGE = `${TEST_END_POINT}/frameset.html`;
15const GUINEA_PIG_IFRAME_PAGE = `${TEST_END_POINT}/iframes.html`;
16// if the phishing URL stops working for some reason, see
17// http://testsafebrowsing.appspot.com/ for alternatives
18const PHISHING_END_POINT = 'http://testsafebrowsing.appspot.com/s/phishing.html';
19const APPIUM_IMAGE = `${BASE_END_POINT}/appium.png`;
20
21async function spinTitle (driver) {
22  return await retry(10, async function () {
23    const title = await driver.title();
24    if (_.isNil(title)) {
25      throw new Error('Did not get a page title');
26    }
27    return title;
28  });
29}
30
31async function spinTitleEquals (driver, expectedTitle, tries = 10, interval = 500) {
32  await retryInterval(tries, interval, async function () {
33    const title = await spinTitle(driver);
34    if (title !== expectedTitle) {
35      throw new Error(`Could not find expected title: '${expectedTitle}'. Found: '${title}'`);
36    }
37  });
38}
39
40async function spinTitleNotEquals (driver, wrongTitle, tries = 10, interval = 500) {
41  await retryInterval(tries, interval, async function () {
42    const title = await spinTitle(driver);
43    if (title === wrongTitle) {
44      throw new Error(`Found title we did not expect: '${title}'`);
45    }
46  });
47}
48
49async function spinWait (fn, waitMs = 10000, intMs = 500) {
50  const tries = parseInt(waitMs / intMs, 10);
51  await retryInterval(tries, intMs, fn);
52}
53
54async function openPage (driver, url, tries = 10, interval = 500) {
55  await retryInterval(tries, interval, async function () {
56    await driver.get(url);
57    await spinTitleNotEquals(driver, 'cannot open page');
58  });
59}
60
61export { spinTitle, spinTitleEquals, spinWait, openPage, GUINEA_PIG_PAGE,
62  GUINEA_PIG_FRAME_PAGE, GUINEA_PIG_IFRAME_PAGE, PHISHING_END_POINT,
63  APPIUM_IMAGE, GUINEA_PIG_SCROLLABLE_PAGE, GUINEA_PIG_APP_BANNER_PAGE };
64
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 Xcuitest 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)