3

A lot of my job requires me to fill out forms online, with unique information each time, but the same types of information (such as name, date of birth), which I have been given by other people.

I've been trying to find a way of filling in the form automatically using the data given to me.

I learnt a bit of coding for my degree but have not used it since and am trying to learn more! (Was shown some C++, html, CSS and javascript, but the latter was mostly copied and pasted and I can't remember very well).

I have identified all of the html id tags for each part of the form and thought that if I pasted the following code at the end of the URL then it would fill in the Last Name box, (and if this would work I could extrapolate the information) but this asked the page if it wanted to reload.

?Javascript:document.getElementById("txtLastName").value="Davy";

This is because the first step of starting a form is to pick whether the form is for us wanting to send data elsewhere, or if we are requesting data from another institution. When deciding this, one then has to start typing to search for the institution, which once this has been confirmed, the form appears (which is almost identical regardless of which options are selected).

Looking at this part of the html I discovered the page uses KO - Knockout and have begun to wonder if I have bitten off more than I can chew...

<div class="input-widget col0 semiwide required lookup notsearchable" data-bind="css: selectedInstitutionId.mandatoryFieldClass, visible: !destIndividualVisible()">
                    <label id="txtInstitution-label" for="txtInstitution" data-bind="text: instLabel">Destination institution</label>
                    <input name="txtInstitution" tabindex="3" class="input-field text" id="txtInstitution" type="text" maxlength="300" placeholder="Browse or start typing" autocomplete="off" data-bind="typeahead: {source: getData, afterSelect: afterSel},  value: selectedInstitution, valueupdate: 'afterkeydown', placeholder: browseOrTypePH,  disable: disableCtrl">
                    <input class="lookup" id="btnBrowse" type="button" value="Browse" data-bind="value: browseLabel, visible: !relatedSectionsVisible(), click: browseClicked">
                    <span class="validationMessage" style="display: none;" data-bind="text: noInstFound, visible: noInstFound"></span>
                    <input id="hdnInstitutionId" type="hidden">
                </div>

For now I thought I would try and get a script to run on the page, once I have selected the institution location and the form has loaded up, but unsure how I can do this in the URL or by clicking on a bookmark with javascript in without it reloading the page.

I looked into AJAX as a solution to that problem but unsure of a way of using this when I obviously(?) can't change the websites source code to get it to run with my own script over the top.

Currently the information I want to populate the form is sent to me in e-mails in varying layouts/formats but my workplace will soon be moving to a system where for these types of recurrent requests a form is filled in by the requesting user. I'm not entirely sure how this data will be presented to us but from searching around expect it will be presented in a table rows in a html web page. I've seen that if I could perhaps parse this into excel then I could format that as a csv to create one line of javascript to run, but again not sure if this would be possible because of the aforementioned us of knockout on the web page and if this wouldn't end up saving that much time going through so many steps.

I'm OK with having the whole process not being automatic so we have a bit of control over ensuring information has been provided correctly. I know there is often a lot of variety between what names the institution names are provided by end users and figure it would be easier for this to be entered in manually by myself and then have the rest of the form filled in. (Although also thinking that when the new system comes in a drop down menu of the possible institutions could be offered which would sync up with those on the website allowing me to easily parse that information and bypass the knockout/page reloading obstacle).

I don't think I'd be able to install any software at my workplace that may assist in getting this to work and want to learn more of the code.

halfer
  • 19,824
  • 17
  • 99
  • 186
Ashley Davy
  • 39
  • 1
  • 3
  • 2
    "clicking on a bookmark with javascript in without it reloading the page" - https://stackoverflow.com/questions/9104/add-a-bookmark-that-is-only-javascript-not-a-url may cover that. The rest is (I suspect) largely off-topic for SO, which is a shame considering how much time you've spent writing it! – Adrian Wragg Dec 29 '17 at 14:02
  • @Ashley Davy Unfortunately by the time you mention Knockout you have gone off topic. Please review the Help Center about asking questions on Stack Overflow: https://stackoverflow.com/help/on-topic – landsteven Dec 29 '17 at 14:10
  • Its possible to just skip the middle man(the form) if you know more about the submission process. Do you have a link to the page? This could possibly be done with [windows power shell curl](http://thesociablegeek.com/azure/using-curl-in-powershell/) or POSIX's variant with some parsing of a csv or similar file type. – John Pavek Dec 29 '17 at 21:37

1 Answers1

0

If you have identified the html elements to fill you can automate your process with the help of Selenium tool. It is easy to grasp if you have some coding knowledge. Below is the link to it. http://executeautomation.com/blog/functional-tools/selenium-automation-with-c/

  • Thanks. I had found this elsewhere but was unsure about looking at it as doubt I'll be able to get permission to have it installed at work, but will look at it at home to see what I can learn from it and maybe utilise the code without the need for software to get it to work in the workplace! – Ashley Davy Dec 29 '17 at 16:34
  • You are welcome Ashley. Best wishes to you. – Daman Pal Singh Khanna Dec 30 '17 at 09:25