WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Using regular expression to find a control

Open Manvibha opened this issue 9 years ago • 3 comments

Hi,

Does latest release supports using regular expression to find a control? Ex: session.FindElementByName("Test Version -*"); // Actual value would be "Test Version - 10.0".

I tested with regular expression and it failed with above scenario. Is there a way to do it or can I expect this feature in near future?

Thanks, Mahendra

Manvibha avatar Aug 29 '17 05:08 Manvibha

Hi @Manvibha,

Most of the element locators match the element precisely as given and does NOT support regular expression. In order to do something similar, you would need to use XPath expressions.

timotiusmargo avatar Aug 29 '17 18:08 timotiusmargo

xpath supports regex ? It seems xpath does't support regex to me. is there any way to do partial search ?

henry1999sg avatar May 29 '20 09:05 henry1999sg

Xpath doesn't support regex, but have other methods. It depends what is you need, e.g.

  1. search for control that contains 'Test Version -' text: session.FindElementByXPath("//*[contains(@Name, 'Test Version -')]");
  2. search for control that start with 'Test Version -' text: session.FindElementByXPath("//*[starts-with(@Name, 'Test Version -')]";

Shakevg avatar May 30 '20 07:05 Shakevg