0

I've written some code to send input to a textbox as shown below :

enter image description here

enter image description here

enter image description here However during execution, the webdriver returns ElementNotInteractableException even though it shows the input type is a textbox.

I've tried to send input using the following ways but have been unsuccessful, seeking advice, thanks!:

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'");
theduck
  • 2,589
  • 13
  • 17
  • 23
  • 1
    Have you seen this answer? https://stackoverflow.com/a/46601444/1230748 – dcalap Jan 03 '20 at 09:26
  • I tried using the wait() methods you've described in that post, it still does not work, I did notice when I use excecuteScript(), the code runs without any exceptions but nothing is inputted into the textbox `Code WebElement element=driver.findElement(By.xpath("//input[@name='bkg_no']")); JavascriptExecutor executor = (JavascriptExecutor)driver; executor.executeScript("arguments[0].click();", element); executor.executeScript("arguments[0].value='ABCDE90003330';",element); ` – Jeevan Daniel Mahtani Jan 03 '20 at 10:15

1 Answers1

0

To send a character sequence to the <input> you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • cssSelector:

    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");
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • This did not seem to work, the element can only be somehow found by its relative xpath //input[@name='bkg_no'] . The weird thing is when I use the selenium IDE addon in chrome, its able to find the inputbox by name and when I playback the recording, it seems to work successfully, no idea why :/ – Jeevan Daniel Mahtani Jan 06 '20 at 04:32