0

DOM Explorer of the object :

<INPUT tabIndex=0 onkeyup=DisableEnableFields(); onblur=autoValidate(this) id=prvd_org_name onkeydown="return HandleMaxLengths(this, 70,event,'','');" maxLength=70 size=120 name=prvd_org_name isRequired="false" ValidationType="ALPHANUMERICSPACEPUNCTUATION">

Please help me with the xpath

Tried below xpaths :

driver.findElement(By.xpath("//input[@name ='prvd_org_name']"))
driver.findElement(By.xpath("//input[@type= text and @name ='prvd_org_name']"))

Please gimme different alternatives as for the above two it gives me unable to find element

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

1 Answers1

0

To identify the element you can use either of the following Locator Strategies:

  • cssSelector:

    WebElement element = driver.findElement(By.cssSelector("input#prvd_org_name[name='prvd_org_name']"));
    
  • xpath:

    WebElement element = driver.findElement(By.xpath("//input[@id='prvd_org_name' and @name='prvd_org_name']"));
    

However, as the element is a dynamic element so to identify the element you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:

  • cssSelector:

    WebElement element = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input#prvd_org_name[name='prvd_org_name']")));
    
  • xpath:

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