![](/img/trans.png)
[英]How to check the presence of an element without using findElement() or findElements() in java-selenium?
[英]how to check checkbox in dropdownmenu using findElements and get ? (java/seleniumWebDriver)
那就是因為您要在//ul[@class='dropdown-menu js-dropdown-menu dropdown-menu-form']/li/div/label/span/span[@class='check']
中查找所有包含類'check'的元素//ul[@class='dropdown-menu js-dropdown-menu dropdown-menu-form']/li/div/label/span/span[@class='check']
,只有一個元素。 另外,您是否需要使用List? 我的意思是,您可以按如下所示直接單擊它:如果您想單擊“ Do ustalenia”,
driver.findElement(By.xpath("//ul[@class='dropdown-menu js-dropdown-menu dropdown-menu-form']/li/div/label/span/span[@class='check']")).click();
或者您可以共享更多HTML復選框。 我對此猜測:
List<WebElement> checkboxes = driver.findElements(By.xpath("//span/span[@class='check']")); // this will find all span elements with class 'check' inside li/div/label
checkboxes.get(1).click();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.