【问题标题】:Unable to click button with Selenium - python无法使用 Selenium 单击按钮 - python
【发布时间】:2020-06-03 23:48:19
【问题描述】:

我在使用 selenium 点击按钮时遇到了困难。似乎无法弄清楚我做错了什么

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

编辑: 所以认为问题是根据 https://sqa.stackexchange.com/questions/36918/xpath-text-buy-now-is-working-but-not-containstext-buy-now

但是,我的新功能仍然无法定位元素 //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>

【问题讨论】:

    标签: python python-3.x selenium selenium-webdriver multi-factor-authentication


    【解决方案1】:

    我遇到了同样的问题,我尝试了这个:

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

    这对我来说效果很好。

    【讨论】:

      猜你喜欢
      • 2021-09-11
      • 1970-01-01
      • 1970-01-01
      • 2020-07-30
      • 1970-01-01
      • 1970-01-01
      • 2017-01-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多