Testing grabAttributeFrom()方法不返回属性值
我试图使用Testing grabAttributeFrom()方法不返回属性值,testing,attributes,automated-tests,testcafe,codeceptjs,Testing,Attributes,Automated Tests,Testcafe,Codeceptjs,我试图使用I.grabAttributeFrom()方法获取元素的属性值,但我总是获取未定义的属性值,而不是属性值。我的代码是 Scenario('Smoketest', async (I) => { const columnIndex = await I.grabAttributeFrom('//th[text()="Status"]', 'aria-colindex'); }); 元素是这样的 “地位” ... 我也无法让它工作,所以我编写了一个量角器助手,它可以帮助我抓取
I.grabAttributeFrom()
方法获取元素的属性值,但我总是获取未定义的属性值,而不是属性值。我的代码是
Scenario('Smoketest', async (I) => {
const columnIndex = await I.grabAttributeFrom('//th[text()="Status"]', 'aria-colindex');
});
元素是这样的
“地位”
...
我也无法让它工作,所以我编写了一个量角器助手,它可以帮助我抓取文本属性:
/**
* Function to return the text content of all elements matching with the locator in an array
* @param xpath object
*/
async getElementsText(locator) {
const driver = this.helpers.Protractor.browser;
await driver.waitForAngular();
// await console.log("Getting text for: " + locator.xpath);
return driver.element.all(by.xpath(locator.xpath)).getAttribute("textContent");
}
我将您的选择器更改为
th
,但它仍然不起作用。我调试了testcafe
模块,它按预期工作:返回值2
。问题可能出在codeceptjs
方面。在他们的github回购协议中报告这一点很有意义。感谢您确认我这不是testcafe问题。我将检查codeceptjs github repo.Fix是否已合并。现在正在等待下一个(2.4.0)版本。谢谢你的欢迎。我将检查下一个版本:)