我拿到这个网页是为了测试索赔编号.但我不能提取同样的东西.
<h1 class="jss41 undefined" style="text-transform: capitalize; display: flex; align-items: center; margin-bottom: 0.5rem;">
"Claims #"
"75078"
</h1>
我想要获取的XPath是
export const getClaimsHeader = () => cy.xpath("//h1[contains(@class,'undefined')]")
这是我正在try 获取索赔编号的代码
getClaimsHeader()
.each((header) => {
claimNum = header.text().split('#');
actualClaimNumber = claimNum[1];
})
.then(() => {
expect(claimNumber).to.equal(actualClaimNumber);
});
但是actualClaimNumber
显示为空白,因为header.text()
只返回"Claims#"