0

I'm using the line of code:

driver.findElement(By.xpath("//*[@id=\"sernum\"]")).sendKeys("XXXXXXXXXX");

All I need to do is insert a value in the field. But it isn't work...

The fragment from "dom":

enter image description here

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
KattyZa
  • 11
  • 1

1 Answers1

0

To send a character sequence within the <input> field as the element is a dynamic element you need to use WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:

  • cssSelector:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input#sernum[name=\"sernum\"]"))).sendKeys("XXXXXXXXXX");
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='sernum' and @name=\"sernum\"]"))).sendKeys("XXXXXXXXXX");
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352