Author Topic: Automating web page input  (Read 3815 times)

MW4

  • Full Member
  • ***
  • Posts: 171
Automating web page input
« 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.

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Deana F.
Technical Support
Wilson WindowWare Inc.

MW4

  • Full Member
  • ***
  • Posts: 171
Re: Automating web page input
« Reply #2 on: July 30, 2014, 12:50:47 pm »
Thanks....  :)

MW4

  • Full Member
  • ***
  • Posts: 171
Re: Automating web page input
« Reply #3 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

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Automating web page input
« Reply #4 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.
Deana F.
Technical Support
Wilson WindowWare Inc.

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Automating web page input
« Reply #5 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
#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

  • Full Member
  • ***
  • Posts: 171
Re: Automating web page input
« Reply #6 on: July 31, 2014, 11:20:25 am »
IE and the page will already be open and I have to click a disclaimer box:


Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Automating web page input
« Reply #7 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
#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.