We have following cucumber test scenario in webdriver.io and cucumber.io framework. We used typescript as the language.
Scenario: can navigate to main page
Given I am on web home page
When I navigate to the next page
Then I can see following person data
| title | name | age |
| Mr | John | 35 |
Also we have following Person model class
export class Person {
title: string
name: string
age : number
} export default new Person();
In our steps we want to read the dataTable and assign to the Class Person.
@when(/^I can see flowing person data$/)
public async icanseeflowingpersondata(table: DataTable) {
Person.title= table.raw.title ;
Person.name = table.raw.name;
Person.age = table.raw.age ;
}
Rather doing above want to create an instance of Person type from dataTable. I know this is possible in c# as bellow, but want to know how we can do the same in typeScript + WebDriver.io+ Cucumber.io ? I am very new to Webdriver.io and helps much appreciated.
var tableData = table.CreateInstance<Person>();