Dropdown multiple values not supported in Typescript
Describe the bug Since PR #1602 Taiko supports multiple value selection for dropdowns, but that does not work in Typescript due to type inconsistency (as already mentioned in the PR comments)
To Reproduce Steps (or script) to reproduce the behavior:
- Create a new folder and cd into it
- Initialize the npm project with
npm init - Add Taiko to the project
npm i taiko - Add Typescript to the project
npm i -D typescript - Create a new file like:
//index.ts
import { dropDown } from "taiko";
async function main() {
const myDropdown = dropDown('Vehicle:');
await myDropdown.select(['Car','Van'])
const values: string[] = await myDropdown.value()
}
- try compiling with
npx tsc - you get an error like:
index.ts:6:9 - error TS2322: Type 'string' is not assignable to type 'string[]'.
6 const values: string[] = await myDropdown.value()
Logs
index.ts:6:9 - error TS2322: Type 'string' is not assignable to type 'string[]'.
6 const values: string[] = await myDropdown.value()
Expected behavior
DropDownWrapper now extends ValueWrapper which has a method value() returning Promise<string>.
I think DropDownWrapper should extend a new MultiValueWrapper which has a method values() returning Promise<string | Array<string> | Array<number>>.
The ValueWrapper should remain as it is for the elements that actually implement that behavior such as ColorWrapper, TextBoxWrapper, etc.
Screenshots If applicable, add screenshots to help explain your problem.
Versions:
- Taiko: 1.0.26
- OS: Win10 home 10.0.19041
- Node.js: v14.4.0
- Typescript: 4.0.5
Additional context Add any other context about the problem here.
I think DropDownWrapper should extend a new MultiValueWrapper which has a method values() returning Promise<string | Array
| Array >. The ValueWrapper should remain as it is for the elements that actually implement that behavior such as ColorWrapper, TextBoxWrapper, etc.
@fmpanelli Since you already have the fix in your mind, would you like to raise a PR for the same?
@fmpanelli Since you already have the fix in your mind, would you like to raise a PR for the same?
Sure! Hopefully I'll be able to submit a PR this evening.