Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

453
Views
Selecting date value from input type = 'month'

Given:

<input class="inputField_input__2B0dA" maxlength="7" id="establishedYear" data-testid="date-input" type="month" value="">

Which on the page is an input field that looks like : ----- ---- [Calendar symbol]

The frist ----- resemble the month, and the next ---- the year => April 2020

But the only way to select the actual date is by clicking on the calendar and clicking on a month

I tried to write the value of the element with the required string using js:

//        JavascriptExecutor jse = (JavascriptExecutor) getDriver();
//        jse.executeScript("document.getElementById('establishedYear').setAttribute('value', '2022-04')");

Which works until the next action, when i click on another element, the value set with JS dissapears.

PS. If i try to manually type the date, it would work for the month, but then for the date if fails, it only changes the last char like for 2022 it would type 0002

Also, If i try to bascially click on the calendar icon, then click on the month with selenium, I cant do that because, when I try to create a selector for the date elements from the caledar, I cannot find them on the DOM.

So i click on the calendar icon, no changes to the dom appear(no new elements added to the dom)

Any suggestions on how to tackle this problem?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Solved this by:

    ocupSelfEmpPage.establishedYearInput.click();
    ocupSelfEmpPage.establishedYearInput.sendKeys(Keys.SPACE);
    ocupSelfEmpPage.establishedYearInput.sendKeys(Keys.UP);
    ocupSelfEmpPage.establishedYearInput.sendKeys(Keys.ENTER);

So clicking on the input, then space to open the calendar and up to select january, then enter to save it

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!