使用硒在下拉菜单中选择一个选项
问题描述:
有人可以帮我选择选项查询从下面的代码?我尝试过但失败。使用硒在下拉菜单中选择一个选项
<div class="SplitButton" id="HIRA_SPLITBUTTON" splitBtnName="pyDescription" btnType = "menu" onSplMenuClick='HIRA.ui.gadget.NewWork.StartProcess4Menu'>
<select id="pyDescription">
<option value='className=HIRAFS-Work-Inquiry&flowType=Inquiry&HarnessVersion=1'> Inquiry </option>
<option value='className=HIRAFS-Work-Copy&flowType=Copy&HarnessVersion=1'> Copy </option>
</select>
<table class='buttonMainTable' border='0' cellspacing='0' cellpadding='0' id='' >
<tr>
<td class='buttonTdLeft'>
<div class="buttonLeftContent">
<div class="buttonLeftContentInner">
</div>
</div></td><td class='buttonTdMiddle'>
<button class='buttonTdButton' alt='' title='' HIRA_VERSION='HTMLPROPERTY' id='HIRA_SPLITBTNpyDescription'>
<table cellspacing='0' cellpadding='0'>
<tr>
<td valign='top'><img src='desktopimages/new.gif' style='margin-top:-1px'/></td><td valign='middle' style='white-space:nowrap;'>New</td>
</tr>
</table></span>
</button></td><td class='buttonTdRight'>
<div class="buttonRightContent">
<div class="buttonRightContentInner">
</div>
</div></td>
</tr>
</table>
</div>
答
您必须引用的webdriver支持DLL做到以下几点。
SelectElement select = new SelectElement(element);
select.SelectByText("Inquiry");
如果您使用的是带有的NuGet视觉工作室,那么你可以去你的PowerShell并键入
Install-Package Selenium.Support
,这将安装所有你所需要的参考资料和DLL。
+0
不得不离开这个...一段时间,忙于一些事情。我仍然无法选择 – Srinivas
@strah:你是怎么处理这个[建议编辑](http://stackoverflow.com/suggested-edits/612169)的评论?此处的编辑历史记录建议您选择修改建议,但没有审核操作的记录。想要过来[这个元问题](http://meta.stackexchange.com/questions/170175/community-is-a-review-monkey-too/170176#170176)并在你身边添加发生在这里的事情? –