Search code examples
javascriptappiumwebdriver-ioappium-android

How to use ID or resource ID contains locator for Android in WebdriverIO


I have a Android Native UI where I have:

  1. Find By: id, Selector: 76ggg-unique-ID-o9o
  2. Attribute - class: android.view.ViewGroup
  3. resource-id: 76ggg-unique-ID-o9o

Now I want to create a selector for this element in WebdriverIO where I can use contains unique-ID. I tried following but nothing worked.

'strategy': 'css selector',
'strategyVal': '[id*="unique-ID"]'
'strategy': 'css selector',
'strategyVal': '[id*=unique-ID]'
'strategy': 'xpath',
'strategyVal': '//*[contains(@id, "unique-ID")]'
'strategy': 'xpath',
'strategyVal': '//*[@id*="unique-ID"]'
'strategy': 'xpath',
'strategyVal': '//*[contains(@id, "unique-ID")]'

Any suggestion is appreciated.


Solution

  • After doing some debugging I came to know it was taking some time to load UI. After waiting for few seconds, below locator strategy worked.

    'strategy': 'xpath',
    'strategyVal': '//android.view.ViewGroup[contains(@resource-id, "unique-ID")]'