This code gets me to the page and fills in the userid and password fields but after it does the submit I get a response from the application that the userid and password are not valid. If I don't execute the submit command but let the program stop at the page then manually click the login button then I successfully login. It appears eventhough the userid and paasword are being filled in correctly on the form, they are not getting passed through to the next page properly.
Any thoughts? I'm a VBsript newbie.
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "https://cpprod.stjohns.edu/cp/home/displaylogin"
Do
WScript.Sleep 500
loop While IE.ReadyState < 4 And IE.Busy
IE.Document.getElementByID("user").value = "testacct"
WScript.Echo IE.Document.getElementByID("user").value
IE.Document.getElementByID("pass").value = "testpw"
WScript.Echo IE.Document.getElementByID("pass").value
IE.Document.getElementByID("cplogin").submit
Give the below a try and let me know your results...
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
oIE.navigate WebPath
Do
WScript.Sleep 250
Loop While oIE.ReadyState < 4 And oIE.Busy
oIE.Document.All.Item("username").Value = sUser
WScript.Sleep 250
oIE.Document.All.Item("password").Value = sPass
WScript.Sleep 250
oIE.Document.All.Item("login").Click
Related
Im making a game called cube, when I noticed a problem. I looked at Task Manager Fr Any Extra Programs, when I noticed tons of vbsscript running. I tried searching around, but no scripts worked for me. Heres my code (It plays A Sound)
Set Sound = CreateObject("WMPlayer.OCX.7")
Sound.URL = "Sounds\Hurt.mp3"
Sound.Controls.play
do while Sound.currentmedia.duration = 0
wscript.sleep 100
loop
wscript.sleep (int(Sound.currentmedia.duration)+1)*1000
WScript.Quit 1
It still doesn't want to stop. Please Help.
Try the below example
With CreateObject("WMPlayer.OCX.7")
.URL = "C:\Users\DELL\Desktop\tmp\hit.wav"
.controls.play
Do
WScript.Sleep 100
Loop Until .playState = 1 Or .playState = 10
' .PlayState https://msdn.microsoft.com/en-us/library/windows/desktop/dd564085(v=vs.85).aspx
' "Stopped" (completed) or "Ready" (file not found)
End With
what I do is I navigate to a site then I want to find an element called "jobId"
Const PAGE_LOADED = 4
Set objIE = CreateObject("InternetExplorer.Application")
Call objIE.Navigate("http://172.25.25.32:8090/")
objIE.Visible = True
Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop
objIE.Document.all.Username.Value = "ashishgi"
objIE.Document.all.Password.Value = "apac2015#"
If Err.Number <> 0 Then
msgbox "Error: " & err.Description
End If
Call objIE.Document.all.gaia_loginform.submit
Set objIE = Nothing
when I use ViewSource this is the elements I want to use :
input type="submit" name="btnsubmit" value="Login" id="logincaption" class="button" style="color:#565656"
So, you're trying to click submit? Your explanation is difficult to interpret what you want the script to do. Based on the element you displayed on your sample is a submit button. It's been a while since I automated a form but I believe you want something to this effect.
objIE.Document.getElementsById("Username").Value = "ashishgi"
objIE.Document.getElementsById("Password").Value = "apac2015#"
' If you want to use the button by name
objIE.Document.all.item("btnsubmit").click
' If you want to use the button by ID
objIE.Document.getElementsById("logincaption").click
'if that fails, make it an object like this and action the click.
Set Submit = objIE.Document.getElementsById("logincaption")
submit.click
Hi i am new to vbs and I am trying to create a vbs script to enter data into a field on a website and output the text returned to a text file
thats what I created so far:
Dim objIE
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = 1
objIE.navigate "http://translation.babylon.com/english/to-spanish/"
WScript.Sleep 100
Do while objIE.busy
Wscript.sleep 200
Loop
objIE.Document.all.Item("translator_input").Value = "sample text"
WScript.Sleep 100
Do while objIE.busy
Wscript.sleep 200
Loop
Call objIE.Document.all.Item("btnTranslate").Click
Objie.Quit
any ideas how to copy the transelation into a txt. or excel doc.?
Using Chrome's DOM inspector, it appears the translated text is put into this element:
<div id="resltext" name="resultext">
</div>
So you should be able to get the text by just looking for the ID and returning the value of innerText:
strTranslated = objIE.Document.All.Item("resltext").innerText
I've got a classic ASP application that contacts a database and receives a valid response but then crashes with
Error Number 9: Subscript out of range
after exiting the IF block the db call is made in. What's odd is that the same code is currently working in production. As far as I can tell they're configured identically (but I suspect there's a subtle difference that's causing this issue) and have identical code bases.
What I want to know is:
Where is this array that I'm supposedly attempting to reach a non-existent index of? I don't see it and the error gives no line number. Is there a chance something is not working correctly in the adodb library?
Perhaps this is a common problem having to do with a certain patch and my particular db connection library? Have you had a similar experience?
How do I troubleshoot a problem that doesn't immediately present itself? Should I just start putting troubleshooting statements in the library?
Explanation of what's happening in the code: When the cookie "click" is received err.number is 0. When the cookie "bang" is received the err.number is 9. It then crashes with that error at the end of the IF block.
<%#Language="VBSCRIPT"%>
<% Server.ScriptTimeout = 150 %>
<%
On Error resume Next
%>
<!--#include file="adovbs.inc"-->
<!--#INCLUDE FILE="DBConn.asp"-->
<!--#INCLUDE FILE="ErrorHandler.asp"-->
<%
'Application Timeout Warning
sessionTimeout = 20
advanceWarning = 5
jsTimeout = (sessionTimeout - advanceWarning) * 60000
'If the users session has expired
If Session("USERNAME") = "" or Session("USERNAME") = NULL Then
Response.Redirect("default.asp")
End If
'If the user has just changed their password. Prompt them that it was successfully changed
If Request("changePasswd") = "true" Then
Response.Write("<script language='Javascript'>alert('Your Password Has been Successfully Changed!');</script>")
End If
Dim connection, cmd, objRS, latestDate, lastDateJPMC, firstDateJPMC, lastDateWACH, firstDateWACH, lastDateWFB, firstDateWFB, accountCount
Function calConvertDate(theDate)
Dim yr, mn, dy, dtSplit
dtSplit = Split(theDate,"/")
yr = dtSplit(2)
mn = dtSplit(0)
dy = dtSplit(1)
if Len(mn) = 1 then mn = "0" & mn
if Len(dy) = 1 then dy = "0" & dy
calConvertDate = "[" & yr & "," & mn & "]"
End Function
set connection = Server.CreateObject("adodb.connection")
connection.Open DBConn
connection.CommandTimeout = 60
set connection = Server.CreateObject("adodb.connection")
connection.Open DBConn
connection.CommandTimeout = 60
'Get Earliest & Latest Date in Database
If Err.Number = 0 Then
Response.Cookies("CLICK")=Err.number
Set cmd = Server.CreateObject("ADODB.Command")
With cmd
Set .ActiveConnection = connection
.CommandText = "CIRS_Admin.spGetLatestDate"
.CommandType = adCmdStoredProc
set objRS = .Execute
End With
latestDate = calConvertDate(objRS("latestDate"))
Response.Cookies("latestdate")=objRS("latestDate")
objRS.Close
Set objRS = Nothing
Response.Cookies("BANG")=Err.number
End If
To debug, please add a statement like
Response.Write (objRS("latestDate"))
before the line
latestDate = calConvertDate(objRS("latestDate"))
so you can see if (for example) the date returned from the server has "-" as separator instead of "/" or if an empty value is returned.
After understanding what is causing the problem you can solve it
1.Where is this array that I'm supposedly attempting to reach a non-existent index of? I don't see it and the error gives no line number. Is there a chance something is not working correctly in the adodb library?
This is your array:
yr = dtSplit(2)
mn = dtSplit(0)
dy = dtSplit(1)
What's odd is that the same code is currently working in production. As far as I can tell they're configured identically (but I suspect there's a subtle difference that's causing this issue) and have identical code bases.
May be you have different regional settings?
I strongly suggest to you use better error handling.
Internal Server Error 500 w/ IIS Log
I'm gettinga n error message in line 8 when I try to call out the script to stop when it finds teh attribute in the Web page: field in AD.
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUserDN)
strwWWHomePage = objItem.Get("wWWHomePage")
If wWWHomePage 6 Then
wscript.quit
Else
Set ppt = CreateObject("PowerPoint.Application")
ppt.Visible = True
ppt.Presentations.Open "\\abngan01\tracking\ppt.pptx"
End If
You have:
If wWWHomePage 6 Then
I'm assuming you want it to say:
If wWWHomePage = 6 Then
Since the missing "=" will cause an error, but since that code really doesn't do anything anyway, other than just abort the script, you could simplify your code by only taking action if that value is not set, for example:
If objItem.Get("wWWHomePage") <> 6 Then
Set ppt = CreateObject("PowerPoint.Application")
ppt.Visible = True
ppt.Presentations.Open "\\abngan01\tracking\ppt.pptx"
End If
I'm also assuming "6" is some sort of flag you've set yourself, you might want to use something a little more descriptive like "PPTSTATUS006", or something along those lines.