Protractor 如何根据通过功能文件传递的数据更新xpath

Protractor 如何根据通过功能文件传递的数据更新xpath,protractor,cucumber,Protractor,Cucumber,我有一个场景,我需要点击日期。需要从要素文件发送日期。 xpath如下所示 //table[@class="mat-calendar-table"]/tbody/tr/td[@aria-label="January 1, 2019"]. 功能文件如下所示 Scenario: Protractor date pickers Test" Given Go to title page Then The title must be "Datepicker | Angular Ma

我有一个场景,我需要点击日期。需要从要素文件发送日期。 xpath如下所示

//table[@class="mat-calendar-table"]/tbody/tr/td[@aria-label="January 1, 2019"].  
功能文件如下所示

 Scenario: Protractor date pickers Test"
    Given Go to title page
    Then The title must be "Datepicker | Angular Material"
    When enter the date "January 6, 2019"
请让我知道如何将日期从功能文件传递到xpath

import { Given, Then, When } from "cucumber";

// if using async/await
When(/^enter the date "(.*)"$/, async(date) => {
  var util = require('util');
  var xpath = '/table[@class="mat-calendar-table"]/tbody/tr/td[@aria-label="%s"]'

  return await element(by.xpath(util.format(xpath, date))).sendKeys(date);
});

// not using async await
When(/^enter the date "(.*)"$/, (date) => {
  var util = require('util');
  var xpath = '/table[@class="mat-calendar-table"]/tbody/tr/td[@aria-label="%s"]'

  return element(by.xpath(util.format(xpath, date))).sendKeys(date);
});