0

I have XML as below:

<input name="_jpfcpncuivr___ns535482039__j_id__ctru0:fragmentRegionStatic:0:it1" maxlength="6" style="text-transform:uppercase" type="text" class="af_inputText_content" id="_jpfcpncuivr___ns535482039__j_id__ctru0:fragmentRegionStatic:0:it1::content">

I have tried driver.findElement by id, name, className, cssSelector, or xpath but all failed and got an error:

no such element: Unable to locate element:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

The desired element is a dynamic element so to locate and click() on the element you need 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("input[class$='inputText_content'][id*='fragmentRegionStatic']"))).click();
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[contains(@class, 'inputText_content') and contains(@id, 'fragmentRegionStatic')]"))).click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352