I have to test this date picker using Java and Selenium. See picture. The non yellow-highlighted part is where you put the date text, and the yellow part, when you click on it, brings up a date picker.
My problem is the whole field is just one input, and the only line inside a div:
<div class="term_dateWidth__hL6-b" style="visibility: visible;">
<input type="date" id="start" min="1900-01-01" max="9999-12-30" value="">
</div>
I can find the element but when I click it it only highlights the text box and does not bring up the picker. If I manually click on that highlighted part with the mouse it will bring it up. I just can't figure out how to do it with Selenium. I even tried the parent div but that did not work.
I though maybe with Actions I could go to a point but that didn't seem to work either, though maybe I don't understand using dimensions correctly. Element termDateArrow has already been set to the input below.
public void clickTermDateArrow() {
Dimension size = termDateArrow.getSize();
int height = size.getHeight();
int width = size.getWidth();
Point point = termDateArrow.getLocation();
int x = point.getX();
int y = point.getY();
Actions action = new Actions(driver);
action.moveToElement(termDateArrow, width - 1, y + 10).build().perform();
}
but that doesn't work either. I am trying to click an offset from the top left point (which getLocation() works. And yes I know I can send text to the box but that does not test the picker.
Any suggestions? See image
I ended up doing this
Dimension size = termDateArrow.getSize();
int width = size.getWidth();
Actions action = new Actions(driver);
action.moveToElement(termDateArrow, (width / 2) - 5, 0).build().perform();
action.click().build().perform();
TestUtils.sleep(5000);
for some reason I had o click twice. Unfortunately, it appears to be a Windows calendar picker so Selenium can't find it. I just hit ENTER and verify the date is the current date