Click Element value at end

2019-08-23 08:07发布

System taking getelementbyid value but it allow to login if we click at that box

I wanted to log in web page "https://www.connect2nse.com/MemberPortal/home.jsp" but site takes keyboard input values only

Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate "https://www.connect2nse.com/MemberPortal/home.jsp"
While ie.readyState <> 4: DoEvents: Wend
ie.Visible = True
ie.document.getElementById("user_id").Value = "1234ABC"
ie.document.getElementById("member_code").Value = "1234"
ie.document.getElementById("password").Value = "5678"
Dim VAL As String
VAL = InputBox("Enter Captcha Value", "CAPTCHA", "")
If VAL = "" Then
End
End If
ie.document.getElementById("loginCap").Value = (VAL)
ie.document.getElementById("ext-gen39").Click

System enables Submit button if UserID, Member Code, Password and Captcha entered using keyboard or click on that box by mouse

How to do it by VBA

1条回答
姐就是有狂的资本
2楼-- · 2019-08-23 08:18

You need to focus on the element first

ie.document.getElementById("loginCap").Focus
ie.document.getElementById("loginCap").Value = VAL

May I suggest you safely exit your code by using

If VAL = vbNullString Then Exit Sub 

rather than your current If statement which uses End.

Also, use a proper page load wait with

While ie.Busy Or ie.readyState < 4: DoEvents: Wend
查看更多
登录 后发表回答