Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

456
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda