async scrape(locator) {
console.log("Locator passed in is" + locator);
}
为什么控制台日志显示 [object Object] 作为参数的输出?它不应该返回传入的任何值吗?
下面是调用该函数的代码:
Scenario('Scrape The Full Menu pricing and calorie data @scrapewebsite, {retries: 0}, async (I) => {
I.waitForElement({"xpath":".//select"});
rawMenuItems = await I.getElementsText({"xpath":".//*[contains(@data-ng-bind-html, 'item.title')]"});
uniqueMenuItems = [...new Set(rawMenuItems)];
for(let b = 0; b < uniqueMenuItems.length; b++ )
{
let locationVar = {"xpath":".//*[text()=\"" + uniqueMenuItems[b] + "\"]//following::*[@class=\"productControllers custom-product-ctrls\"][1]/div/div/select"};
uniqueMenuItems[b] = uniqueMenuItems[b].replace(/®.*/, "");
drinks[b] = await I.scrape(locationVar);
}
});