Akshay Puthran
Akshay Puthran

Reputation: 1

Element should have been "select" but was "input" how can I resolve this error

My Code:

    loginPage.waitHomePage(60,"Order Scheduling");
    Assert.assertEquals("Order Scheduling",driver.getTitle());

    (new WebDriverWait(driver, 40)).until(ExpectedConditions.presenceOfElementLocated(By.id("ctl00_ContentPlaceHolderBody_orderDeliveryControl_lstDelivery_ctrl0_deliveryPanelBar_i0_lstOrderRequestItems_ctrl0_deliveryDetailControl_lstDeliveryLineItem_ctrl0_lineItemControl_lstBuyLineItems_ctrl0_buyLineItemControl_cmbSupplier_Input")));
    Assert.assertTrue(driver.findElement(By.id("ctl00_ContentPlaceHolderBody_orderDeliveryControl_lstDelivery_ctrl0_deliveryPanelBar_i0_lstOrderRequestItems_ctrl0_deliveryDetailControl_lstDeliveryLineItem_ctrl0_lineItemControl_lstBuyLineItems_ctrl0_buyLineItemControl_cmbSupplier_Input")).isDisplayed());
    Select abcSupplier = new Select(driver.findElement(By.id("ctl00_ContentPlaceHolderBody_orderDeliveryControl_lstDelivery_ctrl0_deliveryPanelBar_i0_lstOrderRequestItems_ctrl0_deliveryDetailControl_lstDeliveryLineItem_ctrl0_lineItemControl_lstBuyLineItems_ctrl0_buyLineItemControl_cmbSupplier_Input")));
    /*abcSupplier.selectByIndex(17);*/
    abcSupplier.selectByVisibleText("TBD");
}

HTMl Code:

<input 
    name="ctl00$ContentPlaceHolderBody$orderDeliveryControl$lstDelivery$ctrl0$deliveryPanelBar$i0$lstOrderRequestItems$ctrl0$deliveryDetailControl$lstDeliveryLineItem$ctrl0$lineItemControl$lstBuyLineItems$ctrl0$buyLineItemControl$cmbSupplier" 
    type="text"
    class="rcbInput radPreventDecorate Required_Field_Control Required_Field_Control_Off"   
    id="ctl00_ContentPlaceHolderBody_orderDeliveryControl_lstDelivery_ctrl0_deliveryPanelBar_i0_lstOrderRequestItems_ctrl0_deliveryDetailControl_lstDeliveryLineItem_ctrl0_lineItemControl_lstBuyLineItems_ctrl0_buyLineItemControl_cmbSupplier_Input"
    value="Mansfield Oil Company of Gainesville Inc" 
    autocomplete="off">

Where did I go wrong?

Upvotes: 0

Views: 128

Answers (1)

AlexR
AlexR

Reputation: 115398

Examine this line:

Select abcSupplier = new Select(driver.findElement(By.id("ctl00_ContentPlaceHolderBody_orderDeliveryControl_lstDelivery_ctrl0_deliveryPanelBar_i0_lstOrderRequestItems_ctrl0_deliveryDetailControl_lstDeliveryLineItem_ctrl0_lineItemControl_lstBuyLineItems_ctrl0_buyLineItemControl_cmbSupplier_Input")));

You are expecting element of type Select but path that you are sending to function findElement ends by Input. IMHO this clearly hints that something is wrong either in your ID or in expected element type. It is impossible to give you more concrete answer since only you know the exact structure of HTML document you are working with. But you have to provide correct ID and treat element according to its actual type.

Upvotes: 1

Related Questions