‘UnexpectedTagNameException’ and Element should have been “select” but was “div” error using ‘Select’ function through Selenium java

This error message…

'UnexpectedTagNameException' : Element should have been "select" but was "div"

…implies that you have used Select class to interact with the element where as the element was a <div>.

To click() on the element with text as Borrowing Capacity you can use the following Locator Strategy:

  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//h4[@class="bta-description" and text()='Our calculators']//following::div[@class="bta-select-table row"]//b[@class="button"]"))).click();
    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class="selectric-items"]//li[contains(., 'Borrowing Capacity')]"))).click();
    
  • Browser Snapshot:

BorrowingCapacity

Leave a Comment