如何根据通过功能文件传递的数据更新 xpath
How to update the xpath as per the data passed through feature file
我有一个场景需要点击日期。需要从功能文件发送日期。
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);
});
我有一个场景需要点击日期。需要从功能文件发送日期。 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);
});