gpt4 book ai didi

java - 元素应该是 "select",但却是 "input"我该如何解决此错误

转载 作者:行者123 更新时间:2023-12-02 09:53:16 24 4
gpt4 key购买 nike

我的代码:

    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 代码:

<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">

我哪里出错了?

最佳答案

检查这一行:

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")));

您需要 Select 类型的元素,但发送到函数 findElement 的路径以 Input 结尾。恕我直言,这清楚地暗示您的 ID 或预期的元素类型有问题。不可能给你更具体的答案,因为只有你知道你正在使用的 HTML 文档的确切结构。但您必须提供正确的 ID 并根据元素的实际类型对待元素。

关于java - 元素应该是 "select",但却是 "input"我该如何解决此错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56162301/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com