我的Html
} else if ($post->post_type == 'specialisaties') {
$meta_boxes = [specialisaties_post_meta_boxes(), url_post_meta_boxes()];
}
我的java
<div id="example-1-tab-2" class="responsive-tabs-panel" style="display: none;">
<div class="freme_box">
<iframe class="demo-frame" src="dropdown/default1.html">
<html lang="en">
<head>
</head>
<body>
<div class="ui-widget">
<select id="combobox" style="display: none;">
<option selected="" value="Please Enter">Please Enter</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
</select>
<span class="custom-combobox">
<input class="custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left ui-autocomplete-input" title="" autocomplete="off">
<a class="ui-button ui-widget ui-state-default ui-button-icon-only custom-combobox-toggle ui-corner-right" tabindex="-1" title="Show All Items" role="button">
<span class="ui-button-icon-primary ui-icon ui-icon-triangle-1-s"></span>
<span class="ui-button-text"></span>
</a>
</span>
</div>
</body>
</html>
</iframe>
</div>
我能够从下拉列表中打印所有数据,但这不是我的意图。我只想从该列表中选择一个特定值。如何做到这一点?
答案 0 :(得分:0)
编写代码以点击此范围以关闭下拉选项。
xpath - "//span[@class='ui-button-icon-primary ui-icon ui-icon-triangle-1-s']"
等待显示选项。选择说阿尔及利亚并点击它。
xpath - "//ul[@id='ui-id-1']/li[text()='Algeria']"
答案 1 :(得分:0)
请使用以下代码:
driver.switchTo().frame(driver.findElement(By.cssSelector("iframe.demo-frame"));
// Select class is used to handle drop-downs
Select dropDown = new Select(driver.findElement(By.id("combobox"));
dropDown.selectByVisibleText("<Option you need to select>");
希望这有帮助。