Struggling with inserting JavaScript into the <input type="date"> calendar

Objective: I am trying to automate a calendar on Chrome using Selenium (Python + behave).

The problem: Despite attempting to pass a value via JavaScript, the date is only set when physically clicked through the calendar. Keyboard input and JS method do not seem to work.

Important Note: As per the documentation, users should be able to input dates via keys by default, but this does not function as expected. Inputs do not respond to keyboard commands at all.


Issue Investigation

  • Here are the original input fields within a #shadow-root (open):

https://i.sstatic.net/i6dDs.png

  • Disregarding Python for now, I attempted changing values using simple JavaScript in Chrome Dev Tools console:
    x = document.querySelector("#class > something").shadowRoot.querySelector("div > div > input[type=date]:nth-child(5)") #Select input for From Date
    x = "2022-05-12"
    y = document.querySelector("#class > something").shadowRoot.querySelector("div > div > input[type=date]:nth-child(5)") #Select input for To Date
    y = "2022-06-12"
  • Despite updating values and clicking search, the system does not recognize the new inputs:

https://i.sstatic.net/sT0il.png

  • However, manually selecting dates through the calendar works as intended:

https://i.sstatic.net/r6jRQ.png

  • The manually selected dates are accepted as valid inputs:

https://i.sstatic.net/wQK29.png


The HTML structure for the calendar is as follows:

<input type="date" min="2022-01-01" max="2022-07-19">

Clearly, utilizing JavaScript alone does not suffice. While the same method may work on this calendar, it does not work on the current one. Additionally, there seems to be an issue with getting Selenium to click and open the calendar autonomously.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Real-time Property Availability Widget

I need assistance with creating a website for a homeowner who wants to rent out their property. The client requires a feature that allows them to log in and easily mark individual days as available or unavailable for rental by choosing specific colors for ...

Building Individual Elements in Angular 2

My task involves creating two distinct components in Angular 2, the Users component and the Clients component. These components are not nested and do not have any relationship. To call these components separately, I typically use main.ts as the main entry ...

Learn how to incorporate a click event with the <nuxt-img> component in Vue

I am encountering an issue in my vue-app where I need to make a <nuxt-img /> clickable. I attempted to achieve this by using the following code: <nuxt-img :src="image.src" @click="isClickable ? doSomeStuff : null" /> Howeve ...

Unable to convert the value "undefined" to an ObjectId (type string) in the "_id" path for the "Order" model

As someone who is new to Javascript and working on an e-commerce website, I am currently facing a challenge with displaying the order id on the return page. Each time I try to do so, I encounter an error message that reads Cast to ObjectId failed for val ...

Using Javascript to display or conceal a specific child element within a loop, based on which parent element has been clicked

I need assistance with creating a grid of projects where clicking on a specific 'project' in the loop will display the corresponding 'project_expanded' div, while hiding all other 'project_expanded' divs. My initial plan was ...

Transferring information using express

Currently, my Express server is up and running and it's set to send an HTML file from the public folder of my project. The issue arises when I try to initiate a request from a client script linked in this HTML file to send data back to the server. Des ...

Jest - Silence greets the test results

Struggling with Jest has been a common theme for me ever since I first attempted to use it. Regardless of the tests I run or the options I try to pass to Jest, I never seem to get the expected 'Pass' or 'Fail' results in the console. In ...

What is the best way to retrieve a value by using the data.get() method?

I am currently facing an issue with retrieving the value of a textarea that I have dynamically added to a fieldset in my form. When I attempt to submit the form, the code below is executed: function handleSubmit(e) { e.preventDefault(); console.log( ...

Guide on selecting an element that is not a button with Selenium in Python

I'm a beginner in the world of web scraping and currently attempting to extract data from this real estate website in order to gather information on recently rented properties. To achieve this, I must select "Leased Listing" from a dropdown menu. You ...

What is the best approach for automating DevExpress Combo Boxes using Selenium/Watir?

DevExpress has a unique approach when building combo boxes. Unlike other tools like Selenium and Watir, it does not recognize them as Select Lists by default. Thus, the challenge lies in finding an effective way to automate these components. ...

Obtain the complete path in Vue router by utilizing nested routes

After creating nested routes for Vue Router, I encountered a problem while using the routes to generate a navigation menu. Currently, I am using route.path in 'router-link :to=' which only gives me a part of the path. I want to include the absolu ...

The video element in HTML5 is not showing up on Safari browsers, but it is functioning properly on Chrome

I have set up a video slider on my webpage. You can view the site The code is functioning perfectly on Chrome and iOS Safari, but there seems to be an issue on desktop browsers. When inspecting the page in Safari, the video elements are present in the HTM ...

What is the method for obtaining multiple indices on an Array?

Attempting to find multiple index positions in an Array for a Boolean value. Experimenting with while and for loops to iterate through more than one index position without success so far. Below is the code snippet: let jo = [1,2,3,4,5] let ji = [1,2,3] ...

Next.js Pre-rendering Issue: Error encountered when trying to access properties of a null object

Using Next.js for a React application (full code available here.) Encountering an unusual error while running next build, showing errors related to prerendering on five pages: spenc@WhiteBoxu:~/workout-tracker$ next build info - Loaded env from /home/spe ...

Utilizing Selenium WebDriver to locate and compare similar xpaths

I am dealing with the following xpaths that need to be handled in the same way by WebDriver, and I'm trying to extract text content from them. //*[@id="dialogMessage"]/div[3] //*[@id="dialogMessage"]/div[3]/p //*[@id="dialogMessage"]/div[3]/p/span[2] ...

Using VueJS for reactive binding效果

I am attempting to assign a class using the following syntax: :class="{active: favs.medium_title.fontWeight === 'bold'}" However, the fontWeight attribute is not yet defined when the component loads. This is an excerpt from my object: favs: { ...

Tips for removing the "" character from a JSON string using JavaScript

At my node js server, I am receiving a json string that has the following format: {\"gID\":1,\"sID\":18,\"T\":\"Parking\"} I added the "\" in the string because it was created in C and the \ is used to es ...

Unable to retrieve the value from an object (Javascript)

window.addEventListener('keydown', (e) => { let arrowsObj = { "ArrowUp": 1, "ArrowDown": 2, "ArrowLeft": 3, "ArrowRight": 4 } let eventKey = e.key; console.log(arrowsObj.eventKey); }); Despite p ...

Develop an onclick function with an href attribute

I am interested in transforming links into AJAX versions whenever possible. To achieve this, I plan to implement a function called replaceLinks that will add an onClick handler to each link on the page and trigger ajaxPageWSM(href). This is what I currentl ...

Ways to extract data from form inputs with the help of jQuery

My HTML form allows users to enter data and upon submission, I need to use jQuery to capture the entered values. <form class="my-form needs-validation" method="POST"> <input type="text" id="firstName" name="First Name"> <input type="tex ...