I am new to testcafe and JavaScript and unable to select drop down list by select element id. Above is my html file
<div class="collapse show" id="step-1" style="">
<div class="card card-body pb-0">
<form method="post" class="form-row" id="step-form-1" data- step="2" data-wrapper-key="basic_details">
<div class="form-group col-sm-12 pl-4 pr-4 w-100">
<label for="states">Names of state </label>
<select multiple="" id="states" class="form-control select2-hidden-accessible" label="Names of state"
inputtype="multiselect" required="" options="[object Object]" name="states" tabindex="-1"
aria-hidden="true">
<option value="1">Goa</option>
<option value="2">Punjab</option>
<option value="3">Maharshtra</option>
</form>
</div>
</div>
Here is my js code
test('profile',async t=> {
const selectStates= Selector('#states')
const selectOption=selectStates.find('option');
.click(selectStates)
.click(selectOption.withText('Punjab'))
}
Its not able to even click on drop down button I am getting error "The element that matches the specified selector is not visible".
I debugged in 0.1x speed and found that the dropdown id is getting clicked but the drop down list is not coming, it keeps showing waiting for element to appear.