具有动态ID和名称的selectOption

I am using Codeception do test advanced custom field within a wordpress app.

I am having issues getting it to find the html select box. This is because it never has a static name or ID e.g id="acf-field-field_58079c4650b04_type" name="fields[field_58079c4650b04]. The numbers change each time, which is expected.

Using codeceptions

$I->selectOption("contains(@id, '_type')]", 'number');

I have been unable to get it to find the it and it throws this error.

 1) CreateNewFieldCest: Create a new advanced custom field
 Test  tests/acceptance/CreateNewFieldCest.php:CreateNewField
 Step  Select option "//input[@type='select' and contains(@id, '_type')]","number"
 Fail  Field by name, label, CSS or XPath element with '//input[@type='select' and contains(@id, '_type')]' was not found.

Scenario Steps:

 6. $I->selectOption("//input[@type='select' and contains(@id, '...","number")
 5. $I->wait(2)
 4. $I->fillField("//input[@type='text' and @class='label' a...","test field")
 3. $I->click("+ Add Field")
 2. $I->fillField("#title","test field")
 1. $I->amOnPage("/wp/wp-admin/post-new.php?post_type=acf")


FAILURES!
Tests: 1, Assertions: 0, Failures: 1.
Script codecept handling the __exec_command event returned with error code 1

Can anyone recommend an approach to being able to use selectOption to find a select box with a dynamic id and name.

Xpath seems correct, it should be able to find it if it is contained in the dom and it is visible.

Is it populated from an ajax request?

Then probably the select is not rendered or populated yet.

You can use something like this to wait for the ajax requests to complete

  $I->waitForJs('return jQuery.active == 0', 10);