Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我能';无法通过Selenium ElementNotInteractiableException:按钮无法滚动到视图中_Python_Selenium_Beautifulsoup - Fatal编程技术网

Python 我能';无法通过Selenium ElementNotInteractiableException:按钮无法滚动到视图中

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

有3个按钮,每个按钮在网站上标记为相同的东西。如何在python中单击第二个按钮

<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()