无法单击按钮硒

时间:2020-07-04 17:10:50

标签: python selenium

试图按一个按钮,但是什么也没有发生。单击时没有错误,元素本身已定位。元素可见。

enter image description here

有我的代码:

verify = self.driver.find_element_by_xpath('//span[text()="Resend email"]')
ActionChains(self.driver).move_to_element(verify).click(verify).perform()

HTML:

<div class="Box-root Box-hideIfEmpty" style="pointer-events: auto;"><button class="UnstyledLink ButtonLink Flex-flex" type="button"><div class="Box-root Flex-flex Flex-alignItems--baseline Flex-direction--row" style="position: relative;"><div class="TextAligner Box-root" style="line-height: 20px; font-size: 14px; flex: 0 0 auto;"></div>
<div class="Box-root Flex-flex Flex-alignItems--baseline Flex-direction--row Flex-justifyContent--flexStart" style="line-height: 0; flex: 1 1 auto;"><span class="ButtonLink-label Text-color--blue Text-fontSize--14 Text-fontWeight--medium Text-lineHeight--20 Text-numericSpacing--proportional Text-typeface--base Text-wrap--noWrap Text-display--block" style="margin-top: -1px;">
<span>Resend email</span></span></div></div></button></div></div></div>

UPD:解决了该问题。如果您遇到相同的问题,请尝试更改浏览器配置文件/使用默认选项启动

1 个答案:

答案 0 :(得分:0)

我能够单击它。。。不确定您这边是什么问题...

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox(executable_path=r'D:\geckodriver.exe')
driver.get('https://stripe.com/')

#click on Sign-in
driver.find_element_by_xpath('/html/body/header/div[1]/nav/ul/li[3]/a[2]/span').click()

#send email
driver.find_element_by_xpath('//*[@id="email"]').send_keys("abc@gmail.com")

#send password
driver.find_element_by_xpath('//*[@id="old-password"]').send_keys("akldjfkajdf")

#click on continue
driver.find_element_by_xpath('/html/body/div/div/div[2]/div[2]/div/div[2]/div/div/div/div/div[2]/div/div/div[2]/div/div/div/div[2]/form/div/div/div/div[4]/div/div/div/div/div/div[1]/button/div/div[2]/span').click()

#click on skip for now
driver.find_element_by_xpath('/html/body/div/div/div[2]/div[3]/div/div/div/a/span').click()

#click on verify you email
driver.find_element_by_xpath('/html/body/div[2]/span/div/div/div[1]/div/div[2]/div[2]/div/span/div/div[4]/div[2]/div/div/div/div/div[1]/div/div/div/div[2]/div[2]/span/span').click()

#click on resend email
driver.find_element_by_xpath('/html/body/div[2]/span/div/div/div[1]/div/div[2]/div[2]/div/span/div/div[4]/div[2]/div/div/div/div[2]/div[2]/div/div/div/div/div[2]/button/div/div[2]/span/span').click()