Python 我能';无法通过Selenium ElementNotInteractiableException:按钮无法滚动到视图中
有3个按钮,每个按钮在网站上标记为相同的东西。如何在python中单击第二个按钮Python 我能';无法通过Selenium ElementNotInteractiableException:按钮无法滚动到视图中,python,selenium,beautifulsoup,Python,Selenium,Beautifulsoup,有3个按钮,每个按钮在网站上标记为相同的东西。如何在python中单击第二个按钮 <button type="button" class="btn btn-primary checkout-step-action-done layout-quarter"> 我在pastebin上粘贴HTML,因为它很长。我建议使用ctrl-f查找这3个按钮。我想点击的按钮上写着“继续付款”。这种方法似乎适合我,但我确信有更好的解决方案 button = d
<button type="button" class="btn btn-primary checkout-step-action-done layout-quarter">
我在pastebin上粘贴HTML,因为它很长。我建议使用ctrl-f查找这3个按钮。我想点击的按钮上写着“继续付款”。这种方法似乎适合我,但我确信有更好的解决方案
button = driver.find_elements_by_css_selector(".layout-quarter")
for value in button:
if value.text == 'CONTINUE TO PAYMENT':
value.click()
好的,我已经解决了这个问题。通过使用这个,我可以缩短代码
driver.find_elements_by_css_selector(".layout-quarter")[1].click()
驱动程序。通过_css_选择器(“[value='CONTINUE TO PAYMENT']”)查找_元素。单击()
driver.find_elements_by_css_selector(".layout-quarter")[1].click()