我正在尝试查找页面上尚未点击或“收藏”的所有元素。
这是收藏的元素的 html:
<a class="button-fave unfavorited-button favorited-button" rel="78853399" alt="Add to favorites">
<div class="button-spinner"></div>
<span class="status-text">Favorite</span>
</a>
以下是不收藏该元素时的 html 代码:
<a class="button-fave unfavorited-button" rel="78853399" alt="Add to favorites">
<div class="button-spinner"></div>
<span class="status-text">Favorite</span>
</a>
我努力了:
driver.find_element_by_class_name('button-fave unfavorited-button')
但我得到以下信息:
给定的选择器 button-fave unfavorited-button 无效或不会生成 WebElement。发生以下错误: InvalidSelectorError: Compound class names not allowed
以下工作,但它不区分喜欢的元素和不喜欢的元素:
driver.find_element_by_class_name('button-fave')