【发布时间】:2015-06-27 16:58:10
【问题描述】:
我正在学习 Codeception,但遇到了一些我认为很奇怪的事情。
// This works
$I->see('Secure Check Out', '(//a[contains(text(),"Secure Check Out")])[2]');
// This does not
$I->click('Secure Check Out', '(//a[contains(text(),"Secure Check Out")])[2]');
无法点击“安全签出”,"(//a[contains(text(),"安全签出")])[2]": 页面上未找到链接、按钮、CSS 或 XPath“安全签出”。
通过 Selenium WebDriver 在 Firefox 上运行。我该怎么做才能让它发挥作用?
这里大致是相关的 HTML。
<div class="mobile-only">
<a href="/responsive/ajax/modals/check-out/login.php" class="secure-checkout button blue bordered small modal-open">Secure Check Out</a>
</div>
<div class="secure-checkout-button threecol last mobile-hide">
<div class="pull-right">
<a style="background-color: transparent;" href="/responsive/ajax/modals/check-out/login.php" class="button blue bordered small modal-open">Secure Check Out</a>
</div>
</div>
【问题讨论】:
-
你测试过选择器吗?能否也提供一些元素的html?
-
@Saifur 我从 Firefox 的 Selenium IDE 中提取了该选择器。不知道你说的测试是什么意思。它可以在 IDE 中使用,也可以在 Codeception 中使用 see 调用。我正在测试的页面非常复杂,但我已尽我所能在问题中删除了 HTML。
-
另见另一个问题,它有同样的问题(see() 和 click() 行为不同),但解决方案不同,因为它没有使用 xpath:stackoverflow.com/questions/47094032/…
标签: selenium xpath codeception acceptance-testing