【问题标题】:how to select value from drop down and click on it which is in div in javascript or jquery?如何从下拉列表中选择值并单击 javascript 或 jquery 中的 div 中的值?
【发布时间】:2018-01-18 04:52:18
【问题描述】:
如何从下拉列表中选择值并单击它在javascript或jquery中的div中?尝试在搜索框中输入值并从下拉列表中选择并单击它,需要自动化。
该值在 ul -> li -> div 中。
没有选择标签,输入标签使用type='text'和role="combobox",也没有href标签。
代码在AngularJs中
【问题讨论】:
标签:
javascript
jquery
selenium-webdriver
【解决方案1】:
这是我开发的一个库
$(document).ready(function(){
$(".test").autoFill({
textField: "name",
valueField:"id",
datasource:[{name:'tst', id:"0", href:"https://www.google.se"}, {name:'tst10', id:"1", href:"https://www.microsoft.se"}],
onSelect: function(settings){
alert(settings.selectedItem.href);
}
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/AlenToma/LightData.CMS/master/source/LightData.CMS/Content/Script/JqAutoFill.js"></script>
<link type="text/css" rel="stylesheet" href="https://rawgit.com/AlenToma/LightData.CMS/master/source/LightData.CMS/Content/Styles/JqAutoFill.css" />
<input type="text" class='test' value='None' />