Tips for utilizing Selenium Webdriver to input text into a webpage textbox using onblur, onfocus, and onkeydown attributes

I'm looking to streamline the process of inputting a value into a text box on a webpage, similar to automating my timesheet. The HTML code for the text box is shown below.

<input type="text" class="" onblur="return setValue(this);" title="Time";  onfocus="return getValue(this)" onkeydown="return Validate(event);" value="" id="0_0_1">

The value '9.00' needs to be entered into this textbox. I've attempted using the following code:

JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById('0_0_1').value = '9.00';");

I've also tried the following:

driver.findElement(By.xpath("//*[@id="0_0_1"]")).sendKeys("9.00");

and even

driver.findElement(By.id("0_0_1")).sendKeys("9.00");

Unfortunately, the time value is not being filled in the textbox. Could it be because of the onblur, onfocus, and onkeydown attributes in the code? Any suggestions would be greatly appreciated. Thank you in advance.

Answer №1

One possible solution is to utilize the JavascriptExecutor to manipulate the value attribute.

WebElement targetElement = driver.findElement(By.id("0_0_1"));
js.executeScript("arguments[0].setAttribute('value', '9.00')", targetElement);

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

Utilize Bootstrap tooltips to display live results fetched via an AJAX call

I have a bootstrap tooltip that I am trying to populate with data from an AJAX request. The text retrieved from the request should be displayed as the title property of the tooltip. Despite successfully executing the AJAX request, I am facing two issues: ...

Is there a way to successfully include an apostrophe in a URL?

I am currently utilizing Node.js: var s = 'Who\'s that girl?'; var url = 'http://graph.facebook.com/?text=' + encodeURIComponent(s); request(url, POST, ...) This method is not functioning as expected! Facebook seems to be c ...

What is the best way to set up CORS in IE11 using C# with JQuery.ajax?

Having some trouble with CORS functionality in IE11. I need to perform ajax requests using jquery (or whatever the browser supports natively), without any additional libraries. These requests are cross-domain and function perfectly in Chrome and Firefox. ...

Error: string literal left incomplete with spaces only

I am attempting to run parameters from a JavaScript function, but I am encountering an issue with quotes when there is a white space present. This error specifically pertains to Mozilla: SyntaxError: unterminated string literal Below is the relevant p ...

Searching for an element in C# Selenium based on the value of the onclick() attribute

I am facing an issue with a set of elements that lack consistent IDs but have long onclick attributes with unique identifiers. These elements may overlap, ruling out the use of a CSS selector. <a href="#" onclick="fireEntrySelected('scheduleFrm&a ...

"Ensure div remains at the bottom of the page even while

In order to implement a feature where the menu sticks to the top when scrolling down, you can use the following JS code. You can view a live example of this functionality on this Plunker by widening the preview window to see the columns side by side. wi ...

Ways to effectively pair a radio button with a dropdown menu

function radioCheck() { document.getElementById("last").checked = "checked"; } <label> <input type="radio" name="Ppub" value="" checked="checked">All Dates </label> <br> <label> <input type="radio" id="last" name="Ppu ...

Overlaying a div on top of an iframe

Struggling to make this work for a while now. It seems like a small issue related to CSS. The image isn't overlaying the IFrame at the top of the page as expected, it's going straight to the bottom. Here is the code snippet: .overlay{ width: ...

Choosing an item in an AngularJS select directive from an external origin

I'm currently working on developing a form using Angular JS for editing venue details such as address and city. The backend system is powered by Django and offers a REST API (Django Rest Framework) which I am interfacing with through Restangular serv ...

effortlessly eliminate the Google MyMap watermark from an iframe using ReactJS

I am new to ReactJS and I would like help on how to hide the watermark on a Google My Map. Can someone please assist me with this? <iframe src="https://www.google.com/maps/d/u/1/embed?mid=1OMSkPKZi-U-CnmBr71zByNxp8HYi-vOc&ehbc=2E312F" fram ...

Showing additional content in an alternative design

I'm currently facing an issue with the "load more" post button on my Wordpress site. I've designed a unique grid layout for the category page, with a load more button at the bottom. However, when I click the button to load more posts, they appear ...

Querying data with parameters in a client-side rendered application with Next.js

Currently, I am developing a chat application using Next.js and Axios. One of the functionalities I implemented is a dynamic route called chat/:pid to fetch data using the provided pid. However, I encountered an issue where the values are coming back as un ...

Error: WebDriverException - Chrome crashed and failed to start on an Amazon Web Services Windows container, rendering it unreachable

Having trouble running Chrome with Selenium on an AWS Windows 2019 instance: private final String chromeDriverPath = "src{0}main{0}resources{0}chromedriver{0}chromedriver.exe".replace("{0}", File.separator); private final String chromeP ...

Steps for integrating a Phonegap Java plugin into Ionic

I am currently developing an app with Ionic and I'm experiencing a similar issue to this one found on Stack Overflow: Cannot find file in the gallery after downloading it with PhoneGap in Android When I download a picture in my app, it does not updat ...

Currently working on integrating a countdown timer using the Document Object Model (DOM)

Is it possible to create a timer in the DOM without using any JavaScript? I currently have a JavaScript code for the timer, but I want to convert it to work directly with the DOM without needing to enable JS. Any assistance would be greatly appreciated! ...

Having trouble sending a post request to the /register endpoint

Recently, I've been working on setting up a user registration process using Node.js. However, I've encountered an issue where every time I send a POST request with email and password, I receive a 404 error in Postman stating "Cannot POST /signup" ...

Having trouble importing Bootstrap into Next.js? It seems like the issue may be related to the

I am currently facing an issue with importing bootstrap 5.3.2 (not react-bootstrap) into my NextJS 14.1.0 project that utilizes the new App Router. My goal is to strategically utilize individual Bootstrap components (not through data-attrs). I managed to ...

Parsing JSON data with a timestamp field in Jackson

I encountered the following string: { "debug":"false", "switchTime":"2017-04-12 17:04:42.896026" } My attempt was to extract an object using this method: new ObjectMapper().readValue(string, MyObject.class); This is what my MyObject class looks ...

The HTML was generated without any styling properties assigned

After running my script on a galaxy tab, I encountered a strange issue. I created an HTML element (div) and attempted to access the style attribute, only to receive an error message indicating that style is null. Below is the code snippet: var newDiv = d ...

Can webpack effectively operate in both the frontend and backend environments?

According to the information provided on their website, packaging is defined as: webpack serves as a module bundler with its main purpose being to bundle JavaScript files for usage in a browser. Additionally, it has the ability to transform, bundle, or ...