Securing text field content in Ext JS from exposure to HTML and Selenium

Recently, I've been working on automating test cases using Selenium2 Java for an application that heavily utilizes ExtJS. Despite successfully handling the changing element ids, there is one specific page where I'm facing a puzzling issue. There's a text field for setting a username which remains inactive until the edit button is clicked. However, even after entering text and saving it, the entered text doesn't seem to reflect in the HTML code. The label for the field appears but not the textfield content itself. It seems like some JavaScript is responsible for fetching and displaying the text, which has left me perplexed as I'm not well-versed with ExtJS. I came across a helpful post on Stack Overflow regarding testing ExtJS with Selenium, though my main quest is to understand the script triggered and utilize executeScript to retrieve the text from the textfield. While I can interact with the field using Selenium without any issues, I'm unable to extract the text programmatically.

Any insights on deciphering the underlying script and efficiently extracting the text would be greatly appreciated!

Best regards, Sabrina

Answer №1

I am still figuring out how to identify the script being called, but after getting some guidance from a helpful colleague, I devised a workaround:

String userid=driver.findElementByName("interfaceUsername").getAttribute("id");
String username=(String)js.executeScript("return Ext.getCmp('"+userid+"').getValue()");

By obtaining the element's name, I extract its id (whatever it may be at that moment) and then utilize executeScript to determine the value of the text field. It may lack elegance, but ExtJS isn't known for promoting elegance.

Answer №2

To ensure the field username has a value attribute, navigate to firebug, locate the Username field, and choose the DOM option on the right side. Verify that there is a value attribute containing the username information. For example, if your WebElement is named username, you can extract the value using the code snippet below.

String user = username.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

Discover the best practices for utilizing CSS selectors reliably in puppeteer

For a project, I am currently working on customizing a puppeteer script that is able to play a song from Soundcloud and record it. The main goal is to utilize a CSS selector to display the duration of the song as well. I am encountering difficulties with g ...

Encountered a TypeScript error: Attempted to access property 'REPOSITORY' of an undefined variable

As I delve into TypeScript, a realm unfamiliar yet not entirely foreign due to my background in OO Design, confusion descends upon me like a veil. Within the confines of file application.ts, a code structure unfolds: class APPLICATION { constructor( ...

Ways to enable users to input grammatical equations while verifying certain rules in a text box

I am looking for validation of equations in HTML, not evaluation. I want to allow users to input equations like the following in a textbox, with validation: 400 - IF(age > 32, 6, 4) + 10 The 'age' is a fixed string, and there will be other ...

How can I create a custom message in HTML using Angular directives within a marker popup using the angular-leaflet-directive?

I'm looking to add my own custom HTML markup with $scope event handlers to the message property of a Leaflet marker. Here's an example: App.controller('testController', ['$scope', "leafletEvents", '$compile', ' ...

Having trouble adding elements (after the initial iteration) using the push() method in JavaScript

I'm facing an issue where I have a string and an array, but I'm unable to push elements after the first iteration. Below is the code I'm using: response1 = "hello"; var arr = [""]; arr.push(response1); console.log("First position " + arr[0 ...

Utilize webdriver to extract the Review Date

from selenium import webdriver driver = webdriver.Firefox() base_url = 'https://www.tripadvisor.in/Hotel_Review-g60763-d208452-Reviews-' location_url = 'Conrad_New_York-New_York_City_New_York.html' driver.get(base_url + location_url) de ...

Error: The JQUERY autocomplete is throwing an uncaught type error because it cannot read the property 'length' of an undefined value

These scripts are being utilized at this source I have implemented jQuery Autocomplete to search for users in my database. Below is the controller code returning Json: public function searchusers1() { if ($_GET) { $query = $this -> input ...

What is the best way to restrict the number of threads in a TestNG dataprovider method functioning as a factory?

My current testing setup involves using Selenium to test a single-page application. I load the page in a @beforeClass method and then run all the tests within the class. Finally, I tear down the driver in the @afterClass method. To facilitate browser setu ...

Can NodeJS Handle Image Processing and Analysis?

I am currently running NodeJS on the server-side, and I am attempting to automate the process of determining the 'base color' of an image. My goal is to accomplish this by following these steps: Retrieve an image (located on a remote server, h ...

Is there a way to effectively alter an object that has been assigned in a separate file?

Seeking Assistance: I am facing an issue in my current project where I need to store a javascript object in an external file and then export it using module.exports. The challenge now is that I want another file to be able to modify a specific value withi ...

Problem with responsive design on iPhone

I'm currently working on developing a responsive chatbot using CSS Bootstrap. However, I've encountered an issue where the header and footer are not fixed when I open the app on an iPhone. The keyboard header is also moving up the screen, which s ...

Sorting the order of integer values within an ArrayList of Strings

Trying to confirm if the Ascending sorting order tab is functioning correctly. However, it seems to be failing when comparing results because of single and double digit numbers. Is there a way to convert an ArrayList to int? Will that solve the issue? ...

One Versatile Ajax Function for Accessing Various PHP Pages

On my index.html, there are buttons displayed below: <button value="about_us.php" onClick="fNt(value)">About Us</button> <button value="faq.php" onClick="fNt(value)">FAQ</button> <button value="contact_us.php" onClick="fNt(val ...

Python code to extract only numbers from a dataset by eliminating all letters

Looking for a solution to my Selenium code issue. x = browser.find_element_by_xpath('//*[@id="paginacaoSuperior"]/tbody/tr[1]/td[1]/h2/span').text This code is currently returning the following value: result 1 to 299 I need to extract just th ...

Tips for tracking a webpage and receiving notifications when a new HTML element appears with Selenium?

My website often includes new elements dynamically, such as: <span class="chat_message">| New Login</span> Is there a way to detect when the above code is added to my page? Here are some of the methods I have tried: WebDriver driver = new C ...

Extracting information from ul li div elements and saving it in JSON format

I have been pondering this issue for the past few hours and haven't been able to find a solution. Essentially, I have a list structured like this <ul class="list"> <li class="user"> <div class="name">Name</div> ...

What sets apart Selenium RC from Selenium Webdriver?

When using Selenium RC: The selenium commands are sent to a Proxy server, which then converts the commands into Javascript and injects them into the browser. However, with Selenium Webdriver: The selenium commands are interpreted by the selenium API, wh ...

Is it possible to operate Selenium grid without the use of browsers?

Is it possible to export Selenium to JUnit for webdriver 4 and run tests as an application without opening a browser? I'm interested in conducting load testing with Selenium Grid, but I'm unsure if running parallel instances of my Selenium test ...

Determine the quantity of items currently in an active state

I created a function that toggles the active state of list items when clicked: React toggleActive: function(item){ item.active = !item.active; }, JSX <li key={property.id} onClick={() => this.toggleActive(property)}> Is there a way to count ...

Enhance your loader functionality by dynamically updating ng-repeat using ng-if

To better illustrate my issue, here is a link to the fiddle I created: https://jsfiddle.net/860Ltbva/5/ The goal is to show a loading message while the ng-repeat loop is still loading and hide it once all elements have been loaded. I referenced this help ...