I am writing a test that needs to select from a pull-down list. The list contains options such as:
vpc-123 | Default VPC
vpc-456 | Lab VPC
I wish to select the option that contains “Lab VPC”, but the prefix will be different every time. Thus, I wish to use the regex capability of selectOptionByValue.
My code snippet is:
WebUI.click(findTestObject(‘xxx/Select-LabVPC’))
WebUI.selectOptionByValue(findTestObject(‘xxx/Select-LabVPC’), ‘Lab VPC’, true)
The click is successful, but it never finds the correct option.
The log output is:
05-07-2018 03:04:25 PM - [START] - Start action : selectOptionByValue
05-07-2018 03:04:29 PM - [INFO] - Finding Test Object with id ‘xxx/Select-LabVPC’
05-07-2018 03:04:29 PM - [INFO] - Checking object
05-07-2018 03:04:29 PM - [INFO] - Checking value parameter
05-07-2018 03:04:29 PM - [INFO] - Checking timeout
05-07-2018 03:04:29 PM - [INFO] - Finding web element with id: ‘xxx/Select-LabVPC’ located by ‘By.xpath: //*[contains(text(),‘Lab VPC’)]/…’ in ‘30’ second(s)
05-07-2018 03:04:29 PM - [INFO] - Found 1 web elements with id: ‘xxx/Select-LabVPC’ located by ‘By.xpath: //*[contains(text(),‘Lab VPC’)]/…’ in ‘30’ second(s)
05-07-2018 03:04:29 PM - [INFO] - Selecting options on object ‘xxx/Select-LabVPC’ with value ‘Lab VPC’ using regular expression
05-07-2018 03:04:30 PM - [FAILED] - No option matched.
05-07-2018 03:04:30 PM - [END] - End action : selectOptionByValue
I have been unable to find any examples with isRegex set to true.
I have also tried ‘.*Lab VPC.*’, but it does not match.
What format should be used to match a Regex?