如何使用TestCafé在 标记后的文本中编写xpath?

问题描述 投票:0回答:1

需要检查文本是否在break(br)标记后可用

HTML代码:

<div class="a-column a-span3">
<a class="footer-link" target="_blank" rel="noopener" href="https://www.community.com/">
<span class="footer"><b>Community</b></span>
<br>
Connect 
<br>and fun
</a>
</div>
<div class="a-column a-span3">
<a class="footer-link" target="_blank" rel="noopener" href="https://www.google.com/">
<span class="footer"><b>google</b></span>
<br>
Contact 
<br>and get help
</a>
</div>

我尝试过并得到错误是:

1) AssertionError: expected false to be truthy

   48 |    async checkFooter(footerText){
 > 49 |        await t.expect((Selector('[id=container]').child('div').nth(14).child('div').nth(5).child('div').child('div').nth(2).child('a').withText(footerText)).exists).ok();
   50 |    }

普通Xpath://*[@id="container"]/div[14]/div[5]/div/div[2]/a/text()[1]

如何使用text('Contact')为此元素编写xpath并在break语句之后验证其是否可用

testing automation automated-tests e2e-testing testcafe
1个回答
1
投票

XpathSelector的帮助下,我们使用普通的xpath作为我们希望在硒中使用的xpath。

© www.soinside.com 2019 - 2024. All rights reserved.