Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can My VFP8.0 ap fill in the fields of a web browser? 2

Status
Not open for further replies.

opticalman

Programmer
Nov 6, 2006
103
US
I'm looking but I can not find an answer.

I need to "place an order" via a web browser, Internet Explorer.

I would like my app to enter the info. Can this be done? If so, where do I look for instructions?

Jim Rumbaugh
 
I think you should look at automating IE. Search for "Internet Explorer Automation"

Tamar
 
Thank you Tamar

I now have enough information to keep me busy for a while.
You have pointed me in the right direction. I have already bookemarked 5 different sources.

I consider my question answered.

Jim Rumbaugh
 
Hopefully the code below can give you some insights.

pulls data from a form, auto login to a credit check app (data driven url and user/pass)

and finds the right links to click on and auto fills the web browser form for you.

works on IE 6/7.

*************
Code:
PARAMETERS CallingForm,lLogIn
LOCAL oHelio

SELECT CreditCheck
URL = ALLTRIM(URL)

IF EMPTY(UserName) OR EMPTY(PASSWORD) OR EMPTY(URL)
	MESSAGEBOX("You must setup Helio under Management in your POS",16,"Credit Check")
	RETURN
ENDIF
** Pulls from POS **
cLogIn       = ALLTRIM(UserName)	
cPassword    = ALLTRIM(PASSWORD)	
IF NOT lLogIn
	WITH CallingForm.pfPOS.INFO.cntrAddress
		cFirstName   = .txtcFirst.VALUE
		cLastName    = .txtcLast.VALUE
		cMiddleInit  = .txtcMiddle.VALUE
		cAddress1    = ALLTRIM(.txtcAddress.VALUE)
		cCity        = .txtcCity.VALUE
		cZip         = .txtcZipcode.VALUE
		cState       = .txtcState.VALUE
		cSSN         = STRTRAN(.txtcSSN.VALUE,'-','')
		cBirthDate   = DTOC(.txtdDOB.VALUE)
		cDOBMonth    = PADL(TRANSFORM(MONTH(.txtdDOB.value)),2,'0')
		cDOBDay	  	 = PADL(TRANSFORM(DAY(.txtdDOB.value)),2,'0')
		cDOBYear	 = TRANSFORM(YEAR(.txtdDOB.value))				
		cHomePhone   = .txtcHome.VALUE
	ENDWITH
EndIF



oHelio = CREATEOBJECT([InternetExplorer.Application])
oHelio.Silent = .T.
oHelio.WIDTH = SYSMETRIC(1)
oHelio.HEIGHT = SYSMETRIC(2)
STORE 0 TO oHelio.LEFT,oHelio.TOP
oHelio.NAVIGATE(URL)
oHelio.Visible = .t. 
WaitForIE(oHelio)
oHelio.DOCUMENT.FORMS(0).j_user.VALUE = cLogIn
oHelio.DOCUMENT.FORMS(0).j_password.VALUE = cPassword
oHelio.DOCUMENT.FORMS(0).Submit
WaitForIE(oHelio)
if lLogin
	return
endif 

inkey(1)
WaitForIE(oHelio)
NumOfLinks =  oHelio.Document.frames(1).document.links.length
INKEY(.5)
FOR li_link = 0 TO NumOfLinks - 1
	ls_Text = UPPER(oHelio.DOCUMENT.frames(1).DOCUMENT.Links[li_link].InnerText)
	?ls_Text
	IF ls_Text = 'CREDIT CHECK'
		oHelio.DOCUMENT.frames(1).DOCUMENT.Links[li_link].CLICK()
		EXIT
	ENDIF
NEXT





WaitForIE(oHelio)
oHelio.Document.frames(1).document.forms(0).FST_NM_.VALUE = cFirstName
oHelio.Document.frames(1).document.forms(0).MID_NM_.VALUE = cMiddleInit
oHelio.Document.frames(1).document.forms(0).LST_NM_.VALUE = cLastName
oHelio.Document.frames(1).document.forms(0).ADDR1_.VALUE  = cAddress1
oHelio.Document.frames(1).document.forms(0).CITY_.value   = cCity
oHelio.Document.frames(1).document.forms(0).STATE_.value  = cState
oHelio.Document.frames(1).document.forms(0).ZIP_CD_.VALUE = cZip
oHelio.Document.frames(1).document.forms(0).DATE_OF_BIRTH_M_.value = cDOBMonth
oHelio.Document.frames(1).document.forms(0).DATE_OF_BIRTH_D_.value = cDOBDay
oHelio.Document.frames(1).document.forms(0).DATE_OF_BIRTH_Y_.value = cDOBYear
oHelio.Document.frames(1).document.forms(0).PRIM_PHONE_.value	   = cHomePhone
*******************
PROCEDURE WaitForIE(toBrowser)
	DO WHILE toBrowser.Busy OR toBrowser.ReadyState <> 4
		DOEVENTS
	ENDDO
ENDPROC
*************************
FUNCTION ClickOnCreditCheck()
	NumOfLinks =  oHelio.Document.frames(1).document.links.length
	INKEY(.5)
	FOR li_link = 0 TO NumOfLinks - 1
		ls_Text = UPPER(oHelio.DOCUMENT.frames(1).DOCUMENT.Links[li_link].InnerText)
		?ls_Text
		IF ls_Text = 'CREDIT CHECK'
			oHelio.DOCUMENT.frames(1).DOCUMENT.Links[li_link].CLICK()
			EXIT
		ENDIF
	NEXT
ENDFUNC

Ali Koumaiha
Wireless Toyz
Farmington Hills, Michigan
 
TeknoSDS

That was a BIG help

I have adapted your code to my program with good results. Thank you very much. Now I need start a new thread on how to do the next step.

Thanks you very much

Jim Rumbaugh
 
You're welcome!

What's your other question?

Ali Koumaiha
Wireless Toyz
Farmington Hills, Michigan
 
TeknoSDS

I need to know how to find out what methods and properties are available on the page. For example, in your code the comand was:

Code:
 oHelio.DOCUMENT.frames(1).DOCUMENT.Links[li_link].InnerText
in my application it was:
Code:
 IE.Document.Links(i).Innertext
The part "frames(1).DOCUMENT" was not needed. I found my code via trial and error. IntelliSense only shows the basic Internet Explorer methods and propertires. It does not show the "Links(i).Innertext" methods/properties.

So where do I go to learn??.

Jim Rumbaugh
 
Depends on the HTML of the web page.

In your example, your page had
Code:
<html>
  <body>
    <form>
         <a href=""> </a>
   </form>
  </body>
</html>

In my case, the link (a href) was inside an IFRAME (which could be inside another IFRAME etc..)

So, in my example, you have to reference it..

Just like VFP, when you have an object inside a container on a form,

you'd would do something like:

Code:
  Thisform.cntrCustInfo.txtcFirstName.value
  
  vs.
  Thisform.txtcFirstName.value && Not in a container

Hope that clarified things a little for you.

Ali Koumaiha
Wireless Toyz
Farmington Hills, Michigan
 
Oh, and Unfortunately, IE documentation is very limited. I did alot of "googling" and i found alot of codes in PHP, Python, etc.. I was able to decypher them :) into VFP



Ali Koumaiha
Wireless Toyz
Farmington Hills, Michigan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top