我試圖訪問此div並稍後單擊它。無法使用cssSelector定位元素
<div class="leaflet-marker-icon marker-cluster marker-cluster-small leaflet-clickable leaflet-zoom-animated" style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; opacity: 1; transform: translate(702px, 396px); z-index: 396;" title="13 tracks listened in , UA">
這裏就是我想要做的事:
WebElement cluster = driver.findElement(By.cssSelector("marker-cluster-small"));
這裏就是我試圖做的事:
WebElement cluster = driver.findElement(By.xpath("//div[@class='leaflet-marker-icon marker-cluster marker-cluster-small leaflet-clickable leaflet-zoom-animated']"));
的方法都不奏效。第一個引發「無法定位元素」消息。第二個沒有錯誤,但當我這樣做時:
cluster.click();
沒有任何反應。 我在做什麼錯? 謝謝。
單擊此元素時的預期操作是什麼? – Seanny123
如果沒有直接的命令工作,那麼使用JSExecutor作爲最後的手段。請參閱 - http://docs.seleniumhq.org/docs/03_webdriver.jsp#using-javascript。 – Akbar