Jump to content

How can I validate this form using Javascript?

Recommended Posts

Hello AutoIt Community!


I have no where else to go so I have came here for some hope! Haha.

I am trying to validate this form to I can upload an image to a website. For some reason, every time I dynamically add a value to the URL input box, it does not allow me to upload.

I need some type of work around. Here is my code. I feel like I have tried everything.

// ;: INCLUDES :;

#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

// ;: IE DOCUMENT :;

Local $oIE = _IECreate("https://wordpress.com/post/ENTER YOUR BLOG HERE")
Local $oDoc = _IEDocGetObj($oIE)



$oDoc.querySelector("div.media-library__header-popover .popover__inner .popover__menu .popover__menu-item").click()

$oDoc.querySelector("form.media-library__upload-url .form-text-input").focus()

Local $oInput = $oDoc.querySelector("form.media-library__upload-url .form-text-input")
_IEFormElementSetValue($oInput, "http://lorempixel.com/400/200")

// I have also tried
// $oInput.value = "http://lorempixel.com/400/200"

$oEvt1 = $oIE.document.createEvent("Event1")
$oEvt1.initEvent("change", True, False)

$oEvt2 = $oIE.document.createEvent("Event2")
$oEvt2.initEvent("input", True, False)

$oEvt3 = $oIE.document.createEvent("Event3")
$oEvt3.initEvent("keydown", True, False)

$oEvt4 = $oIE.document.createEvent("Event4")
$oEvt4.initEvent("keypress", True, False)


$oDoc.querySelector("div.media-library__upload-url-button-group .button").focus()
$oDoc.querySelector("div.media-library__upload-url-button-group .button").click()


For some reason, the console always outputs this and this

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/
e.extension is undefined


What else could I try? I am lost at this point. Been trying for 3 days...


Link to post
Share on other sites

I imagine e.extension is coming from the js console. the XML error you see is defined in JQuery.  Maybe e.extension is.

If you go to the site... look at the source, anything related to e.extension or just extension in any of the source script files?

in chrome you can also check the network section and js console.

[font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font]

Link to post
Share on other sites

The site used the ReactJS library, which can be a PITA to automate. I previously wrote some code to deal with this in FF. Unfortunately, this doesn't appear to be working with this version of the library.

The good news is that I found some code here that appears to work when I manually ran it in the console.

var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
nativeInputValueSetter.call(input, 'react 16 value');

var ev2 = new Event('input', { bubbles: true});

This appears to work fine in my testing. Now you just need to implement the solution in Autoit. :sweating:

Link to post
Share on other sites
  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...