WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: MW4 on July 30, 2014, 12:25:58 PM

Title: Automating web page input
Post by: MW4 on July 30, 2014, 12:25:58 PM
I have a web page that I'd like to push data from a database into.

One input box has this when inspecting the element:
<INPUT id=ctl00_ContentPlaceHolder1_IncentiveClaimStep11_txtVIN style="WIDTH: 200px; TEXT-TRANSFORM: uppercase" maxLength=17 name=ctl00$ContentPlaceHolder1$IncentiveClaimStep11$txtVIN>

So let's say I have an access database called Mydata.mdb, with a table called Main, and a field called VIN that needs to get pushed into that box...

What is my starting point?
The entire page has many references to javascript, and there is about 25 input boxes for me to populate.
Title: Re: Automating web page input
Post by: Deana on July 30, 2014, 12:48:16 PM
For querying the database I recommend ADO: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+Tutorials/OLE~TUTORIAL+ADO.txt

For inputting information into a webpage, check out:

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/OLE~with~MSIE/User~Samples+Search~Craigslist.txt

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/OLE~with~MSIE+!!~Webpage~Element~Explorer~!!.txt

If you need further assistance, please post the entire Form source from the webpage you are trying to access.
Title: Re: Automating web page input
Post by: MW4 on July 30, 2014, 12:50:47 PM
Thanks....  :)
Title: Re: Automating web page input
Post by: MW4 on July 30, 2014, 01:21:30 PM
Here is the webpage code...it's inaccessible unless you are on our IP range.
Had to split it because of the file size.

Getting the data out of the database I have down, Just getting it into the page is the mystery
Title: Re: Automating web page input
Post by: Deana on July 30, 2014, 01:37:54 PM
Are you familiar with your browsers F12 web developer tool? You will need to determine the Id of the control you are trying to input data to.
Title: Re: Automating web page input
Post by: Deana on July 30, 2014, 02:07:15 PM
Assuming you determine the ID of the input element on the page. The code might look something like this:


Code (winbatch) Select
#DefineFunction udfIEPageLoadWait( objIE )
    ; Wait for webpage to load
    While !(objIE.readyState == 'complete' || objIE.readyState == 4 )
       TimeDelay(0.1)
    EndWhile
    While !(objIE.document.readyState == 'complete' || objIE.document.readyState == 4 )
       TimeDelay(0.1)
    EndWhile
    Return 1
#EndFunction

inputid = 'ctl00_ContentPlaceHolder1_IncentiveClaimStep11_calDeliveryDate_dateInput'
oIE = ObjectCreate("InternetExplorer.Application")
oIE.visible = @TRUE

url = 'C:\TEMP\webpage1.html'
oIE.Navigate(url)
udfIEPageLoadWait(oIE)
oElement =  oIE.Document.GetElementById(inputid)
oElement.Value = 'WinBatch Rocks'
Exit
Title: Re: Automating web page input
Post by: MW4 on July 31, 2014, 11:20:25 AM
IE and the page will already be open and I have to click a disclaimer box:

Title: Re: Automating web page input
Post by: Deana on August 05, 2014, 08:03:26 AM
Try my previously posted code sample but pass that elements ID instead.

Also you are dealing with a checkbox rather than an text input. So you might try setting its value to @TRUE:

Code (winbatch) Select
#DefineFunction udfIEPageLoadWait( objIE )
    ; Wait for webpage to load
    While !(objIE.readyState == 'complete' || objIE.readyState == 4 )
       TimeDelay(0.1)
    EndWhile
    While !(objIE.document.readyState == 'complete' || objIE.document.readyState == 4 )
       TimeDelay(0.1)
    EndWhile
    Return 1
#EndFunction

inputid = 'ctl00_ContentPlaceHolder1_IncentiveClaimStep11_chkAcknowledge'
oIE = ObjectCreate("InternetExplorer.Application")
oIE.visible = @TRUE

url = 'C:\TEMP\webpage1.html'
oIE.Navigate(url)
udfIEPageLoadWait(oIE)
oElement =  oIE.Document.GetElementById(inputid)
oElement.Checked = @True
Exit


See Also: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsrch.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/OLE~with~MSIE+TechHome/WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/OLE~with~MSIE#