【问题标题】:Selenium - compound class names not permitted [duplicate]Selenium - 不允许使用复合类名[重复]
【发布时间】:2018-05-19 05:58:08
【问题描述】:

我正在尝试获取具有特定类名的所有元素:

theButtons = browser.find_elements_by_class_name("Icon Icon--medium Icon--reply");

但是我得到了错误:

Compound class names not permitted

我知道类名中不允许有空格来获取,但是那我该怎么办呢?

谢谢

【问题讨论】:

  • 试试我的答案,让我知道

标签: python selenium


【解决方案1】:

试试 xpath:

theButtons = browser.find_elements_by_xpath("//*[contains(@class,'Icon Icon--medium Icon--reply')]");

theButtons = browser.find_elements_by_xpath("//*[@class='Icon Icon--medium Icon--reply']");

如果我错了,请替换引号,因为我对 Python 的了解较少

【讨论】:

    猜你喜欢
    • 2020-11-04
    • 1970-01-01
    • 2023-03-29
    • 2015-04-15
    • 2015-11-09
    • 2019-04-30
    • 1970-01-01
    • 2019-12-08
    • 1970-01-01
    相关资源
    最近更新 更多