1

I have a question about the use of an "expect().toExist() command (part of the "expect-webdriverio" package). I am attempting to use it in an appium test suite run on the mocha framework - we are testing an application on tvOS (not on any web browser) and I am getting the following error: ReferenceError: browser is not defined This is happening in a framework in which the "browser" is actually the "client". We use the word "client" because we are not testing anything web-based. So, this is the test script:

await client.pause(5000); //wait for app install and loading screen
const thisButton = await browser.$("~CONTINUE");
        //console.log(client.capabilities);
 console.log(thisButton);//this is logged in detail
 await expect(thisButton).toExist();//this is where we get the error
 await thisButton.click();//this works perfectly once we get to it.
 await client.pause(10000);

... and here's what we see when I tell it to log thisButton:

Element {
  sessionId: '57f34ce7-968c-47da-b2f3-42cea8e31090',
  elementId: '0F000000-0000-0000-4C58-010000000000',
  'element-6066-11e4-a52e-4f735466cecf': '0F000000-0000-0000-4C58-010000000000',
  selector: '~CONTINUE',
  parent: Browser {
    sessionId: '57f34ce7-968c-47da-b2f3-42cea8e31090',
    capabilities: {
      webStorageEnabled: false,
      locationContextEnabled: false,
      browserName: '',
      platform: 'MAC',
      javascriptEnabled: true,
      databaseEnabled: false,
      takesScreenshot: true,
      networkConnectionEnabled: false,
      platformName: 'tvOS',
      automationName: 'XCUITest',
      deviceName: 'Apple TV',
      platformVersion: '15.4',
      app: <not listed - path is completely internal to the computer>,
      udid: 'D5A91802-8E82-47FF-9408-68A39FA606FC'
    },
    addCommand: [Function (anonymous)],
    overwriteCommand: [Function (anonymous)],
    addLocatorStrategy: [Function (anonymous)]
  },
  emit: [Function: bound ],
  isReactElement: false,
  addCommand: [Function (anonymous)],
  overwriteCommand: [Function (anonymous)]
}

The capabilities used are contained in the "caps.js" file - contents are as follows:

const tvosCaps = {
    platformName: "tvOS",
    automationName: "XCUITest",
    deviceName: process.env.IOS_DEVICE_NAME || "Apple TV",
    platformVersion: process.env.IOS_PLATFORM_VERSION || "15.4",
    app: undefined, //to be defined in test file
};

const serverConfig = {
    path: "/wd/hub",
    host: process.env.APPIUM_HOST || "localhost",
    port: process.env.APPIUM_PORT || 4723,
    logLevel: "info",
};

const tvosOptions = Object.assign(
    {
        capabilities: tvosCaps,
    },
    serverConfig
);
module.exports = {
    tvosOptions,
};

There is a wdio.conf.js file, but it has value "chrome" for browserName, and we're not using chrome at all for this. I have it set up to use appium as a service - I'm not sure how to include it in the configuration. Maybe through package.json?

Any idea as to how to get past this ReferenceError?

0 Answers0