簡體   English   中英

無法單擊 Selenium - python 的按鈕

[英]Unable to click button with Selenium - python

我在點擊使用 selenium 的按鈕時遇到了困難。 似乎無法弄清楚我做錯了什么

self.driver.find_element(By.XPATH, "//button[contains(text(), 'Call Me ')]").click()

編輯:所以認為問題是 xpath 根據https://sqa.stackexchange.com/questions/36918/xpath-text-buy-now-is-working-but-not-containstext-buy-now

但是,我的新 function 仍然無法找到元素//button[contains(.,'Call Me')]

感謝你目前的幫助。

下面是我要訪問的按鈕的 HTML 代碼。

<div id="auth_methods">

<fieldset data-device-index="phone1" class="">
<h2 class="medium-or-larger auth-method-header">
Choose an authentication method
</h2>

<div class="row-label push-label">
<input type="hidden" name="factor" value="Duo Push">
<span class="label factor-label">
<i class="icon-smartphone-check"></i>
Duo Push


<small class="recommended">
Recommended
</small>


</span>
<button tabindex="2" type="submit" class="positive auth-button"><!-- -->Send Me a Push </button>
</div>

<div class="row-label phone-label">
<input type="hidden" name="factor" value="Phone Call">
<span class="label factor-label">
<i class="icon-call-ringing" alt="" role="presentation"></i>
Call Me

</span>
<button tabindex="2" type="submit" class="positive auth-button"><!-- -->Call Me </button>
</div>

我遇到了同樣的麻煩,我嘗試了這個:

path =  'your xpath'
button = driver.find_element_by_xpath(path)
button.Click()

這對我來說效果很好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM