Ho un campo di testo ExtJs su una pagina. Lo sto riempiendo di un certo valore in casper.js, che funziona bene.
Quindi desidero mettere a fuoco questo campo e premere il Immettere la chiave, poiché non è presente alcun <form>
da inviare.casper.js: premere il tasto "invio" nel campo di inserimento di ExtJs
Quello che ho provato è stato:
casper.then(function() {
// the text field is filled with the string
this.sendKeys('#searchfield', 'some text');
this.evaluate(function() {
// this does not put the field in focus
document.querySelector('#searchfield').focus();
// so 'pressing' enter has no effect at all
var evt = document.createEvent('KeyboardEvent');
evt.initKeyboardEvent('keypress', true, true, window, 0, 0, 0, 0, 0, 13);
document.dispatchEvent(evt);
});
});
Avete qualche idea di come per ottenere questo risultato?
Grazie per la risposta e scusa per il mio ritardo. Ho capito che il problema non è a livello casper, ma non è nemmeno nella normale finestra del browser (Chrome). –