Codeception:我可以看到一个链接,但无法点击它

Ben*_*nee 2 selenium xpath acceptance-testing codeception

我正在学习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]');
Run Code Online (Sandbox Code Playgroud)

无法单击"安全检出","(// a [包含(文本(),"安全检出")])[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>
Run Code Online (Sandbox Code Playgroud)

Sai*_*fur 5

似乎它只是因为该see函数允许两个参数,click并且只有一个参数xpath.因此,根据这一点,以下应该工作

$I->click('(//a[contains(text(),"Secure Check Out")])[2]');
Run Code Online (Sandbox Code Playgroud)