【问题标题】:How can I use css selector to find elements after some element [duplicate]如何使用css选择器在某些元素之后查找元素[重复]
【发布时间】:2019-10-05 19:40:10
【问题描述】:

我有这个 html 代码

.......
<div class="list-rows> </div>
<div class="list-rows> </div>

<div class="cat-row"><span>Topics</span></div>
<div class="list-rows> </div>
<div class="list-rows> </div>
<div class="list-rows> </div>

现在我想找到所有具有 list-rows 类但在此元素之后的 div &lt;div class="cat-row"&gt;&lt;span&gt;Topics&lt;/span&gt;&lt;/div&gt;

div.cat-row +list-rows 不工作

【问题讨论】:

  • 你是不是在 list-rows 后面漏掉了一个引号

标签: html css selenium css-selectors


【解决方案1】:

【讨论】:

    【解决方案2】:

    您需要在 html 中的类名上加上右引号,并且应该使用 div.cat-row+.list-rows 之类的东西作为选择器。

    【讨论】:

      【解决方案3】:

      结合评论和前面两个答案:

      • 大部分class= 属性都缺少右引号。
      • CSS list-rows 前面没有 . 以表明它一个类。
      • CSS 中的+下一个弟弟妹妹)应该是波浪号~所有弟弟妹妹)。

      【讨论】:

        猜你喜欢
        • 2021-11-17
        • 2020-04-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-04
        • 1970-01-01
        相关资源
        最近更新 更多