scenario outline cucumber typescript

273 Views Asked by At

Iam searching how can i implement the cucumber scenario outline in typescript, How can I click on 3 different inputs using typescript and playwright cucumber ?

This is the scenario and typescript implementation but it doesn't work

`Scenario: test multiClicks Given test displayed When I click '' Then I should see all captures

        | header1  |
        | input2   |
        | input3   |
        | input4    |`

My implementation

what is wrong here

When('I click {string}', async function (header1: string) { const page = this.page!; await page.click("text=" + header1); });

thankyou !

1

There are 1 best solutions below

1
On

Not sure if you got this fixed but if you pasted your Scenario exactly as you have it then you are missing some syntax and it should look like below.

    Scenario: test multiClicks 
    Given test displayed 
    When I click '<header1>' 
    Then I should see all captures

    | header1   |
    | input2    |
    | input3    |
    | input4    |

Then also, I think you want to follow the click pattern more like: await page.getByRole('button', { name: header1 }).click();