Automating web page input

Started by MW4, July 30, 2014, 12:25:58 PM

Previous topic - Next topic

MW4

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.

Deana

Deana F.
Technical Support
Wilson WindowWare Inc.

MW4


MW4

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

Deana

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.
Deana F.
Technical Support
Wilson WindowWare Inc.

Deana

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
Deana F.
Technical Support
Wilson WindowWare Inc.

MW4

IE and the page will already be open and I have to click a disclaimer box:


Deana

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#
Deana F.
Technical Support
Wilson WindowWare Inc.