Node.js 如何在codeceptjs中调试和使用grabAttributeFrom?
在我的例子中,页面中的所有标识符都是动态生成的。所以我不能使用xpath 我在文档中找到了方法:Node.js 如何在codeceptjs中调试和使用grabAttributeFrom?,node.js,puppeteer,functional-testing,codeceptjs,Node.js,Puppeteer,Functional Testing,Codeceptjs,在我的例子中,页面中的所有标识符都是动态生成的。所以我不能使用xpath 我在文档中找到了方法:grabAttributeFrom 当我在--debug模式下使用cmd时,如何看到里面的内容 在搜索输入时,是否可以使用grabAttributeFrom从页面提取xpath 我如何访问具有名称的输入,这些输入是xpath动态生成的,而我不能使用xpath的 我尝试了以下代码: I.fillField(locate('input').inside('.jq-panel-body-default'
grabAttributeFrom
- 当我在--debug模式下使用cmd时,如何看到里面的内容
- 在搜索输入时,是否可以使用grabAttributeFrom从页面提取xpath
- 我如何访问具有名称的输入,这些输入是xpath动态生成的,而我不能使用xpath的
I.fillField(locate('input').inside('.jq-panel-body-default').at(2),'John');
但它不能正常工作并生成异常:
FAIL Field "{"type":"xpath","output":null,"strict":true,"locator":{"xpath":".//input[ancestor::*[contains(concat(' ', normalize-space(./@class), ' '), ' jq-panel-body-default ')]][position()=2]"},"value":".//input[ancestor::*[contains(concat(' ', normalize-space(./@class), ' '), ' jq-panel-body-default ')]][position()=2]"}" was not found by text|CSS|XPath
Scenario("test", async (I) => {
...
const attributeValue = await I.grabAttributeFrom(<locator>, <attribute>);
console.log(attributeValue);
...
});
场景(“测试”,异步(I)=>{
...
const attributeValue=wait I.grabAttributeFrom(,);
console.log(attributeValue);
...
});
grabAttributeFrom
用于获取属性值,而不是用于xpath查找。
但若你们问,你们能在定位器参数中使用xpath吗,是的,你们能
如果你的意思是
name
属性,你可以使用按名称过滤://输入[@name=”“]
你有很多问题,我的朋友。让我们稍微整理一下这个问题。即使设置了一点格式,这些问题也需要更多的时间来整理。