Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

582
Vistas
How to extract the input text from angular form using Python Selenium?

I have already tried .text and get_attribute('value') to get the value from an angular input.

Here's the element,

<input class="form-control m-input ng-pristine ng-valid ng-touched" name="contact" pattern="^((0091)|(\+91)|0?)[789]{1}\d{9}$" placeholder="Enter contact number" required="" type="text">

The screenshot of the element,

enter image description here

There's an email in this input field. I.g. something.mail.com which I want to get.

Here's the code I have tried,

contact = contact_field.get_property("value")
contact = contact_field.get_attribute("value")
contact = contact_field.text
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As per the HTML:

<input class="form-control m-input ng-pristine ng-valid ng-touched" name="contact" pattern="^((0091)|(\+91)|0?)[789]{1}\d{9}$" placeholder="Enter contact number" required="" type="text">

none of the attibutes caters to the value change within the HTML DOM on sending text to the <input> element.


Deep Dive

The change in the DOM Tree occurs incase the <input> element contains the following attributes and evenets:

  • change event: The change event is fired for <input>, <select>, and <textarea> elements when an alteration to the element's value is committed by the user. Unlike the <input> event, the change event is not necessarily fired for each alteration to an element's value. Examples:
    • example#a:

      <input type="text" class="form-control" (input)="onSearchChange($event.target.value)">
      
    • example#b:

      <input type="text" [ngModel]="mymodel" (ngModelChange)="valuechange($event)" />
      
    • example#c:

      <input type="text" [ngModel]="mymodel" (keypress)="mymodel=$event.target.value"/>
      
    • example#d:

      <textarea [(ngModel)]="smsMessage" (change)="changeSMSMessage()"></textarea>
      

Note: The HTML specification lists the <input> types that should fire the change event.


Example

As an example, for some elements, including <input type="text">, the change event doesn't fire until the control loses focus. On entering something into the field below, and then click somewhere else to trigger the event.

HTML:

<input placeholder="Enter some text" name="name"/>
<p id="log"></p>

JavaScript:

const input = document.querySelector('input');
const log = document.getElementById('log');

input.addEventListener('change', updateValue);

function updateValue(e) {
  log.textContent = e.target.value;
}

References

You can find a couple of relevant detailed discussions in:

  • Angular 2 change event on every keypress
  • Angular: change value on input event
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda