如何更改此选择器路由,以便将其作为参数传递给Selenium?

问题描述 投票:0回答:1

我想单击该按钮,但是我不知道如何更改路线。我想使用选择器来完成此操作,因此可以将其置于无限循环中,并遍历整个YouTube列表。

boton = '#movie div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-left-controls > a.ytp-next-button.ytp-button'
buscador.find_element_by_css_selector(boton).click()
python html selenium button selector
1个回答
0
投票

如果您尝试单击每个按钮,则可以执行以下操作

boton = '#movie div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-left-controls > a.ytp-next-button.ytp-button'
numberOfButtons = len(driver.find_elements_by_css_selector(boton))

# now iterate through all the buttons and click on them
for counter in range(numberOfButtons):
    driver.find_elements_by_css_selector(buton)[counter].click()

© www.soinside.com 2019 - 2024. All rights reserved.