0

I can not locate element for this box to click on to get the date picker to popup

Any help would be appreciated

enter image description here

when I inspect element this is what I see...Xpath does not work either

<input ng-disabled="viewOnly" class="formInput effectiveDates ng-pristine ng-isolate-scope hasDatepicker ng-empty ng-invalid ng-invalid-required ng-not-modified ng-touched" autocomplete="off" name="effectiveStartDate" ng-required="true" placeholder="Select/Enter date(mm/dd/yyyy)" type="search" ng-model="authObj.authStartDate" value="" ng-keydown="preventUserEnterDateInfo($event)" datepicker="" minimumdate="02/27/2020" ng-change="effectiveDateChange(authObj.authStartDate)" ng-class="(authListForm.$submitted &amp;&amp; authListForm.effectiveStartDate.$invalid)?'reqd':''" id="dp1582663746532" required="required">
Guy
  • 46,488
  • 10
  • 44
  • 88
Adam Khan
  • 1
  • 1

3 Answers3

0

The desired element is an Angular element so to locate/click() on the element you need 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.formInput.effectiveDates.ng-pristine.ng-isolate-scope.hasDatepicker.ng-empty.ng-invalid.ng-invalid-required.ng-not-modified.ng-touched[name='effectiveStartDate'][placeholder*='Enter date']"))).click();
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@class='formInput effectiveDates ng-pristine ng-isolate-scope hasDatepicker ng-empty ng-invalid ng-invalid-required ng-not-modified ng-touched' and @name='effectiveStartDate'][contains(@placeholder, 'Enter date')]"))).click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

You can try click using JavascriptExecutor.

((JavascriptExecutor) driver).executeScript("arguments[0].click();", element);

or you can try click using coordinates:

Actions builder = new Actions(driver);   
builder.moveToElement(element, 10, 25).click().build().perform();
Ronak Jain
  • 2,402
  • 2
  • 24
  • 38
0

I noticed that the 'type'-tag is set to Search. If you want a browser to recognize it as a Date-Input, change it to type="date". The browser itself will invoke its default datepicker.

Charles de M.
  • 633
  • 7
  • 20