0

Unable to click on element though Web driver is able to find it.

Already implicit wait applied. Also,tried explicit wait but when explicit wait getting error element is not attached to page

WebElement sales_order_doc_type_dropdown = driver.findElement(By.xpath("//input[@id='WD67']"));
sales_order_doc_type_dropdown.click();

HTML Code for element

<input id="WD67" ct="CB" lsdata="{1:'26.4ex',5:true,8:'WD68',9:'1'}" lsevents="{Select:[{ResponseData:'delta',ClientAction:'submit'},{}]}" type="text" autocomplete="off" tabindex="0" ti="0" class="urEdf2TxtEnbl lsEdfLeftBrdRadius lsEdf3TxtHlpBtn urBorderBox lsControl--explicitwidth" readonly="" value="" style="vertical-align:top;width:26.4ex;">
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

The desired element is a dynamic element so to click() on the element you have to induce 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[id^='WD'][ct='CB'][lsevents*='ClientAction']"))).click();
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[starts-with(@id, 'WD') and @ct='CB'][contains(@lsevents, 'ClientAction')]"))).click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • When try explicit wait getting error - stale element reference: element is not attached to the page document – Sachin Sharma Aug 19 '19 at 10:09
  • I used Actions to click and it is working Actions action = new Actions(driver); action.moveToElement(sales_order_doc_type_dropdown); action.click().perform(); – Sachin Sharma Aug 19 '19 at 10:22