daypro
asked on
vb6 InternetExplorer.application auto submit click
I Can use vb6 code auto fill user_id,user_code ,and password in webpage of https://eservice.chinalife.com.tw/sso/loginContent.jsp
when I manual mouse click login button it works ok
but using 'MyIE.Document.Forms(0).su bmit auto submit
it shows error message like security reason ,time out
how do I using vb6 program code to auto click login,
"https://eservice.chinalife.com.tw/sso/loginContent.jsp "
thanks.
'-------VB6 CODE Begin
Private Sub Command1_Click()
sUrl = "https://eservice.chinalife.com.tw/sso/loginContent.jsp"
Set MyIE = CreateObject("InternetExpl orer.appli cation")
MyIE.Navigate (sUrl)
Do While MyIE.Busy And Not MyIE.ReadyState = 4
DoEvents
Loop
MyIE.Document.Forms(0).use r_id.Value = "T120122924"
MyIE.Document.Forms(0).use r_code.Val ue = "99580212"
MyIE.Document.Forms(0).Pas sword.Valu e = "11111111"
'MyIE.Document.Forms(0).su bmit
MyIE.visible = True
End Sub
when I manual mouse click login button it works ok
but using 'MyIE.Document.Forms(0).su
it shows error message like security reason ,time out
how do I using vb6 program code to auto click login,
"https://eservice.chinalife.com.tw/sso/loginContent.jsp "
thanks.
'-------VB6 CODE Begin
Private Sub Command1_Click()
sUrl = "https://eservice.chinalife.com.tw/sso/loginContent.jsp"
Set MyIE = CreateObject("InternetExpl
MyIE.Navigate (sUrl)
Do While MyIE.Busy And Not MyIE.ReadyState = 4
DoEvents
Loop
MyIE.Document.Forms(0).use
MyIE.Document.Forms(0).use
MyIE.Document.Forms(0).Pas
'MyIE.Document.Forms(0).su
MyIE.visible = True
End Sub
cant you do someting with url posts like :
https://eservice.chinalife.com.tw/sso/PruServlet?type=iPC&module=SYSTEM&purpose=LOGON&user_id=T120122924&user_code=99580212&user_password=11111111
And in your form you are missing some paramters. The site contains 3 hidden items which or neccesarry to logon, these are set by a javascript when submitted.
type=iPC&module=SYSTEM&pur pose=LOGON
https://eservice.chinalife.com.tw/sso/PruServlet?type=iPC&module=SYSTEM&purpose=LOGON&user_id=T120122924&user_code=99580212&user_password=11111111
And in your form you are missing some paramters. The site contains 3 hidden items which or neccesarry to logon, these are set by a javascript when submitted.
type=iPC&module=SYSTEM&pur
ASKER
I try manual click
https://eservice.chinalife.com.tw/sso/PruServlet?type=iPC&module=SYSTEM&purpose=LOGON&user_id=T120122924&user_code=99580212&user_password=11111111
and try below code
but IE all show error message "Data base error"
-----
attach second file insu2.gif is manual mouse click result ok screen shot
-----------------vb6 code (still have problem,( IE show Data BASE ERROR)
Private Sub Command9_Click()
URL_STR = "https://eservice.chinalife.com.tw/sso/PruServlet?type=iPC&module=SYSTEM&purpose=LOGON&user_id=T120122924&user_code=99580212&user_password=11111111"
Dim IE As Object
Set IE = CreateObject("InternetExpl orer.Appli cation")
IE.visible = True
IE.Navigate URL_STR
' Wait for the page to load.
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
Set IE = Nothing
End Sub
insu1.GIF
insu2.GIF
https://eservice.chinalife.com.tw/sso/PruServlet?type=iPC&module=SYSTEM&purpose=LOGON&user_id=T120122924&user_code=99580212&user_password=11111111
and try below code
but IE all show error message "Data base error"
-----
attach second file insu2.gif is manual mouse click result ok screen shot
-----------------vb6 code (still have problem,( IE show Data BASE ERROR)
Private Sub Command9_Click()
URL_STR = "https://eservice.chinalife.com.tw/sso/PruServlet?type=iPC&module=SYSTEM&purpose=LOGON&user_id=T120122924&user_code=99580212&user_password=11111111"
Dim IE As Object
Set IE = CreateObject("InternetExpl
IE.visible = True
IE.Navigate URL_STR
' Wait for the page to load.
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
Set IE = Nothing
End Sub
insu1.GIF
insu2.GIF
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you realy wish to click that image then you can use the following. The image input has no ID so we need to find it on the form.
Public Sub myChina(ByVal szUser As String, ByVal szCode As String, ByVal szPass As String)
Dim IE As Object
Set IE = CreateObject("InternetExpl orer.Appli cation")
IE.Visible = True
IE.Navigate "https://eservice.chinalife.com.tw/sso/loginContent.jsp"
' Wait for the page to load.
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
IE.Document.getElementById ("user_id" ).Value = szUser
IE.Document.getElementById ("user_cod e").Value = szCode
IE.Document.getElementById ("password ").Value = szPass
IE.Document.getElementById ("type").V alue = "iPC"
IE.Document.getElementById ("module") .Value = "SYSTEM"
IE.Document.getElementById ("purpose" ).Value = "LOGON"
' Find the image that can perform a submit, the image has no id so we have to go through all input elements to find it
For i = 0 To IE.Document.getElementsByT agName("in put").Leng th - 1
If IE.Document.getElementsByT agName("in put")(i).T ype = "image" Then
On Error Resume Next
If Right(IE.Document.getEleme ntsByTagNa me("input" )(i).src, Len("btn_login.gif")) = "btn_login.gif" Then
IE.Document.getElementsByT agName("in put")(i).C lick
Exit For
End If
On Error GoTo 0
End If
Next
Set IE = Nothing
End Sub
Private Sub Command1_Click()
myChina "username", "12345", "111111"
End Sub
But this gives the same results as my previous post.
Public Sub myChina(ByVal szUser As String, ByVal szCode As String, ByVal szPass As String)
Dim IE As Object
Set IE = CreateObject("InternetExpl
IE.Visible = True
IE.Navigate "https://eservice.chinalife.com.tw/sso/loginContent.jsp"
' Wait for the page to load.
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
IE.Document.getElementById
IE.Document.getElementById
IE.Document.getElementById
IE.Document.getElementById
IE.Document.getElementById
IE.Document.getElementById
' Find the image that can perform a submit, the image has no id so we have to go through all input elements to find it
For i = 0 To IE.Document.getElementsByT
If IE.Document.getElementsByT
On Error Resume Next
If Right(IE.Document.getEleme
IE.Document.getElementsByT
Exit For
End If
On Error GoTo 0
End If
Next
Set IE = Nothing
End Sub
Private Sub Command1_Click()
myChina "username", "12345", "111111"
End Sub
But this gives the same results as my previous post.
ASKER
Thanks aelatik
It's really a wanderful solution
It's really a wanderful solution
Open in new window