Selenium/Xpath select option containing text

For one of my tests I am trying to select an option that contains the text “Current”

The select dropdown looks like so:

<select name="lead" class="wide">
<option value="">-- Select a lead --</option>
<option value="5066689">Current Lead: L5066689 (kitchens) Created: '27/08/2021 11:10:53'</option>
<option value="5066671"> L5066671 (kitchens) Created: '27/08/2021 09:56:10'</option></select>

What I’m trying is using this function:

const chooseCurrentLeadToSaveAgainst = async () => {
    await pageHelpers.waitForSelectorAndClick(selectors.leadDropdown);
    await logger.logScreenshot();
    await pageHelpers.waitForSelectorAndClick(selectors.currentLead);

The leadDropdown selector is:

leadDropdown: 'select.wide',

This works and the test will click on the select box to open it up, I am then attempting to try click on the option that contains the the text ‘Current’ through the selector currentLead:

 currentLead: 'option[(contains(text(),'Current')]',

With this selector, however, it’s failing to find it and can’t click on it, where am I going wrong with this selector?


Those back slashes does not look good. use // initially to select the current node, see below :-


also if you are confident that this value will not change, 5066689 try to use value attribute.

Update :'select.wide').click('select.wide option:nth-child(1)')