我希望能够通过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();
答案 0 :(得分:2)
想通了
driver.findElement(By.cssSelector("[cluster-id-hash='" + clusterIDHash + "']")).click();