Using regular expression to find a control
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
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.
xpath supports regex ? It seems xpath does't support regex to me. is there any way to do partial search ?
Xpath doesn't support regex, but have other methods. It depends what is you need, e.g.
- search for control that contains 'Test Version -' text: session.FindElementByXPath("//*[contains(@Name, 'Test Version -')]");
- search for control that start with 'Test Version -' text: session.FindElementByXPath("//*[starts-with(@Name, 'Test Version -')]";