Access VBA - Clicking button or invoking javascript on website

Viewed 50

I am stumped. I have vba code that fills a website form fields and, for years, has successfully clicked a continue button at the bottom of the page. Recently, the website made changes that have derailed that last step - clicking the continue button.

The HTML code for the button now reads as:

<input type="submit" name="PaymentProcessor$ButtonContinue" value="Confirm" onclick="javascript:PaymentProcessor_ButtonContinue.disabled=true;__doPostBack(&#39;PaymentProcessor$ButtonContinue&#39;,&#39;&#39;);WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;PaymentProcessor$ButtonContinue&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="PaymentProcessor_ButtonContinue" class="btn btn-default" style="font-weight:normal;font-style:normal;text-decoration:none;" /> 

In the past, I have defined ieObj As HTMLInputElement and clicked the button like this:

Set ieObj = iePage.getElementById("PaymentProcessor_ButtonContinue")
ieObj.Click

Now, that no longer works. I don't get an error, nothing happens. I can see the ieobj get populated in the locals window, so I think I have the correct handle, I just can't manipulate the object.

I have also tried the following:

ieObj.FireEvent ("onkeypress")
''no error, no effect
ieObj.FireEvent ("doPostBack")
''error
ieObj.submit
''error- does not support method
ieObj.Value = "continue"
''no error, no effect
ieObj.Value = "confirm"
''no error, no effect

I also tried invoking the javascript portion of that html directly, but I am probably doing it wrong:

iePage.parentWindow.execScript "document.getElementById('PaymentProcessor_ButtonContinue').submit();", "javascript"
''gives automation error
iePage.parentWindow.execScript "__doPostBack(&#39;PaymentProcessor$ButtonContinue&#39;,&#39;&#39;);WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;PaymentProcessor$ButtonContinue&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false));", "javascript"
''gives automation error

I made an effort to utilize queryselector and queryselectorall, but both methods made Access crash.

Elsewhere on the page, the below javascript functions are defined. I don't know if is important, but it is below:

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['Form1'];
if (!theForm) {
    theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>

Any Ideas I should try?

1 Answers

See if the input button is part of a form, and call the form's "Submit" procedure. Without knowing more about the HTML being scraped, I cannot provide further help.

Related