select a value in <input> based dropdown using selenium webdriver with c#

1,598 views
Skip to first unread message

Jane Jin

unread,
Feb 8, 2017, 5:34:20 PM2/8/17
to webdriver

Hi,

 

 I am trying this code to select an <input> based dropdown value using selenium webdriver with c#

 

    IWebElement e1 = dr.FindElement(By.XPath("//*[@hiddenControlId='list_type_select']"));

           E1.Click();

 

 

   IWebElement e2 = dr.FindElement(By.XPath("//*[contains(@drop_info,'Users')]"));

            E2.Click();

 

The e1 part work fine, but the e2 part throw “ElementNotVisible” exception.

 

 

Following is the HTML:


<div id="list_type">
    <div class="linear labelRight cols">
        <div class="col-2-1">
            <div p="" nolabel="">
                <input name="ctl56" title="Professional" class="dropdown dropdownMouseOut" id="ctl56" onclick="DoDropDown( 'ctl56' )" type="text" readOnly="" value="Professional" dropdownMode="L" dropImage="ctl57" DefValue="Professional" showClear="0" selectMode="S" hiddenControlId="list_type_select" delimiter="; " useParentWidth="1" localDropdownId="ctl39" textBasedSelection="1" clearString="Clear" currentText="Professional">

                <div id="ctl39" style="display: none;">
                    <div class="boxInner" id="dynamicFrame">
                        <div class="grid gridDefault" id="grid_generictablename" ondragenter="InDrag(event)" ondragover="InDrag(event)" ondragleave="OutDrag(event)" ondrop="FinishDrag('_dd_list_type_select', event)" detach="1" drop_types="X" drop_type="XXX" name="grid_generictablename">
                            <div style="width: 100%; height: 300px; vertical-align: top; overflow-x: auto; overflow-y: auto;" table="_dd_list_type_select" body="" resize="v" grid3_id="_dd_list_type_select_scroll_hv">
                                <table id="_dd_list_type_select" style="width: 100%;" ondragstart="StartDrag(event)" cellSpacing="0" cellPadding="1" PageSize="73" HasTotals="0" FilteredRows="0" RenderFullVisualEffect="0" remote="1" PagerStyle="Numeric" SelectedItems="" PagingDisabled="true" DeselectedItemsId="des_grid_generictablename" drag_type="XXX" CopiedItemsId="cpy_grid_generictablename" PageNumber="1" FooterSize="0" PageButtonCount="5" HeaderSize="0" drag_action="Move" PagerSize="0">
                                    <tbody>
                                        <tr drop_info="Professional" Selectable="true" drag_info="SCFN">
                                            <td style="width: 100%;"><nobr>Professional</nobr></td>
                                        </tr>
                                                                   
                                        <tr drop_info="Users" Selectable="true" drag_info="UROL">
                                            <td style="width: 100%;"><nobr>Users</nobr></td>
                                        </tr>
                                        ...
                                    </tbody>
                                </table><span style="display: none;"></span></div>
                    ...
       


I am using selenium webdriver v3, IE 11.

 

Thanks in advance.







darrell grainger

unread,
Feb 9, 2017, 7:30:44 AM2/9/17
to webdriver
WebDriver requires EXACT instructions. In many cases you might think the test steps are:
  1. Click input
  2. Click type
But the reality is that the test steps are:
  1. Click input
  2. Wait for type to be visible
  3. Click type
There is a WebDriverWait class. You instantiate a WebDriverWait class using the instance of WebDriver you created (dr). Then you can use the instance of WebDriverWait for step 2.
Reply all
Reply to author
Forward
0 new messages