Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

html - Element should have been "select" but was "div" getting an error in selenium

Here is the HTML code, i'm trying to select 'select customer' drop-down.

<div id="createTasksPopup_customerSelector" class="customerOrProjectSelector selectorWithPlaceholderContainer at-dropdown-list-btn-ct notSelected">
    <table id="ext-comp-1057" class="x-btn-wrap x-btn at-dropdown-list-btn x-btn-over x-btn-focus" cellspacing="0" cellpadding="0" border="0" style="width: auto;">
       <tbody>
             <tr id="ext-gen397" class=" x-btn-with-menu">
                  <td class="x-btn-left">
                      <td class="x-btn-center">
                          <em unselectable="on">
                              <button id="ext-gen391" class="x-btn-text" type="button">- Select Customer -</button>
                          </em>
                      </td>
                 <td class="x-btn-right">
            </tr>
        </tbody>
    </table>
</div>

Image - enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

First check that:

Drop down in your UI/FrontEnd is using "select" method or not ?

And if not then use below snippet that will click in drop down and select value.

WebElement selectMyElement = driver.findElement(this.getObject(By.Id("Id of Your DropDown"))); 
selectMyElement.click();

Actions keyDown = new Actions(driver);
keyDown.sendKeys(Keys.chord(Keys.DOWN, Keys.DOWN)).perform();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...