0

I am writing a chrome extension to set an ASP.NET website textbox but the site doesn't recognize the input from the javascript. For testing purposes I am using this example Set value active input in active page from chrome extension with the proper changes to fit my needs.

The issue is that when extension sets the textbox value form is not auto submitted as if I was typing physically the input.

Here are the changes on the content.js

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}
async function demo() {
  document.getElementById('addresses').value = 'π';
  await sleep(200);
  document.getElementById('addresses').value = 'πα';
   await sleep(200);
  document.getElementById('addresses').value = 'παρ';
   await sleep(200);
  document.getElementById('addresses').value = 'παρν';
   await sleep(200);
  document.getElementById('addresses').value = 'παρνα';
}

demo();
//document.getElementById("dnn_ctr654_View_ctxSearchZipCode_btnSearchZipCode").click()

I even tried to force the submission of the form but no luck!

Cœur
  • 37,241
  • 25
  • 195
  • 267
Argiris
  • 189
  • 2
  • 15
  • Try using [`focus()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) followed by [`blur()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur), maybe that will kick off the auto submit - which doesn't work on every character you type in anyway. – Hans Kesting Jul 04 '17 at 07:26
  • Not working. Just tried it. – Argiris Jul 04 '17 at 07:40
  • @Velucio, did you focus the element before execCommand? Also, maybe the page is "smart" and uses contentEditable so a different element should be focused. – wOxxOm Jul 04 '17 at 09:22
  • @wOxxOm yes I did the focus before and the blur after. also tried to focus write a character blur focus write character blur etc. As for the "smart" I am not sure but I will try to do check it. But its weird because when you write there something manually its working fine. even if you write a single character it works. – Argiris Jul 04 '17 at 09:30

0 Answers0