0

I am trying to automate login process for a website. I used below code

Dim objIE
Dim htmld
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = False
objIE.Navigate "website.com"  //website.com is example not the original
While objIE.Busy
WScript.Sleep 400
Wend
WScript.Sleep 500
objIE.Document.getElementById("login_id").value = "ss"

the html code for the textbox login_id is

<TABLE id=logintable cellSpacing=0><TBODY>
<TR>
<TD><IMG src="/nfusion/default/en_US/images/sign_in_flag.gif"></TD>
<TD class=tdlabel>User ID:</TD>
<TD><INPUT id=login_id class=txt name=login_id></TD></TR>
<TR>
<TD></TD>

I am getting error of the interface is unknown. I have changed the security and login_id does not have tag so i was not able to use getElementByTag.

5
  • Why VBScript? Why not JavaScript? Commented Nov 27, 2015 at 13:08
  • coz i am using VBS for related function. Why down votes ? Commented Nov 27, 2015 at 17:51
  • What is the host you are running? VBA or WSH VBS? Remove extraneous tag. What security did you change and how? What do you mean saying getElementByTag? There is no such method. Commented Nov 27, 2015 at 19:05
  • @user3201928 Okay, not sure about the downvotes... Commented Nov 27, 2015 at 19:48
  • @user3201928 I voted you up, this is a great question, and the answer I provided below I use everyday to do exactly what you have asked. It saves me a lot of time and effort. Commented Dec 4, 2015 at 8:09

2 Answers 2

1

Try these additional checks:

Dim IE
Set IE = CreateObject("InternetExplorer.Application")
With IE
    .Visible = False
    .Navigate "website.com" ' website.com is example not the original
    Do While .Busy Or Not .readyState = 4: WScript.Sleep 100: Loop
    Do Until .document.readyState = "complete": WScript.Sleep 100: Loop
    Do While TypeName(.document.getElementById("login_id")) = "Null": WScript.Sleep 100: Loop
    .document.getElementById("login_id").Value = "ss"
End With
Sign up to request clarification or add additional context in comments.

1 Comment

Object doesn't support this property or method error
0

I wrote a vbscript to do just what you asked, and I use it all the time. It opens up one tab in IE, and logs in, then it opens two more tabs to different pages in our application.

On Error Resume Next

ECRecord = "http://vm195/views/welcome.action"
ECJobs = "http://vm195/views/job/jobList.action?query.MaxResults=500&allStates=false%2F&query.ActiveState=true&query.ActiveState=false%2F&query.PendingState=true&query.PendingState=false%2F&query.CompletedState=false%2F&query.FailedState=true&query.FailedState=false%2F&query.CancelledState=true&query.CancelledState=false%2F&query.HoldState=true&query.HoldState=false%2F&query.jobTypes=-1&allFreqs=true&allFreqs=false%2F&query.DailyFrequency=true&query.DailyFrequency=false%2F&query.IntervalFrequency=true&query.IntervalFrequency=false%2F&query.SetDateFrequency=true&query.SetDateFrequency=false%2F&query.SingleFrequency=true&query.SingleFrequency=false%2F&query.patientId=&query.accessionNumber=&query.studyPk=&query.dateRange=-3&query.beginDate=&query.endDate=&Submit=Search&refreshRate=120"
ECConfig = "http://vm195/views/org/organizationTree.action"

Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
'open a new window
oIE.Navigate2 ECRecord

Do While (oIE.Busy)
   WScript.Sleep 10
 Loop                    


 Set Helem = oIE.document.getElementByID("username")
 Helem.Value = "tsu500" ' change this to yours
 Set Helem = oIE.document.getElementByID("password")
 Helem.Value = "production" ' change this to yours

 oIE.Document.getElementsByName("submit_button").Item(0).Click

 'Set Helem = oIE.document.Forms(1)
 'Helem.Submit


WScript.Sleep 500


Do While (oIE.Busy)
   WScript.Sleep 10
 Loop  


'open url In new tab
oIE.Navigate2 ECJobs, 2048
WScript.Sleep 100
oIE.Navigate2 ECConfig, 2048

Set oIE = Nothing 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.