gpt4 book ai didi

java - WebDriver 未检测到输入文本框,抛出 ElementNotInteractableException : element not interactable

转载 作者:行者123 更新时间:2023-12-01 19:05:08 25 4
gpt4 key购买 nike

我编写了一些代码来将输入发送到文本框,如下所示:

enter image description here

enter image description here

enter image description here然而,在执行过程中,即使 Webdriver 显示输入类型是文本框,也会返回 ElementNotInteractableException。

我尝试使用以下方式发送输入但没有成功,寻求建议,谢谢!:

1)

driver.findElement(By.xpath("//input[@name='bkg_no']")).sendKeys("ABCDE9000333");

2)

String bkg = "ABCDE9000333"
WebElement bkgNo = driver.findElement(By.xpath("//input[@name='bkg_no']"));";
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("arguments[0].value="+bkg+";", bkgNo);

3)

driver.findElement(By.name("bkg_no")).sendKeys("ABCDE9000333");

4)

JavascriptExecutor jse = (JavascriptExecutor)driver;    
jse.executeScript("document.getElementByName('bkg_no').value='PKG900890300'");

最佳答案

字符序列发送到 <input>你必须诱导WebDriver等待element_to_be_clickable()您可以使用以下任一 Locator Strategies :

  • css选择器:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("form[name='form'][onkeydown*='search'] div.wrap_search input.input[name='bkg_no']"))).sendKeys("ABCDE9000333");
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//form[@name='form' and contains(@onkeydown, 'search')]//div[contains(@class, 'wrap_search')]//input[@class='input' and @name='bkg_no']"))).sendKeys("ABCDE9000333");

关于java - WebDriver 未检测到输入文本框,抛出 ElementNotInteractableException : element not interactable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59575870/

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