问题描述
你好,
我正在从事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?
谢谢.
推荐答案
webbrowser1.Document.GetElementsByTagName("select")[0].Document.GetElementsByTagName("option")[2].SetAttribute("selected", "selected");
webbrowser1.Document.InvokeScript("__doPostBack");
它运行良好.
谢谢大家.
Its working perfectly.
Thanks for all.
这篇关于如何在Web浏览器中选择淹没列表选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!