Problem with using ng model GetText() method in Selenium WebDriver with Java

Action: Retrieving the value from a text box using the GetText() method with Selenium webdriver.

HTML code:

<input class="form-control ng-pristine ng-valid dirty ng-touched" type="text" placeholder="Search Query" my-enter="SaveBind('Search');" ng-model="Query.SearchTerm" name="headerSearch">

The above code represents an input type with text control, thus requiring the extraction of the value from the text box.

My Xpath:

@FindBy(how = How.XPATH, using = "//input[@ng-model='Query.SearchTerm']")
public WebElement searchQuery;

When utilizing the getText method, an empty value is retrieved.

String query = searchQuery.getText();

However, sending the value through sendKeys works correctly as the entered value is pasted into the control.

searchQuery.sendKeys("Welcome");

My inquiry: If the entered values are not displayed in the HTML tag, how can the value be extracted from the text box? Is it possible to automate Angular Js?

Attached screenshot: https://i.sstatic.net/bJLZo.png

Answer №1

The values entered are not displayed in the HTML. To retrieve the entered value, you must utilize the getAttribute() method

String query = searchQuery.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

Develop a monitor for an entity that has not been created

Currently, I am tackling a feature that involves tracking an asynchronous request within a synchronous one. Let me elaborate. The code snippet I am working with looks something like this: const myObj = {}; function sendMessage(requestId, data) { kafkaP ...

Is it no longer necessary to bind functions in React Component Classes?

Recently, I observed that when defining normal class component functions in React, there is no longer a need to bind them inside the class constructor. This means that even without using ES6 public class field syntax, you can simply pass these functions to ...

The sorting process fails to make any changes, thus leaving the state unaffected

Is there a way to sort an array of objects in descending order by their id? No errors appear in the console. Even after calling the sort method, the state of allPosts remains unchanged. import { useState } from "react"; import Button f ...

What is the best method to reset the chosen option in a dynamic select dropdown using React?

I have a form set up with a Select dropdown that is populated dynamically from the server. The issue I'm facing is that after selecting an option from the dropdown and then saving or canceling the form, the selected value remains in the field when I ...

Implementing a node.js application deployment with pm2 to ensure zero downtime

While there are countless tutorials on developing chat applications using socket.io and node.js, the event-driven advantage of Node is undeniable for building chat apps. However, a recent thought crossed my mind - how can I ensure the sustainability of my ...

I'm baffled by the unexpected result I'm getting when using 'foreach' in node.js

Recently delving into node.js, I've encountered a puzzling issue. I'm perplexed as to why my output appears as: ciao data data instead of: data data ciao Below is the code causing this unexpected output: fs.readdir("sender", (err, fil ...

The TestNG framework has ignored the test case

My current testing setup involves the TestNG framework for writing test cases for my Android application, utilizing the Appium testing tool. The necessary files for this setup include: pom.xml file - required for dependencies A BaseTest.java class Two c ...

What is the best way to incorporate background colors into menu items?

<div class="container"> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-12 fl logo"> <a href="#"><img src="images/main-logo.png" alt="logo" /> </a> ...

How can you avoid scraping the <a> tag when utilizing selenium to extract data?

HTML: <tbody> <tr > <td> Tim Cook </td> <td class="wpsTableNrmRow" > Apple CEO <a href:applicatiodetailaddress> all CEOs </a> // Nor required this node ...

The webpage fails to load using the Chrome driver, but successfully loads when using the geckodriver

I am currently facing challenges while attempting to scrape a specific website. Initially, I tried using Beautifulsoup without success. When I switched to the Selenium Chrome driver, the website refused to open. Interestingly, it does open with Firefox b ...

Immediate self-invocation occurs within a JavaScript function

My goal is to dynamically create a DOM button object with JavaScript, and it seems to be happening perfectly fine. However, I'm facing an issue where if I try to assign another JavaScript function to one of the buttons, the other script triggers itsel ...

Tips for triggering window load event on a particular page

I need to trigger the windows.load event on a specific page. Currently, I have set it up like this: $(window).load(function(){ if(document.URL == "/car-driving.html") { overlay.show(); overlay.appendTo(document.body); $('.popup' ...

Encountering an issue: TypeError: The unbound method get() needs to be invoked with a WebDriver instance as the first argument (received a string instance instead)

Below is a sample script that I have experimented with: import unittest from selenium import webdriver from ddt import ddt,data,unpack #@ddt class search(unittest.TestCase): def setUp(self): self.driver=webdriver.Chrome #@data(("Bed &a ...

What is the most effective way to transfer color values from one div to another?

When recreating a game similar to Mastermind, I encountered a challenge of copying color values from one div to another upon clicking a button. Despite browsing the web, I haven't found a solution for this specific situation. Below is the code I have ...

Use either Jquery or CSS3 to hide a div if one of its inner divs is empty

I have multiple data sets to display in divs with the same class name. Each div contains two inner divs. <div class="div1"> <div class="div2">Abc</div> <div class="div3"><?php echo $row['SOME VALUE']; ?>< ...

Is there a way for me to retrieve SCSS color variables within the javascript of a Vue template?

I have a unique challenge in my application involving a component called Notification. To bring notifications to other components, I utilize the mixin method toast('message to display', 'color-variable'). My goal is to set the backgroun ...

How to visually represent options without labels using icons in Material UI Autocomplete

My options are structured as follows: const options = ['option1', 'option2']; I am looking to display the options with icons like this: https://i.stack.imgur.com/aubHS.png The current code for rendering options looks like this: ...

Validating dates using JQuery within a specific range of dates

Users can input a date within a specified range in an input field. To enable this feature, I created a new method using the jQuery validator object: $.validator.addMethod("dateRange", function(value, element, from, to){ try { var date = new D ...

Data on global map routes displayed in highcharts react

After reviewing the react highmaps documentation, it appears that they have saved the map data in a hardcoded manner. Take a look at Link 1 Check out Link 2 In various tutorials, I noticed that the data is retrieved from high maps itself by passing a ke ...

When running the command `npm start`, an error message is generated

Hey everyone, I've been trying to learn some basic AngularJS 2.0 skills through a tutorial. Unfortunately, when I tried running the command npm run start, it didn't work as expected. I'm currently using Git Bash on Windows 10 OS. If you hav ...