我有一个从Ajax请求返回的json数组,如下所示。
WebDriverWait wait = new WeBDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("")));
我想抓取每个数据,并在选择框中选择它。但是jquery代码不起作用。谢谢你的帮助。
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.53.0</version>
</dependency>
答案 0 :(得分:1)
var response = {
"success":true,
"message":null,
"messages":null,
"data":[
{"Type":"Model","Value":"A Model"},
{"Type":"Model","Value":"B Model"}
]
}
$.each(response.data, function(key, val){
$('select').append('<option id="' + val.Value + '">' + val.Value +'</option>');//missing +
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select></select>