python selenium - 为什么我不能点击这个?

时间:2016-11-14 21:11:01

标签: python selenium click

https://gyazo.com/9887635aa04d723758ba17b3413f72e1 - html

名为class =“radio inline bundle-cta”的是我想要的那个。

<label class="radio inline bundle-cta">
            <input data-bind="checked: activeBundle" id="BundleType" name="BundleType" type="radio" value="Default">
            Nej tak, jeg vælger en basisannonce uden tilvalg
                <span class="uneditable-input price">Kr. <span data-price="0">0</span>,-</span>

            <span class="bundle-cta-button">Vælg basisannonce</span>
        </label>

错误消息,尝试点击它时:

Element is not clickable at point (604, 698). Other element would receive the click: <p style="line-height: 20px; margin: 0px 40px 0px 15px; padding: 0px;">...</p>
  (Session info: chrome=54.0.2840.71)
  (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.14393 x86_64)

我曾经试图点击它的代码:

element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.class, "bundle-cta-button"))

# vælg gratis pakke
browser.find_element_by_class_name('bundle-cta-button').click()
sleep(0.75)
browser.find_element_by_xpath('//*[@id="content"]/div[2]/div/div/form/div/button').click()

1 个答案:

答案 0 :(得分:1)

尝试将空格更改为点,并通过CSS_selector查找,如下所示:

browser.find_element_by_css_selector("radio.inline.bundle-cta").click()