VBScript error 80004005 check class in IE Document - vbscript

I'm trying to set my script to sleep until a class is available in a website.
Set IE = createobject("internetexplorer.application")
strURL = "SomeUrl"
If IsNull(IE.Document.GetElementsByClassName("button")) Then
IE.navigate strURL
Do While (IE.Busy Or IE.ReadyState <> 4)
WScript.Sleep 100
Loop
End If
I've looked the error and it does not specify what is wrong so I have no idea.
"Unspecified Error" Code 80004005 at:
If IsNull(IE.Document.GetElementsByClassName("button")) Then
I've also tried:
Set Button = IE.Document.GetElementsByClassName("button")
If IsNull(Button) Then
IE.navigate strURL
Do While (IE.Busy Or IE.ReadyState <> 4)
WScript.Sleep 100
Loop
Set Button = IE.Document.GetElementsByClassName("buttonp")
End If
Same error. What's the problem?

Related

How can I use an already open IE with VB Script? GetObject is not working

Below is the code block i used to open a new window. I tried using GetObject in place of Create Object as below. But did not work.
Set IE = GetObject("","InternetExplorer.Application")
'
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://msn.com"
Do While IE.ReadyState <> 4
WScript.Sleep 1000
Loop
Set ElementCol = IE.Document.getElementsByTagName("a")
For Each Link In ElementCol
If Link.innerHTML = "News" Then
Link.Click
WScript.Sleep(6000)
Exit For
End If
Next
IE.navigate "https://msn.com"
This uses Explorer which used to do the internet.
Set objShell = CreateObject("Shell.Application")
Do
Set AllWindows = objShell.Windows
Count = 0
For Each window in AllWindows
msgbox window.locationname
' window.refresh2 3
Count = Count + 1
Next
If Count = 0 then Exit Do
Wscript.sleep 5000
Loop

VB Script for auto Login into website giving an error

I am using below VB script for auto login in to website. It is entering username but it does not enter password and gives the error that 'doesn't support this property or method' . I have not worked in VB script , so not sure why this error is coming.
On Error Resume Next
Const PAGE_LOADED = 4
Set objIE = CreateObject("InternetExplorer.Application")
Call objIE.Navigate("http://www.gmail.com")
objIE.Visible = True
Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop
objIE.Document.all.username.Value = "username"
objIE.Document.all.Passwd.Value = "password"
If Err.Number <> 0 Then
msgbox "Error: " & err.Description
End If
Call objIE.Document.all.login_form.submit
Set objIE = Nothing
Try if this code can did the trick or not because gmail has changed its source code !
Dim IE
Set IE = Wscript.CreateObject("InternetExplorer.Application")
IE.Visible = 1
IE.navigate("https://accounts.google.com/ServiceLogin?service=ig&passive=true&continue=http://www.google.com/ig%3Fhl%3Den&followup=http://www.google.com/ig%3Fhl%3Den&cd=US&hl=en&nui=1&ltmpl=default")
Do While (IE.Busy)
WScript.Sleep 10
Loop
Set Helem = IE.document.getElementById("Email")
Helem.Value = "Your Login goes here" 'Change to your Gmail login
Set Helem = IE.document.Forms(0)
Helem.Submit
Do While (IE.Busy)
WScript.Sleep 10
Loop
wscript.sleep 2000
Set Helem = IE.document.getElementById("Passwd")
Helem.Value = "Your Password goes here" 'Change to your Gmail password
Set Helem = IE.document.Forms(0)
Helem.Submit

VB Script Set Statement

I need help with the following codes:
Dim IE
Dim UserName
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "http://www.nextview.com/index.php?country=my"
Do Until IE.ReadyState <> 3
Loop
Set UserName = IE.Document.getElementById("username") <----- ERROR
IE.Document.all.UserName.Value = "TESTING"
Set Login = IE.Document.getElementById("frmlogin")
Login.submit
Do Until IE.ReadyState <> 3
Loop
The codes are created to help me key in my username. But it has error at the location shown above.
Any idea how to solve this problem?
I think your waiting Do..Loop is not correct.
'Syntax notes:
Do Until [expression return False]
Do While [expression return True]
'So, you can use one of the next:
Do Until IE.readyState = 4
Wscript.Sleep 100
Loop
Do While IE.readyState <> 4
Wscript.Sleep 100
Loop

vbscript to send GET request using IE error

I've got the vbscript below which needs to send a GET request and then logoff the current user. The idea is to replace the default "logoff" start menu item with this script.
When I run it with cscript it throws an error on line 9,
HTTPGet = IE.document.documentelement.outerhtml
I don't understand what's wrong. Maybe I should wait to receive the response before logging off the user, but as the line above doesn't seem to work I logoff immediately.
TOKEN = "xxxxx"
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate "https://something.com/?action=create&token=" & TOKEN
Do While IE.Busy
WScript.Sleep 200 ' see the above notice of change
Exit Do ' prevents script host from going crazy waiting for IE
loop
HTTPGet = IE.document.documentelement.outerhtml
IE.quit
Set IE = Nothing
'WScript.Echo HTTPGet 'good for debugging. shows what you got back.
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "C:\WINDOWS\system32\shutdown.exe -l"
If it matters this is for Windows XP only with IE 8.
Try out this code:
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate "https://host/?a=" & TOKEN
i = 1
Do While (IE.readyState <> 4)
WScript.Sleep 1000 ' see the above notice of change
i = i + 1
If (i > 10) Then
Exit Do
End If
loop
HTTPGet = IE.document.documentElement.outerHTML
IE.Quit()
Set IE = Nothing

VBScript to Launch a website login

I found this script online, I edited most of it.
It is able to enter username, and password on its down but it is not able to click login.
please help me fix
Here is login forum.
http://desistream.tv/en/index.shtml
Here is Script currently it is in IE but I will need to change it open in Google Chrome.
WScript.Quit Main
Function Main
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "http://desistream.tv/en/index.shtml"
Wait IE
With IE.Document
.getElementByID("login_username").value = "myusername"
.getElementByID("login_password").value = "mypassword"
.getElementByID("form").submit
End With
End Function
Sub Wait(IE)
Do
WScript.Sleep 500
Loop While IE.ReadyState < 4 And IE.Busy
Do
WScript.Sleep 500
Loop While IE.ReadyState < 4 And IE.Busy
End Sub
Sub IE_OnQuit
On Error Resume Next
WScript.StdErr.WriteLine "IE closed before script finished."
WScript.Quit
End Sub
Here is...
Call Main
Function Main
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "http://desistream.tv/en/index.shtml"
Wait IE
With IE.Document
.getElementByID("username").value = "myusername"
.getElementByID("pass").value = "mypassword"
.getElementsByName("frmLogin")(0).Submit
End With
End Function
Sub Wait(IE)
Do
WScript.Sleep 500
Loop While IE.ReadyState < 4 And IE.Busy
End Sub
If you look at the page source, you'll see that the actual <form> tag is called frmLogin, not login.

Resources