【发布时间】:2018-07-13 10:45:34
【问题描述】:
这是我在 HTML 上的元素:
<a aria-role="button" href="" class="sc-button-play playButton sc-button sc-button-xlarge" tabindex="0" title="Play" draggable="true">Play</a>
我使用 Selenium 来制作点击事件:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get(url)
buttons = driver.find_elements_by_class_name('playButton')
你可以猜到,它不起作用:)
【问题讨论】:
-
用 xpath 试试
-
我只看到人们使用元素的id,所以我不知道如何使用他的类
-
就像@ThatBird 说的,试试
xpath。如果您不熟悉它,请使用 chrome 插件“xPath Finder”。 -
我在您的代码中没有看到对 click() 方法的任何调用。一旦你有了按钮,你会用它做什么?此外,当您说它不起作用时,您会收到什么错误/异常消息。这将为我们提供有关问题的线索。
标签: python html selenium selenium-webdriver