Robert Berke
asked on
IE developer tool "gathering textbox names" from a web page/
I want to automate a program for entering data to a government web page.
The web page has about two dozen textboxs, each of which as an element name.
Here is how I currently do this with my dual monitor setup.
1 I open notepad on screen 2
and open ie webpage on screen 1
2 f12 to developer tool and move it to screen 2
3 screen 2 > find > select element by click.
4 in ie click on textbox #1
5 on screen 2, the html for textbox #1 is automatically highlighted. I right click > copy
6 I paste it into notepad.
I repeat steps 3 to 6 for all the text boxes.
This is a little cumbersome. Is there anything like the Excel Recorder, that can be used to automatically gather the field names, so I can just click from one field to another and have the text automatically be put to the clipboard, or similar scratch area?
rberke
The web page has about two dozen textboxs, each of which as an element name.
Here is how I currently do this with my dual monitor setup.
1 I open notepad on screen 2
and open ie webpage on screen 1
2 f12 to developer tool and move it to screen 2
3 screen 2 > find > select element by click.
4 in ie click on textbox #1
5 on screen 2, the html for textbox #1 is automatically highlighted. I right click > copy
6 I paste it into notepad.
I repeat steps 3 to 6 for all the text boxes.
This is a little cumbersome. Is there anything like the Excel Recorder, that can be used to automatically gather the field names, so I can just click from one field to another and have the text automatically be put to the clipboard, or similar scratch area?
rberke
Does your browser support auto form fill?
ASKER
I am using IE 10, and yes it does support auto form fill. But, the data is dynamic, so I plan on using vba to fill in to web page
If you just find the form tag in you can copy that then past the to your note pad. From there you can easily see the input tags and grab what you need.
This does not seem to work well using IE because when you paste, the formatting did not keep the line breaks. When I do this in chrome, you can see the same line breaks and it is much easier to read.
On a side, note, if you are posting to a website from outside the site, make sure it is within the terms of service.
This does not seem to work well using IE because when you paste, the formatting did not keep the line breaks. When I do this in chrome, you can see the same line breaks and it is much easier to read.
On a side, note, if you are posting to a website from outside the site, make sure it is within the terms of service.
ASKER
You suggested <<If you just find the form tag in you can copy that then past the to your note pad. From there you can easily see the input tags and grab what you need.>>
I am already doing exactly what you suggest. In fact, that is exactly what I outlined in my original post.
I was looking for an easier way. Instead of two dozen cut and paste operations I want something that would put the key-able text boxes clipboard.
I am already doing exactly what you suggest. In fact, that is exactly what I outlined in my original post.
I was looking for an easier way. Instead of two dozen cut and paste operations I want something that would put the key-able text boxes clipboard.
ASKER
I wrote a vba routine to do what I wanted. Using this routine, I generated code for 2 dozen txt fields in 1 minute !!!!
But, if a rookie web developer like me can do this in a few hours, there has GOT TO BE a nifty tool that will do it for me in a much better manner.
Experts-Exchange MUST have a web developer expert that has seen something like this.
I am keeping this post open in the hopes that some guru can point me to such a tool. If nobody can help, I will PAQ it with my own answer.
rberke
But, if a rookie web developer like me can do this in a few hours, there has GOT TO BE a nifty tool that will do it for me in a much better manner.
Experts-Exchange MUST have a web developer expert that has seen something like this.
I am keeping this post open in the hopes that some guru can point me to such a tool. If nobody can help, I will PAQ it with my own answer.
rberke
Sub IEMTC()
' ieMtc = make textbox code
' creates code for current text box, then advances to next textbox.
'
' keyin the values you want in the text boxes then position cursor to first text box.
' run IeMtc
' it will put .document.getelementbyname("xxxxx")(0).value = "xyz"
Dim objie, code
Set objie = waitThenGetobject("InternetExplorer.Application")
With objie
code = ".Document.getElementsByName('aaaaa')(0).Value = 'vvvvv'"
code = Replace(code, "aaaaa", .Document.activeElement.name)
code = Replace(code, "vvvvv", .Document.activeElement.Value)
code = Replace(code, "'", chr$(34))
Debug.Print code
AppActivate "Windows Internet Explorer"
Sleep 100
SendKeys "{TAB}"
AppActivate Application ' <== only needed if I am using vba IDE to test the code.
End With
End Sub
Function waitThenGetobject(objectclass As String) As Object ' this routine is useful because getobject("Internetexplorer.application") gives Error Number: 429" "ActiveX component can't create object or return object
' this returns the first object of the desired type
' only tested with internetexplorer.application
If LCase(objectclass) <> "internetexplorer.application" _
And LCase(objectclass) <> "x.y" Then Error 1
Dim shellWins As SHDocVw.ShellWindows
Dim explorer As SHDocVw.InternetExplorer
Set shellWins = New SHDocVw.ShellWindows
On Error Resume Next ' avoid problem: sometimes this code threw -2147417848 The object invoked has disconnected from its clients.
For Each explorer In shellWins
If Not explorer Is Nothing Then
Dim fullname As String
fullname = ""
fullname = explorer.fullname
If InStr(1, fullname, "iexplore.exe", 1) > 0 Then
Set waitThenGetobject = explorer
End If
End If
Next
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
After 10 years of programming vba, I am pretty good at it, but I know nothing about Java Script, or xmlhttp.
I tried copying your script into a MyProg.js file, but I just guessed at the extension, and it got nowhere.
I clicked on your hyperlink, which executed fine, but when I pasted HTML into the text box nothing happened.
And, I copied your vbscript into a myprog.vbs file, changed the URL and of course, it didn't compile because the <% isn't really vbscript.
3 strikes so far, and I feel like I am really out.
I admit am in way over my head and should take a class on all this junk.
If you have time, I hope you can give me a few pointers, but I realize I have way too much too learn, so I should probably just close this question.
I tried copying your script into a MyProg.js file, but I just guessed at the extension, and it got nowhere.
I clicked on your hyperlink, which executed fine, but when I pasted HTML into the text box nothing happened.
And, I copied your vbscript into a myprog.vbs file, changed the URL and of course, it didn't compile because the <% isn't really vbscript.
3 strikes so far, and I feel like I am really out.
I admit am in way over my head and should take a class on all this junk.
If you have time, I hope you can give me a few pointers, but I realize I have way too much too learn, so I should probably just close this question.
<% is typically asp classic and that is what I used but it is vbscript not vba. Well, a mix of asp and vbs.
The way you should start is by simply taking the original html code I gave you here http:Q_28365799.html#a39868961, copy all of it, paste it to your text editor, then save it as a .html file. So we are talking the same thing, save it as test.html
Now you can open test.html with your browser and you shouldn't even have to do it using localhost at this point. It should look and act identical to the jsbin link I gave you. You will have to have an internet connection as I am referencing the jquery cdn.
Can you get that working?
Do you have localhost running? can you run php or asp?
The way you should start is by simply taking the original html code I gave you here http:Q_28365799.html#a39868961, copy all of it, paste it to your text editor, then save it as a .html file. So we are talking the same thing, save it as test.html
Now you can open test.html with your browser and you shouldn't even have to do it using localhost at this point. It should look and act identical to the jsbin link I gave you. You will have to have an internet connection as I am referencing the jquery cdn.
Can you get that working?
Do you have localhost running? can you run php or asp?
ASKER
I saved it as Myprog.html and it runs just like the jsbin.
Don't know how to tell if local host/php/asp is running.
When I look for files ending in php, I see the extension is associated with microsoft expression Web version 4.0 free version (which I installed recently and never used.)
Don't know how to tell if local host/php/asp is running.
When I look for files ending in php, I see the extension is associated with microsoft expression Web version 4.0 free version (which I installed recently and never used.)
ASKER
I made some progress.
How can I modify your wonderful application, so that I can simply paste the ENTIRE tgt.htm. webpage.
Here are a few details.
I changed my target.html to target.txt, and opened it in notepad.
If I grab specific chunks of my tgt.txt and paste it into your JS Bin text window, it does a GREAT job of parsing dozens of text boxes.
But, when I use ctrl A to grab all of tgt.txt and paste it into JS Bin, NOTHING happens.
I played a little, and grabbed most of tgt.txt from <html> to ></html>.
When I paste that into your window, it renders the entire webpage, but didn't parse any text box names.
I then randomly dropped a dozen lines from the top and bottom of tgt.txt and pasted that into JS Bin. Voila, it produced a COMPLETE list.
So how can I modify your wonderful application, so that I can simply paste the ENTIRE tgt.htm. webpage?
How can I modify your wonderful application, so that I can simply paste the ENTIRE tgt.htm. webpage.
Here are a few details.
I changed my target.html to target.txt, and opened it in notepad.
If I grab specific chunks of my tgt.txt and paste it into your JS Bin text window, it does a GREAT job of parsing dozens of text boxes.
But, when I use ctrl A to grab all of tgt.txt and paste it into JS Bin, NOTHING happens.
I played a little, and grabbed most of tgt.txt from <html> to ></html>.
When I paste that into your window, it renders the entire webpage, but didn't parse any text box names.
I then randomly dropped a dozen lines from the top and bottom of tgt.txt and pasted that into JS Bin. Voila, it produced a COMPLETE list.
So how can I modify your wonderful application, so that I can simply paste the ENTIRE tgt.htm. webpage?
We just need to filter for the input. I have updated the js portion below and this is the new working sample. http://jsbin.com/padasQ_28365799/3/edit?html,output
$( document ).ready(function() {
$('textarea').focusout(function () {
var formData = $(this).val();
formData=$(formData).filter(':input');
$('#temp').html(formData);
getHtml();
});
function getHtml() {
var xHtml = '';
var myArray = [];
$('#temp input').each(function () {
var name = $(this).attr('name');
myArray.push(name);
});
$('#temp').hide();
$('#results1').text(myArray);
for (var i = 0; i < myArray.length; i++) {
xHtml = xHtml + myArray[i] + '<br>';
}
$('#results2').html(xHtml);
}
});
ASKER
Well, it still does nothing when I paste the entire contents of the html file.
But, it probably isn't worth pursing right now, I have already used the output from my previous step, and am on to other tasks now.
When I have more time, I may repost and see if we can get it to work better.
I will close the problem with thanks for your help.
But, it probably isn't worth pursing right now, I have already used the output from my previous step, and am on to other tasks now.
When I have more time, I may repost and see if we can get it to work better.
I will close the problem with thanks for your help.