This is a feature request for selecting multiple values with the dropDown API
dropDown(label).select(option1,option2') ==> Should select multiple values
dropDown(label).select({index:0,1,2,3})
dropDown(label).select(/subString/) ==> Should select all the options which match the given Regex
dropDown(label).select(option1,option2') ==> throws error
dropDown(label).select({index:0,1,2,3}) ==> this selects only the last option ie index 3
dropDown(label).select(/subString/) ==> selects first matching regex
The API should be modified (in the future) take an array i.e
dropDown(label).select(['option1', 'option2'])
For selecting multiple items, this should only work if the drop down is multi select.
For regex the current behaviour should change so that
dropDown(label).select(/subString/g)
Selects multiple items matching /subString/ if the dropdown is multi-select. (notice the g which is a global match flag)
If it is still open then i would like to take this up along with Jyoti(https://github.com/guptajyoti845)
Need clarification for the following scenarios :
@guptajyoti845 great catch.
when we are not having multiple attribute for select tag and user give array input in select API .Should we select the last element of input array or nothing will get selected with some readable error message.
In this case it should select the first item in the array.
When user try to select the disabled option in input array. Should we select the remaining array inputs or nothing will get selected with some readable error message.
In this case it should throw an error saying that I cannot set a value as the field is disabled.
One more scenario :
When user gives input array in select API, and one of the element is not available , then what should be the behaviour.
Either select other valid inputs or nothing would be selected.
When user gives input array in select API, and one of the element is not available
As Taiko does implicit assertions I think the test should fail as this could be a valid case missing data and unexpected behaviour.
Which now makes me rethink the following scenario
when we are not having multiple attribute for select tag and user give array input in select API .Should we select the last element of input array or nothing will get selected with some readable error message.
I think we should fail with an error the tester expects the field to be multi select but it is not implemented correctly. This is to avoid missing wrongly implemented behaviour.
if (!this.multiple && valuesToSelect.length > 1) {
return {
error: 'Cannot select multiple values on a single select dropdown',
stack: '',
};
}
Should it be implemented in this way, this will make no. 1 and 2 consistent and the user will not have any selection.
In the first scenario, we will fail the test. However, should we select other dropdown values which could be selected or should we skip selection of those and just raise an exception.
It's ok if the test fails while setting the value that is not available. I assume this can be done in the order of the input. This would be like how a user selects these options.
So for an array ['one', 'two', 'three', 'four'] let's say three is not available. It would have ideally set one and two and failed on 'three' without setting 'four'. This also means Taiko can tell the user which data was not found.
PR raised.
Most helpful comment
If it is still open then i would like to take this up along with Jyoti(https://github.com/guptajyoti845)