2015-06-27 51 views
2

我正在學習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]'); 

無法點擊 「安全退房」, 「(//一個[包含(文本(),」 安全退房 「))[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> 
+0

您是否測試過選擇器?你還可以提供一些元素的HTML? – Saifur

+0

@Saifur我從Firefox中的Selenium IDE中取出選擇器。不確定你測試的意思。它可以與IDE協同工作,並且可以在Codeception中使用see調用。我正在測試的頁面非常複雜,但是我儘可能地放棄了HTML。 –

回答

4

好像這只是因爲see功能允許兩個參數並click只做一個在xpath情況。所以,根據this以下應該工作

$I->click('(//a[contains(text(),"Secure Check Out")])[2]'); 
+1

你先生得到我的互聯網點。謝謝您的幫助! –

相關問題