简体   繁体   中英

Can I use regex pattern matching for a CSS selector in Appium mobile automation?

I am trying to find a set of iOS UI elements in my automation script.

The framework is written in JS and utilizes Appium & WebdriverIO.

I was able to determine that the correct regex pattern I am searching for is this: [-+][\d]{1,3} which finds a string that starts with either +/- and is of 3 numerical digits in length.

The current implementation I use is:

  var strings = await $$("XCUIElementTypeStaticText[name*='[\d]{3}]']");

but I do not believe that is correct because when I print out the array length in console, it does not match to what is displayed in the iOS client UI.

Is it possible to use regex pattern matching when trying to find mobile application UI elements via CSS selector?

It is not possible to use regex as part of the css expression. If possible please try adding testIdentifiers to those elements or use XCUITest predicates as suggested here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM