Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

460
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda