Utilize the sendKeys method to input text and save the entered value in

Currently, I am using WebdriverJS to interact with a form. In my test, I want to open the form, fill in a field using sendKeys, and then store this value in a variable. Here is the code snippet:

driver.findElement(By.xpath("//a[contains(text(),'Añadir Propuesta Test')]")).click();
driver.wait(function () {
    return driver.isElementPresent(By.css(".form-control.col-md-8")); 
}, 15000);
var propuesta = driver.findElement(By.name('rut'));
propuesta.sendKeys('1111122222');
propuesta.getText().then(function(text){
    console.log(text);
});

However, the actual result is returning an empty value.

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

I am wondering how I can use sendKeys and also store the value that was sent?

Answer №1

Your input has been saved in the value attribute:

propuesta.getAttribute('value').then(function(message){
    console.log(message);
});

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

Issue with the camera functionality in phonegap 3.3.0 API on IOS platform

I am currently in the process of developing an application for iPad that will allow users to capture and store photos. I have encountered some difficulties while using the PhoneGap camera API library, as my code is not generating any errors which makes i ...

AngularJS - Best practices for defining Angular modules

Imagine you have an angular js app called myApp with a controller and directive. How should you go about declaring both components? angular.module("myApp",[]) .controller("myController"...... angular.module("myApp") .directive("myDirective"....... OR a ...

Automating the process of posting a file to a form with javascript

I have a piece of client-side JavaScript that creates a jpeg file through HTML5 canvas manipulation when the user clicks an "OK" button. My goal is to automatically insert this jpeg output into the "Upload Front Side" field in a form, simulating a user up ...

Why does routing function correctly in a browser with AngularUI Router and Ionic, but not in Ionic View?

My Ionic App runs smoothly in the browser when using ionic serve. However, I encounter issues with routing when running the app in Ionic View (view.ionic.io) after uploading it with ionic upload. The index.html loads but nothing within <div ui-view=""& ...

Tips for implementing two Secondary Actions in React Material UI, with one positioned on the left corner and the other on the right, while ensuring that the behavior of the

Is there a way to display two secondary actions on either end of a list item without triggering additional onclick events? The placement can be adjusted by overriding the CSS properties right and left. https://i.stack.imgur.com/rhr7N.gif The issue arises ...

Make sure to always select the alternative option in ajax

I am trying to create a condition where if the value of id=type_investor is either 1 or 6, an email should be sent using a different controller. Here is my complete code: function (isConfirm) { if (!isConfirm) return; $.ajax({ ...

What is the method to call a private function using its name?

How can I call a function by its name? I understand how to call a function by name, but I am struggling to find the necessary scope. Currently, I am using this["get" + widgetName], which works for _get_publishedBuildsWidget1 but I would like to make the fu ...

Automatically update local library dependencies with npm

Utilizing the local package dependency functionality of npm, I have implemented it in the following manner: npm install --save "file:/path/to/module" After updating my library module by running npm run build to generate dist files, I then execut ...

JavaScript is not designed to run a second time

Currently, I have a script set up using $(document).ready(). It works perfectly upon initial loading. However, I also need this script to execute whenever the user changes an HTML select control. Ideally, upon page load, I want the filter and sort functio ...

Using jQuery or JavaScript in an ASP.NET environment, you can make the parent list item of a dropdown link active

Welcome to my navigation menu <ul class="sidebar-menu" id="navigation-menu"> <li class="active"><a class="nav-link" href="/"><i class="fas fa-home"></i><span>Home Page</span></a></li> <li cl ...

Is there a way for me to dynamically decide whether to use the append or prepend function?

Utilizing jQuery to retrieve data from the controller and populate a calendar represented by a table with days in columns. Implementing functionality for navigating between previous week / next week, as well as previous day / next day. The four scenarios s ...

What is the process of extracting a URL and inputting it into a form to enhance

Can anyone help with extracting a specific value (TEXT) from a URL and automatically paste it into an input form field? For example, if the URL is domain.com/page?code=123abc, I need to grab the code (in this case, 123abc) and have it automatically popula ...

Is it possible to transmit messages from a Chrome extension to a Java server?

My question is, if I want to create a Chrome extension that sends messages to a Java server, should I use the XmlHttpRequest API in the extension and have the Java server as an HTTP server? ...

Closing webdriver instance in Selenium within a loop

Greetings fellow Selenium enthusiasts! I am fairly new to using Selenium and I am encountering a puzzling issue that I can't seem to crack. Within my web scraping script, I have a for loop that is functioning properly. However, during the execution, ...

Switching from a right arrow to a down arrow using jQuery for a collapsible accordion feature

I have developed a unique type of toggle feature similar to an accordion design. When I click on the right-arrow next to an item, such as Area A, it expands to reveal the list of items within Area A. The arrow also changes orientation to point downwards (L ...

Tips for utilizing window.scrollTo in order to scroll inside an element:

I'm experiencing an issue where I have a vertical scrollbar for the entire page, and within that, there's an element (let's call it 'content') with a max-height and overflow-y scroll. The 'content' element contains child ...

Display HTML code within a data attribute

I have a function that modifies an element from OpenLayers. In the official documentation, it mentions that the property label accepts either HTML or a string. methods: { onUpdatePosition (coordinate) { this.deviceCoordinate = coordinat ...

Having difficulty executing groovy Webdriver scripts within the WebdriverSampler framework

I am attempting to launch my client using the Groovy script and the WebDriver Sampler, but I am experiencing issues. The only code that seems to work is JavaScript when using the following snippet: var pkg = JavaImporter(org.openqa.selenium); //WebDrive ...

The error in React's useEffect occurs when trying to access the property 'map' of an undefined value

import { handleResponse, handleError } from "./apiUtils"; const baseUrl = process.env.REACT_APP_API_URL; export function getAllNotes() { return fetch(baseUrl + "/notes", { method: "GET", headers: { 'Accept': 'application/j ...

An AJAX request will only occur if there is an alert triggered on a particular computer

Here's an interesting issue I encountered with my company's CMS newsletter system. It seems that the AJAX call to send an email works flawlessly in all modern browsers and operating systems, except for one client. This particular client is using ...