【问题标题】:can't click button with selenium python无法单击带有 selenium python 的按钮
【发布时间】:2020-03-06 00:55:44
【问题描述】:

我找不到用硒按下按钮的方法。试图按名称和xpath单击它,但没有用。 这是此网站上的登录按钮 - https://account.envato.com/sign_in?to=audiojungle

这是按钮的代码:

<input type="submit" name="commit" value="Sign in to your account" class="js-sign-in__submit e-btn--3d -color-primary -size-m -width-full h-mb2 h-mt1">

如果我尝试通过 x 路径找到它,使用 - driver.find_element_by_xpath('//*[@id="sign-in-form"]/div[6]/input').click() 或使用 - driver.find_element_by_name('commit').click()

它带来了这个问题-

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <input type="submit" name="commit" value="Sign In"formnovalidate="formnovalidate" data-disable-with="Sign In"> is not clickable at point (789, 309). Other element would receive the click: <p style="">...</p>

我不记得我尝试过的所有事情,但我希望你能理解我。我在互联网上没有找到解决方案,所以我希望你能帮助我,谢谢)

【问题讨论】:

  • 你能分享你剩下的代码吗?这将帮助我们弄清楚正在发生的事情以及如何最好地提供帮助。
  • 嗨,Alex,看起来你有异步加载的东西,我假设你在提交之前在该表单中做了其他事情,这会导致问题。

标签: python selenium selenium-webdriver button


【解决方案1】:

试试这个: 选项 1:

wait.until(ec.visibility_of_element_located((By.XPATH,"Your xpath")

选项 2: 检查它是否不在 iframe 中。

选项 3: 使用 Action 或 Javascript 点击按钮。 希望这会有所帮助。

【讨论】:

  • 感谢您的回答,我尝试使用 wait.until 函数,但它带来了另一个问题,我找到了这个解决方案 - button = driver.find_element_by_xpath('//*[@id="sign -in-form"]/div[6]/input') driver.execute_script("arguments[0].click();", button)
  • 无法理解为什么只有这种方法有效,发现它的人也不知道为什么这种方法有效)
猜你喜欢
  • 2015-09-26
  • 1970-01-01
  • 1970-01-01
  • 2019-02-27
  • 2021-08-13
  • 2020-07-30
  • 1970-01-01
  • 1970-01-01
  • 2020-04-14
相关资源
最近更新 更多