【问题标题】:How to click on a class with a dynamic variable如何单击具有动态变量的类
【发布时间】:2019-06-11 00:43:00
【问题描述】:

我希望能够通过 cluster-id-hash="foobar" 进行搜索和点击,但我也做不到。找不到元素

以下是页面上的一些 css 示例

<div class="ancCol w33 person-panel" _ngcontent-c6="" cluster-id-hash="KYDQEX8il7BIG2"></div>

or
<div class="ancCol w33 person-panel annColRow" _ngcontent-c6="" cluster-id-hash="5gamjajdkjgPcma">

我已经尝试过,其中 clusterIdHash 是我传递的字符串:

driver.findElement(By.cssSelector(".cluster-id-hash='" + clusterIdHash )).click();

【问题讨论】:

    标签: java selenium web automation driver


    【解决方案1】:

    想通了

    driver.findElement(By.cssSelector("[cluster-id-hash='" + clusterIDHash + "']")).click();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-19
      • 1970-01-01
      • 1970-01-01
      • 2019-09-15
      • 1970-01-01
      • 1970-01-01
      • 2010-12-01
      相关资源
      最近更新 更多