Obtain the text content in cases where the DOM is missing both the title and value fields

I am trying to extract the value from a text-box using selenium, but the text-box is marked as readonly and aria-live is set to off.

Here is the DOM structure:

<input autocomplete="off" class="abc" type="text" role="textbox" id="sumAccount" aria-describedby="sumAccount_describedby" tabindex="0" readonly="true" data-preview="true" aria-live="off">

On the webpage, the Summary of Account field displays the value "4567" in a read-only field.

I have tried the following code to retrieve the value, but I always receive a null value:

string accNumber = driver.findElement(By.id("sumAccount")).getAttribute("title");
string accNumber = driver.findElement(By.id("sumAccount")).text();

Could someone please assist me in retrieving the value?

Answer №1

If you want to retrieve the value from a read-only <input> element with aria-live="off" using Selenium, you can try this code snippet:

String accountNumber = driver.findElement(By.id("sumAccount")).getAttribute("value");

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

How can you effectively manage Click events within a three.js environment?

I'm working with a world map layer as a plane geometry and I need to handle click events on different parts, such as continents or countries. I want to show popup events on specific parts like information, videos, or image data with links. How can I a ...

Collaborate by sharing local storage with other systems

One of my systems (x.x.x.x: 8000) creates a localstorage after logging in. Now, when a user interacts with another system (x.x.x.x: 8001) by clicking a specific button, the information stored in the initial system's localstorage (x.x.x.x: 8000) is nee ...

Troublesome issue with the Focus() function in JavaScript

I'm having trouble setting the focus on a textbox with the id "txtCity." document.getElementById("txtCity").focus(); Any suggestions on how to make it work? ...

Converting a variety of form fields containing dynamic values into floating point numbers

Trying to parse the input fields with a specific class has presented a challenge. Only the value of the first field is being parsed and copied to the other fields. https://i.stack.imgur.com/QE9mP.png <?php foreach($income as $inc): ?> <input ty ...

Having trouble finding module: Unable to locate 'fs' - yet another hurdle with NextJS

Trying to access a JSON file located one directory above the NextJS application directory can be tricky. In a standard JavaScript setup, you might use the following code: var fs = require('fs'); var data = JSON.parse(fs.readFileSync(directory_pat ...

Newbie in JavaScript - reinitiating my for loop journey

After running an animation in 4 steps, I want it to restart once all the steps are completed. var aSteps = [ { "x": "800", "y": "0" }, { "x": "800", "y": "500" }, { "x": "0", "y": "500" ...

What could be causing the Toast message to not show up in react-native-root-toast?

Incorporated react-native-root-toast into my expo project running on expo 51. Please see the code snippet below for reference: const toastColors = { 'error': { color: '#DA5C53', iconName: <WarningIcon size="5 ...

How to make text dynamically shrink with TailwindCSS class 'flex-shrink-0'

I've designed an 'Album' (React) component to showcase album artwork, name, and release date in a card-like format. This component consists of two divs - one for the photo and the other for text. Each artist's discography displays multi ...

What is the best way to query based on a nested object property in Mongoose?

const collection = [ { inner_obj: { prop: "A" } } ] Get the outer records by searching for the ones that match the value of the `prop` property within the `inner_obj` column. How can we locate the o ...

Transforming an image object into a File object using Javascript

My goal is to utilize HTML5 on the client side in order to convert an "image object" into a "File object" for uploading to azure blob storage. I am working with AngularJs and my approach involves: Converting the image to a file Uploading the file to blob ...

javascript href clears Internet Explorer webpage

I noticed a strange issue with my HTML page. In Internet Explorer, when I click on the link, it displays the return value on a blank page. However, in Chrome, it simply executes the function without affecting the page appearance. Is there a way to make I ...

Tips for incorporating flow and TypeScript typings into an NPM module

Are there any resources available for adding both flow and typescript typings to an NPM module at the same time? I've been struggling to find a comprehensive guide on this topic, and it seems to be a common issue faced by open source library maintain ...

Extracting only the outer tags with Selenium: Tips and tricks

I need to isolate only the outer tag. <tr><td class="tdstyle"><b>Sub Sub Category</b></td><td class="tdstyle" style="font-weight:bold">U/s.482 Cr.p.c under sec.138 and 142</td></tr> <tr><td colspan ...

Executing a JavaScript function within MainPage.xaml.cs codebehind file in a Windows application

I am currently working on a project developing a Windows 8.1 app using HTML5 and Javascript (Silverlight). I have encountered an issue with implementing the functionality for the hardware back button. Within the MainPage.xaml.cs Codebehind file, I need to ...

Press the button to update several span elements

Imagine I have multiple span elements like this: <span>A</span> <span>B</span> <span>C</span> <span>D</span> and a div element (which will be converted to a button later) named "change". <div id="chan ...

Combine video using ffmpeg (or similar tools) while incorporating additional elements (such as overlays)

I am currently in the process of scraping clips from Twitch and combining them into a single video file. I have successfully managed to scrape Twitch clip links, but I am only able to get 16-20 videos due to the need to scroll with Selenium. While this is ...

What is preventing me from retrieving WP custom fields value or post ID using Ajax?

After successfully generating a link based on the visitor's location, I encountered an issue with caching when using full-page caching. To address this problem, I decided to implement AJAX to dynamically load the link. While my code worked well in ret ...

Selecting an Option Value from a Local Option Set

Situation After attempting to use the Dynamics 365 REST API's InsertOptionValue Action on a local option set, I encountered an issue. Despite the documentation stating that the action can be applied to both global and local option sets, I am unable ...

Encountered an issue with mapping data from a controller to a view in Angular.js

Currently, my application consists of only three small parts: a service that makes an http call to a .json file, a controller that receives data from the service and sends it to a view. Everything was working fine when I hard coded the data in my service. ...

Capturing the shouldBe or shouldHave method in Selenide

I am in the process of creating a test, but I am encountering issues with loading all fields correctly. My initial thought was to use a simple try/catch method, however when I include the following code: $("select[formcontrolname=\"identifier\"] ...