I have Web form and when I fill in fields with Vb-script i get popup message box OK/Cancel.
I can not get my script to click on that OK button. Anyone has solution?
Set IE = Createobject("InternetExplorer.Application")
IE.Navigate "*******/page"
IE.Visible = True
Wscript.Sleep 500
IE.Document.All.Item("user").Value = "username"
IE.Document.All.Item("pass").Value = "password"
IE.Document.All.Item("submit").Click ' ******here popup window appears
Wscript.Sleep 500
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "{ENTER}" ' ******this does not execute
I had the same problem, so I wrote a second script with the soul purpose of sending "ENTER" after a delay of 1 second (or whatever) and execute this file right before you "Click" Submit.
it's a very ugly workaround, but it works. so it'll have to do until I find a better selution
Related
So I have a really annoying set of forms at work that I have to fill out daily and spend about 20 minutes doing so, I was looking to script this and have a basic sendkeys method that works but I wanted to improve this.
Dim WshShell, objIE, ElementCol
Dim LinkHref
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "Webpage Title"
Set objIE = CreateObject("InternetExplorer.Application")
wshShell.AppActivate objIE
Do While objIE.Busy
wscript.sleep 100
Loop
Set ElementCol = objIE.document.getElementsByTagName("a")
For Each Link In ElementCol
If Link.innerHTML = "*Specfic text" Then
Link.Click
Exit For
End If
Next
So I get an error on the Set ElementCol line that says null thats my first issue
For the *specific text is this allowed? Basically I know the text of the links will be Hello and world but could pop in like 1) Hello and 2) World or 1) World 2) Hello
I also want to after the click run a different .vbs script that fills out the form after that .vbs script completes it returns back to this initial page where I want to continue on this script to the next link.
Thanks a ton for any help!
The development is done in angular js and am using UFT(QTP)12.02 for test automation. Using select and extend select for the items in the weblist appears like selected(the selected items are gray) but the dependent controls are not being populated.
Also tried this ,but no luck
Setting.WebPackage("ReplayType") = 2
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys Datatable.Value("AssignedTerminal", dtlocalsheet)
WshShell.SendKeys "{TAB}"
Set WshShell = Nothing
Setting.WebPackage("ReplayType") = 1
I am trying to run a vbscript that will load up a html page in chrome and then do control+a which will select everything on the page, with the ultimate view to copy it and then paste it into excel.
this my script so far:
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim iURL
Dim objShell
iURL = "C:\Users\Aasfasf\AppData\Local\Temp\TD_80\hpqc\52136023e30\****\121200.html"
set objShell = CreateObject("WScript.Shell")
objShell.run(iURL)
WScript.Sleep 1500
WshShell.SendKeys "^a"
when I run it loads up the html page, but i dont think the control+a command is working as nothing is selected.
Two suggestions:
The focus is probably not on the content in chrome. Try sending a Tab key press a couple of times first to see if that fixes it.
A better approach to this might be to just read the contents of the file, then delete all the markup from the document using regex.
Excel can just load your web page without needing any help from you.
Alt + D, D, W
I want to open an Internet Explorer page using vbscript, currently my script is as follows
Dim IE
Dim MyDocument
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = 0
IE.navigate "https://google.com"
This works fine. The problem is that I need to get the response of my webpage (google.com) i.e its contents in string format
I know it will be mostly gibberish but I require it for what I am working on
Thanks
You're almost there already. You just need to wait until the page has finished loading
While IE.ReadyState <> 4 : WScript.Sleep 100 : Wend
then you can access the page text like this:
WScript.Echo IE.document.body.innerText
or the page HTML like this:
WScript.Echo IE.document.body.innerHTML
How to perform the Pressing of Enter Action in QTP. I'm selecting a cell and able to set a value ,now I want to press enter key and get the list from that Java Edit box. Which are the different ways I can achieve this?
Use mentioned above Type method: YourObject.Type micReturn
Use SendKeys method:
Function SendKeys(sKey)
Set WshShell = CreateObject("WScript.Shell")
WshShell.AppActivate "Your browser" ' You may need to activate your browser first
WshShell.SendKeys sKey
wait(1) ' You may need to add some Wait statements around
End Function
In your case it will be
SendKeys "{ENTER}"
See MSDN SendKeys and MSDN AppActivate for more details.
You can either send key (micEnter) through .Type() method of the object or use FireEvent to invoke an event handler directly.
Set WshShell = CreateObject("WScript.Shell")
WshShell.AppActivate
WshShell.SendKeys (ENTER) '--------parenthesis