-2

So currently I am working on an autofill project in swift 3 to fill a website form with data.

I have figured out the filling of the text fields, but cannot figure out how to click the button. The code for the button is as follows:

<div id="isc_5D" eventproxy="isc_ButtonItem_12_button" style="position: absolute; left: 55px; top: 94px; width: 200px; height: 30px; z-index: 201242; overflow: hidden; cursor: pointer; -webkit-margin-collapse: collapse collapse; box-shadow: white 0px -1px 1px inset, white -1px 0px 1px inset, white 1px 0px 1px inset;" onscroll="return isc_ButtonItem_12_button.$lh()" onfocus="isc.EH.focusInCanvas(isc_ButtonItem_12_button,true);" onblur="if(window.isc)isc.EH.blurFocusCanvas(isc_ButtonItem_12_button,true);" tabindex="2896" role="button"><table cellspacing="0" cellpadding="0" width="200px" height="30px" style="table-layout:fixed"><tbody><tr><td class="buttonRounded" style="padding-top:0px;padding-bottom:0px;text-align:center;vertical-align:middle"><div style="display:inline-block;max-width:100%;white-space:nowrap;vertical-align:middle"><div id="isc_5C" style="overflow:hidden;text-overflow:ellipsis"><b style="font-size:18px;">Login</b></div></div></td></tr></tbody></table></div>

If you need to look at the website yourself, its URL is https://jpams.lpssonline.com/progress/

Edit:

It may be best to go to the site and inspect element this button:

Picture [Imgur]

So for I have tried:

document.getElementById("isc_D").focus();
document.getElementById("isc_D").click();

which worked to fill the textfields (first you focus, then you change the value for the textfield) but I can not seem to click this button.

I even tried submitting the form it is placed on, but that just refreshes the page. It would be preferable to not have to use the submitting the form method because after logging in there are more buttons that are coded like the login button and I need to know how to click all of them.

1 Answers1

0

That's some horrific markup just to draw a button.

Anyway, rather than causing the "button" to be clicked, what you actually want to do is cause the <form> that surrounds it to be submitted. That's what will trigger the postback.

document.getElementById("isc_A").submit();

should do the trick (in JavaScript).

ADyson
  • 57,178
  • 14
  • 51
  • 63
  • Thanks, yea I don't control that site. The school board does. haha – user3051640 Apr 06 '17 at 14:38
  • That command seems to only refresh the page – user3051640 Apr 06 '17 at 14:41
  • Yes, well, that's what a postback is - it's a page refresh, with some processing potentially taking place in the background. It should have submitted the login details to the server, if they were correctly filled in., – ADyson Apr 06 '17 at 14:52
  • Still just refreshing everytime, I even tried with correct username/password. – user3051640 Apr 06 '17 at 15:16
  • What is this event proxy I keep seeing on the buttons? eventproxy="isc_ButtonItem_12_button" – user3051640 Apr 06 '17 at 15:22
  • I deleted the event proxy and the button no longer works. SO how do I invoke the event proxy in javascript? – user3051640 Apr 06 '17 at 15:24
  • There has to be something I can do to call this button? – user3051640 Apr 06 '17 at 16:49
  • TBH if what I suggested doesn't work, then I'm not sure. Bear in mind f you look at the page elements, there's no actual "button" element in the form (or an "input type='submit'" either), it's just a load of divs and table elements which together look a bit like a button. None of them have a "click" event defined on them, so there's nothing to click. This page has been created with some horrible framework and they've successfully managed to obfuscate how it works. You might have to do some patient debugging of the page in your browser's dev tools - set some breakpoints and see how it works. – ADyson Apr 07 '17 at 09:03