如何在Web浏览器中选择淹没列表选项 [英] How to selected drowndown list options in web browser

查看:171
本文介绍了如何在Web浏览器中选择淹没列表选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在从事Web浏览器自动化项目.网站上有一个受ajax控制的下拉列表.

Im working a web browser automation project. There is an ajax controlled dropdown list in a web site.

就是这样;

< option value ="test1"> test1</option>
< option value ="test2"> test2</option>
< option value ="test3"> test3</option>
< option value ="test4"> test4</option>
< option value ="test5"> test5</option>

<option value="test1">test1</option>
<option value="test2">test2</option>
<option value="test3">test3</option>
<option value="test4">test4</option>
<option value="test5">test5</option>

当我被选中时,test2 ajax正在工作,并且给了另一个div. (我需要这个div)

When i was selected test2 ajax is working and its giving another div. (I need this div)

我使用此代码;

webbrowser1.Document.GetElementsByTagName("select")[0] .Document.GetElementsByTagName("option")[1] .SetAttribute("selected","selected");

webbrowser1.Document.GetElementsByTagName("select")[0].Document.GetElementsByTagName("option")[1].SetAttribute("selected", "selected");

它仅更改属性,因此,它不起作用ajax.

Its only changing attribute and for this reason it doesnt working ajax.

如何选择选项1?

谢谢.

推荐答案

var chkBoxList = document.getElementById(''drowndownlist1''); var chkBoxes = chkBoxList.getElementsByTagName("input"); chkBoxes [0] .checked = true;
var chkBoxList = document.getElementById(''drowndownlist1''); var chkBoxes = chkBoxList.getElementsByTagName("input"); chkBoxes[0].checked = true;


是的,最后我已经完成了.

Yes, at last end i have done it.

webbrowser1.Document.GetElementsByTagName("select")[0].Document.GetElementsByTagName("option")[2].SetAttribute("selected", "selected");
webbrowser1.Document.InvokeScript("__doPostBack");



它运行良好.
谢谢大家.



Its working perfectly.
Thanks for all.


这篇关于如何在Web浏览器中选择淹没列表选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆