html - Clicking Javascript confirmation button in VBA script -
the purpose of code run report on website specified criteria. want search of "distance" criteria, prompts message box asking if i'm sure. want code able click "ok" button. however, code stops running once "submit" button hit , hung until "ok" button hit.
note: cannot change html or javascript
here's vba code
sub data_grab() 'open internet explorer , webpage dim ie object set ie = createobject("internetexplorer.application") ie.visible = true ie.navigate "insert website here" 'wait page finish loading while ie.busy loop 'get reference search form finding id in web page's object model dim daysas object dim city object set days= ie.document.getelementbyid("age"): days.value = "10" set city= ie.document.getelementbyid("location"): city.value = "la" 'click search button ie.document set elems = .getelementsbytagname("input") each e in elems if (e.getattribute("value") = "submit") e.click exit end if next e end end sub
the relevant html/javascript code website source
if (!distanceselect) { proceed = confirm("are sure wish search " + question + "? performance issues may occur."); } else {proceed = true;}
and
<input class="contentarea" type="button" value="submit" id="submit" onclick="javascript:loadreport();" />
i've tried numerous different solution, such sendkeys , creating shellscript, haven't been able of them work.
thank you.
one way override confirm
execscript
:
dim ie object, win object set ie = createobject("internetexplorer.application") ie.visible = true ie.navigate "https://stackoverflow.com" while ie.busy: doevents: loop set win = ie.document.parentwindow win.execscript "window.confirm = function(){return true;};"
Comments
Post a Comment