Выбор опции в выпадающем меню с помощью Selenium - PullRequest
0 голосов
/ 17 ноября 2011

Может ли кто-нибудь помочь мне в выборе опции Запрос из приведенного ниже кода? Я пытался, но не получилось.


<div class="SplitButton" id="HIRA_SPLITBUTTON" splitBtnName="pyDescription" btnType = "menu" onSplMenuClick='HIRA.ui.gadget.NewWork.StartProcess4Menu'>
    <select id="pyDescription">
        <option value='className&#61;HIRAFS-Work-Inquiry&amp;flowType&#61;Inquiry&amp;HarnessVersion&#61;1'> Inquiry </option>
        <option value='className&#61;HIRAFS-Work-Copy&amp;flowType&#61;Copy&amp;HarnessVersion&#61;1'> Copy </option>
    </select>
    <table class='buttonMainTable' border='0' cellspacing='0' cellpadding='0' id='' >
        <tr>
            <td class='buttonTdLeft'>
            <div class="buttonLeftContent">
                <div class="buttonLeftContentInner">
                    &nbsp;
                </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">
                    &nbsp;
                </div>
            </div></td>
        </tr>
    </table>
</div>

1 Ответ

1 голос
/ 17 ноября 2011

Вам необходимо обратиться к dll поддержки webdriver, чтобы сделать следующее.

SelectElement select = new SelectElement(element);
select.SelectByText("Inquiry");

Если вы используете Visual Studios с NuGet, вы можете перейти к PowerShell и набрать

Install-Package Selenium.Support

, и это установит все необходимые вам ссылки и библиотеки.

...