Having trouble inputting a value into a textbox after enabling it via Javascript

I'm having trouble setting a value in a textbox after forcibly enabling it through JavaScript executor in my Selenium automation script using Ruby bindings.

input_fieldcar1 = browser.find_element(:xpath, "/html/body/div[5]/div/div[3]/div[2]/div[2]/div/div/div/div/div[2]/div[2]/div/div/div/div[2]/div/div/div[5]/div/div[2]/div[2]/div/div/div/div[4]/div/div/div[3]/div/div/input")
browser.execute_script('arguments[0].removeAttribute("disabled");', input_fieldcar1)

I attempted to use

input_fieldcar1.send_keys"7"

browser.execute_script('arguments[0].setAttribute("innerHTML","1");', input_field1)

both of which did not work as expected!

The script also ends without any errors being thrown.

What could be the missing or wrong step here?

Answer №1

Considering it is a textbox, you could try using the value attribute.

browser.execute_script('arguments[0].value = "1";', input_field1)

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

What causes a "UnhandledPromiseRejectionWarning" while using Puppeteer?

What causes the following warnings to appear, and how can I resolve them? Warnings: (node:26771) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Protocol error (Runtime.callFunctionOn): Target closed. (node:26771) ...

Displaying the active navigation element in ApyCom JavaScript jQuery menu: tips and tricks

Currently, I am utilizing the jQuery navigation menu from ApyCom. Everything seems to be functioning properly except for one issue. Whenever I click on a different navigation element, I expect that element to remain highlighted in order to indicate to the ...

Loading Angular.js scripts into the webpage

My app is built using the MEAN stack. When a user visits the URL: http://localhost:3000/edit/0 Where 0 represents a record id. Initially, it seems like everything should work fine, but I am facing an issue where my scripts are not loading in the edit.js ...

Element Not Found Error

Can someone help me find the Xpath for the element below? - <ion-button class="ta-btn btn-red ios button button-block button-round button-outline ion-activatable ion-focusable hydrated"expand="block"fill="outline"mode=" ...

Sending a File Object and Data to an MVC 6 Controller in ASP.NET 5 using JavaScript

I have been working with an Ajax function that is supposed to handle file upload, but I am encountering some issues. Despite dragging and dropping the file, nothing seems to happen with the Ajax. Upon inspecting the properties on the page, I can see that t ...

Disappear solely upon clicking on the menu

Currently, I am working on implementing navigation for menu items. The functionality I want to achieve is that when a user hovers over a menu item, it extends, and when they move the mouse away, it retracts. I have been able to make the menu stay in the ex ...

Verifying the visibility of a div and triggering its closure upon clicking outside of it

Would anyone be able to provide guidance on how I can merge these two scripts into one? Thank you in advance! $(document).ready(function(){ if ($('.myContainer').is(':visible')) { alert('Hello'); } }); $(doc ...

Tips for Retrieving Tooltip Information in Kendo UI Graphs

Click here to see the image. I am trying to retrieve the text from a tooltip but when using the code below, it is returning null: elementswait(chartSegmentList); Actions ac = new Actions(driver); Thread.sleep(2000); ac.moveToElement(chartSegmentList.get( ...

Cannot locate JSON file in NodeJS

Currently, I am developing an express API and looking to establish a connection with a MySQL server using this API. The configuration settings are stored in a file named settings.json. To retrieve these settings, I am utilizing the following code: const c ...

Making a Cross-Origin Resource Sharing (CORS) request with jQuery utilizing the $

I am currently in the process of building a web application that relies heavily on data from multiple domains. Approximately 90% of the requests made by my application are cross-domain requests. However, I have encountered an issue where I am unable to re ...

Improving Performance: Addressing Charset Definition Issue in NextJS Lighthouse Best Practices

Encountering an error on my blog page that states: Properly define charset Error! A character encoding declaration is required. It can be achieved with a tag in the first 1024 bytes of the HTML or in the Content-Type HTTP response header. Find out more a ...

Enhance the click() function in Webdriver or Selenium2 to measure the response time of a webpage

My goal is to measure page response time by using the code provided below, however I have noticed that there is some redundancy in it. long start; start = System.currentTimeMillis(); driver.get(url); or click(); System.out.println (driver.getTit ...

Limit the implementation of Angular Material's MomentDateAdapter to strictly within the confines of individual

Within my app, I have several components that utilize the mat-datepicker. However, there is one component where I specifically want to use the MomentDateAdapter. The issue arises when I provide it in this one component as it ends up affecting all the other ...

Turn on / off Button Using a Different Button

I am currently working on an application that is designed to create teams using button selectors. There are two initial teams in play: the (available team) which consists of two buttons - one for selecting a player and populating the player name into the ( ...

The server gets blocked by numerous AJAX GET requests happening at the same time until the data gets returned

In my Rails application, I am using the gridList library to display charts. The chart data is fetched asynchronously from a controller method in JSON format via AJAX. Upon initial page load, each gridlist item displays a loading icon while simultaneously m ...

What is the best way to select a color at random from an array without any duplicates?

When iterating through a group of 15 users to create a table row for each user, I am interested in randomly choosing a color from my theme's array of 4 colors for each user. How can I efficiently ensure that no two identical colors are next to each ot ...

"Exploring the capabilities of Rxjs ReplaySubject and its usage with the

Is it possible to utilize the pairwise() method with a ReplaySubject instead of a BehaviorSubject when working with the first emitted value? Typically, with a BehaviorSubject, I can set the initial value in the constructor allowing pairwise() to function ...

Learning to implement $first in an Angular ng-repeat to dynamically add a new table row

I am currently facing an issue with displaying a Google map for addresses in my Angular application. The problem seems to be related to the asynchronous nature of HTML and JS, but I am struggling to find a solution. The issue is that even though the map vi ...

Only display the element if there is corresponding data available

I have implemented the angular ng-hide directive to conceal certain markup when there is no data present: <li class="header" ng-hide = " todayRecents.length === 0 ">today</li> At this point, ng-hide simply applies a display value of 'non ...

Tips for obtaining response headers

Currently, I am utilizing Angular version 15.0 and retrieving a list of items from the backend (ASP.NET Core 5) with an additional item attached to the header. The GET method in the client-side service is as follows: /** GET Paged commodities from the s ...