-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Yes all code should work in 2003, as the example uses the COM webbrowser, not the windows forms webbrowser which was introduced in 2005.
The windows forms webbrowser is basically a wrapper around the COM interface, run all in managed code, however it has many short comings and missing features (I assume for full managed code compatibility). For example (just one of many) the 2.0 webbrowser doesn't have a navigate_error event, but the COM one does.
As far as your error, I am not sure why you are getting it, as it could be related to the specific HTML page you are parsing the data out of. If you run the example code, you will see that it does infact work to get text from a textbox in a webpage.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Ok, I found a way to get the value a the txtVersion when the page is not in a frameset :
VB Code:
Private Sub AxWebBrowser1_DownloadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxWebBrowser1.DownloadComplete
Dim document As mshtml.HTMLDocument = DirectCast(AxWebBrowser1.Document, mshtml.HTMLDocument)
Dim form As mshtml.HTMLFormElement = DirectCast(document.forms.item(0), mshtml.HTMLFormElement)
Dim Version As String = DirectCast(form.item("txtVersion"), mshtml.HTMLInputElement).value
MsgBox("Version : " & Version)
End Sub
Do you have an idea when the page is in the second frame of a frameset ?
This doesn't work :
VB Code:
Private Sub AxWebBrowser1_DownloadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxWebBrowser1.DownloadComplete
Dim document As mshtml.HTMLDocument = DirectCast(AxWebBrowser1.Document, mshtml.HTMLDocument)
Dim frame1 As mshtml.HTMLFrameElement = DirectCast(document.frames.item(0), mshtml.HTMLFrameElement)
Dim frame2 As mshtml.HTMLFrameElement = DirectCast(document.frames.item(1), mshtml.HTMLFrameElement)
Dim form As mshtml.HTMLFormElement = DirectCast(frame2.forms.item(0), mshtml.HTMLFormElement)
Dim Version As String = DirectCast(form.item("txtVersion"), mshtml.HTMLInputElement).value
MsgBox("Version : " & Version)
End Sub
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
If you want to make me a little dinky 2 frame HTML page, I will be more than happy to use it here to write some code to grad the data out of it.
The issue MAY be in the fact that inside each frame might be considered a document, so you would have to grad the document of the frame, then the form from the document. (and then the textbox element)
If you want to upload me a sample page to use for analysis, I can confirm that.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I will try to PM the source code tonight or tomorrow, but please, do not share... Just take what you need.
I also found something interresting; you cannot grab value of a textbox with property visible = false...
Thanks,
Pass
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
do you mean an ASP.NET textbox with visible set to false? If so, that is because ASP.NET simply doesn't even render HTML for it when its not visible.
If you are talking about a regular <input type=text> tag, then visible isn't a valid HTML property of the tag anyway.
Also, I don't need your whole source, I just need a sample HTML page with frames in it, so I can test grabbing data in the frames. If you provide one, I will take a look at it and try to provide an answer.
-
Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hello sir,
I am new member to this forum.
I have one doubt in vb.net 2005.
How to set the file upload element value using web browser control?.
Thank you for advance.
Regards,
Subu
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I am tried using setattribute and other command in .net 2005 but i can set the value of file upload element but i am trying send key to set the value but this is very slow.
There is anyother solution?.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I have a newbie question that hopefully the experts here can answer quickly without me being too much of a nuisance. In the past, I have created simple apps to fill in username and password fields using the webbrowser control in VB.
However, now I am trying to get past a page that implements frames, one of which contains the username and password fields in question. For some reason the method I have used in the past (with varying field names, obviously), namely:
With wWeb.Document
.All("username").Value = "loginid"
.All("password").Value = "pword"
.getElementById("Submit").Click
End With
doesn't work with frames. The web page in question will not let me navigate just to the frame that I need (probably for security reasons).
My questions are:
1. Can anyone point me to where I can get some documentation for what properties and methods can be used under the Document property (i.e. some documentation on WebBrowser.Document.GetElementById or WebBrowser.Document.GetElementByName or WebBrowser.Document.Frames(x) or other properties and methods). I can't help but think if I could get to that information I could figure it out.
2. Can anyone figure out how I should modify the above code to satisfy this web page --> https://sportal.uspto.gov/authentica...rLocalEPF.html
I would prefer to use VB6 but also have access to VB.NET 2005.
Thanks for any help you can render.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I am not aware of any easy way to auto fill content within frames.
I also didn't find anything that looked promising in my searches.
If I do figure out a way to manipulate content in frames, I will update this example code accordingly ;)
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Ok... this should be easy, but I'm having a terrible time...
kleinma, I've looked over your sample and still can't get this to work:
All I'm trying to do is fill in the info on the paypal website and log in. The email field is named "login_email", the password field is "login_password", and the submit button is named "submit.x"
I've scrapped all of my repeated attempts, because I haven't been able to get anything to work.
I've ended up with this, even though I know it's not exactly how you coded your sample, I ended up straying away because I couldn't get yours to work.
Code:
If IsBrowserBusy(WebBrowser1) = False Then
Dim HTML As HtmlDocument
Dim HTMLS As mshtml.HTMLInputButtonElement
HTML = WebBrowser1.Document
HTML.All.Item("login_email").InnerText = "***"
HTML.All.Item("login_password").InnerText = "*****"
HTML.All.Item("submit").Click()
For Each HTMLS In WebBrowser1.Document.GetElementsByTagName("input")
If HTMLS.type = "submit" And HTMLS.value = "Log In" Then
HTMLS.click()
Exit For
End If
Next
End If
IsBrowserBusy is just a function I made to return whether or not the browser is busy. With this code, the textboxes were filled in, but I can't get it to submit, before even compiling i get this error:
"Error 1 'Public Event Click(sender As Object, e As System.Windows.Forms.HtmlElementEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event."
Ugh, this is frustrating! Hopefully you have some time to lend a hand-
-
1 Attachment(s)
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Just use the 2005 webbrowser, and use the InvokeMember() method
I have attached example code.
I actually plan on rewriting the original example in this thread using the 2005 webbrowser (even though it still does have some limitations that the COM browser doesn't)
however it also does have some advantages.
So anyway take a look at the attached zip file, you will see its only a few lines of code to do a paypal auto login.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Perfect, you're the man!
Any clue where I can find a good writeup on the 2005 web browser?
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
well its a control that is actually a built in part of the .NET 2.o framework, so a good starting place would be to go through the MSDN help documentation on it. It will list all the properties, methods, events, etc...
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Sorry for the mistake.:wave:
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Sorry but you are using VB6 and IE automation, and all this example code is done with VB.NET, and ActiveX/.NET webbrowser controls.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi fellows,
i am trying to do a similar stuff and i am very much successful as of yet. I am building a desktop application in C# which will submit form by HttpWebRequest and HttpWebResponse in addition to other functionalities. i came across a problem when i was trying to submit form on a ASP.Net site as it wont yield the page after login. One reason a friend told me was that i was not incorporating ViewState value in the data being sent. Now as i am building a desktop application and i need UrlEncode function of HttpUtility class for converting viewstate value into base64 equivalent(reason being that this representation caters for escape sequences). I cant access this class in a desktop application.
Can anyone tell me that am i going on right track and if yes what else i need to do.
ur assistance will be of great help to me.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I'm using VS2005 and VB.NET, .NET framework 2.0.
I've read most of this thread... in hopes to be able to "click" on HtmlElements with a WebBrowser, without luck. The issue is I don't want to do this in a windows form app.
I've tried both the InvokeMember("click") method and the reflections/DomElement, which work fine if the browser is on a Windows Form but just hang and don't do anything in my ASP.NET application (where I instantiate the browser myself).
I can get the browser to navigate to pages however. I have to be running in a separate thread with ApartmentState STA.
The AxSHDocVw.AxWebBrowser() ends up throwing this out trying to navigate:
An unhandled exception of type 'System.Windows.Forms.AxHost.InvalidActiveXStateException' occurred in AxInterop.SHDocVw.DLL
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
wait, so what exactly are you trying to do? Invoke your own clicks in an ASP.NET application?
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Yea that's what I need to do. I wouldn't need the WebBrowser object except for javascript use in some pages I'll need to crawl. The dependence on a web browser object doesn't lend itself well to the parallel nature of crawling, but usually httpwebrequest/response is what I'll use.
We have an old VB6 winform app that is able to do this fine, but in a winform. I'd like to have a sort of independent library that I can choose to use wherever, (asp.net, cmd line, etc). Wanted to use the web browser despite not having one actually visible as it normally would be, and still be able to simulate clicks.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
why not just use a winform and put the webbrowser off screen?
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I want to be able to do this from within an ASP.NET application.
Now I'm down to just wondering if I should have the web app start off an exe webform app and communicate with it somehow... probably not worth it. :afrog:
Is there no other way besides these WebBrowser objects to deal with executing javascript that does whatever and eventually takes me to another page? Without writing a javascript interpreter or something, hah.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Nice, I can do .Navigate and have the URL string just be the javascript in the link instead (with the .NET System.Windows.Forms.WebBrowser wrapper).
Now to get this to work with buttons... some pages have onclick javascript that goes off, then expect the normal button's form submit on click to happen afterwards it seems.
Edit: well, that works with some javascript and even some I make up to .click() something in the DOM, but hangs with other js like described above.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by kleinma
What code did you try?
I am a newbie to VB.Net, I have spent many hours researching the internet for info in reference to auto logon. This thread is the best thread I have seen yet. But your attitude towards inquiries is out standing. You are constantly offering to write code on behalf of the inquirer. It show that you are a person of great character. I AM AMAZED. I am using 2005 VB Express, unfortunately I am unable to get your webpage manipulation code to work. Has 21 errors when opening. I would love to see it in action. Any recommendations apart from purchasing VS 2005. Thanks in advance...:thumb: :)
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
You should NOT need a pay version of Visual Studio to get the code to work. However perhaps if you can list (some) of the errors, I could point you in the right direction to get it fixed.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
as requested:
All I can debug is that my Vb 2005 Express does not know "mshtml"
Looking fwd to your reply
Thanks //Gibbo :)
Discription Line Column
Error 1 Type 'mshtml.HTMLDocument' is not defined. 85 22
Error 2 Type 'mshtml.IHTMLTxtRange' is not defined. 86 24
Error 3 Type 'mshtml.IHTMLTxtRange' is not defined. 87 61
Error 4 Type 'mshtml.HTMLDocument' is not defined. 99 44
Error 5 Type 'mshtml.HTMLDocument' is not defined. 101 44
Error 6 Type 'mshtml.HTMLFormElement' is not defined. 110 45
Error 7 Type 'mshtml.HTMLFormElement' is not defined. 113 67
Error 8 Type 'mshtml.HTMLInputElement' is not defined. 129 54
Error 9 Type 'mshtml.HTMLInputElement' is not defined. 133 85
Error 10 Type 'mshtml.HTMLTextAreaElement' is not defined. 138 55
Error 11 Type 'mshtml.HTMLTextAreaElement' is not defined.142 86
Error 12 Type 'mshtml.HTMLOptionButtonElement' is not defined 148 67
Error 13 Type 'mshtml.HTMLOptionButtonElement' is not defined. 150 67
Error 14 Type 'mshtml.HTMLButtonElement' is not defined. 156 61
Error 15 Type 'mshtml.HTMLButtonElement' is not defined. 162 62
Error 16 Type 'mshtml.HTMLAnchorElement' is not defined. 176 28
Error 17 Type 'mshtml.HTMLDivElement' is not defined. 186 22
Error 18 Type 'mshtml.HTMLImg' is not defined. 225 28
Error 19 Type 'mshtml.HTMLImg' is not defined. 229 73
Error 20 Type 'mshtml.HTMLSelectElement' is not defined. 242 28
Error 21 Type 'mshtml.HTMLInputElement' is not defined. 250 31
Warning 22 The referenced component 'Microsoft.mshtml' could not be found.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
looks like the only problem is you don't have the needed microsoft.mshtml.dll file which is the parsing engine.
On my PC it is located at
C:\program files\microsoft.net\primary interop assemblies\Microsoft.mshtml.dll
Search your PC and see if you have it. If you find it, add a reference to it in the "Add Reference" dialog, and the errors will go away.
Let me know if you don't have it and I could probably upload it.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
You hit the nail on the head. The file is missing, no where to be found on C:drive... you can e-mail to [email protected]
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
microsoft.mshtml.dll
Here you go. I will leave it available on that server for a little while until I know you have gotten it.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Thxs, I have download the file, file has been copied into the same location as yours. Problem persist. I have attempted to enter path in the "add reference" dialog as you have recommended. But it is not allowing me to enter the value. Any suggestions…sorry for the inconvenience
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
sorry found the problem thxs. please ignore my last message
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Glad to hear you got it working.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I need to ask the biggest favour ever. I have been researching the web for the last 14 days for a specific script. It appears that you seem to know what your are talking about, thus you may have the answer I seek. Therefore I need your advice and/or direction.
Objective
1. Open a http and/or https website
2. Wait until the page has completely finish downloading (e.g. done) before keystrokes "username" then "TAB" then "password" then "TAB" then "Click".
Please note:
1 The problem is that I move about and thus am connected to varying internet speeds. "Wait" and "sleep" commands are unstable.
2. Other sessions of browsers are already open. Thus the keystroke must be directed to the specific browser window.
3. Plus the individual characters in the "username" or "password" are echoing. Which brings me to the next problem but is related. Slow down the keystrokes, such that the next keystroke will not occur until the script receives a reply from server acknowledges the previous keystroke. Again “wait” and “sleep” are unstable.
4. Please note that use of cookies is not an option as the website that I access issue new cookies every time I log on.
In summary
I need to slow the script down between WebPages and keystrokes. The script steps thru as it receives acknowledgements from server
Thankyou
//Gibbo :)
P.S. your programme is great :thumb:
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
well are you planning on making a windows forms app in VB.NET that will host a webbrowser control? If so then this sounds easy to do. If you are actually trying to automate an external instance of internet explorer, then that will be more difficult. I know you used to be able to create external instances of IE and automate them, but I think support for that has dropped.
Anyway, so if you wanted to make a windows app that hosts the browser control (which is what my example code does) then here are a few key points to keep in mind:
When you navigate to a page, you need to wait for the DocumentCompleted event to fire. This event fires when the page has been fully loaded in the browser. Unlike the navigated event which fires as soon as a navigation has started.
You don't need to send tabs and keystrokes to the webpage when you use the methods shown in my example code. You simply access the pages DOM (document object model) and fill in the needed fields, and click the needed buttons/links.
The only one of your points I am not sure of is number 3? What do you mean by echoing? Does the page post back to the server on every keystroke entered? Is that why you need the wait?
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I have created a form with buttons to activate individual scripts. Simply I have to log onto many different secure websites at the same time in order to perform different task as part of my employment. Remembering all my usernames and passwords, plus constantly logging on and off website is frustrating. Hence the Form I am creating. Eventually as my experience and knowledge improves. I would like to auto fill the from on these websites from a database, as a lot of my work is repetitive.
The echoing. The script only has "a" as a keystroke followed by a wait of 500ms before the next keystroke. But the username field may display multiple "a". But this problem does not seem to occur when I am connect to a high speed broadband.
If you are able to provide a basic code to which I can model from and/or improve it would be much appreciated
It is now 0200hrs here in Aussie, Thus I must get some shut eye
Thanks
//Gibbo
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi guys. I've read throught this whole thread and I'm hoping you can help me. What I'm trying to do is automate a batch load process we have for our case tracking system. Basicily we have a website internal to our company that we go to and input the filename. You then click submit and it's done.
So I downloaded the OP's webmanipulate program and got it work well. But when I tried to use the code into my project, it didn't seem to work. It kept getting a repeating error of sorts. So I tried other methods mentioned on this page. The only method I got to somewhat work is:
Browser.Document.Forms(0).GetElementsByTagName("Input").Item(0).SetAttribute("Value", "test1")
The result of this is that it puts "test1" is put into a text box, but not the right one. I tried adjusting the Item number but it didn't work. I could only get it to put the text in the top text box (which is a search bar thats a standard part of our company's intranet).
So here's the html code for the page which I got permission to post with some editions:
Code:
<html>
<head>
<title>Merckury Batch Load Upload Page</title>
<script type="text/javascript">
var portallastmod='3 Mar 2005'
var portalcontact='[email protected]'
</script>
<meta name="Language" content="English language" />
<meta name="Sensitivity_class" content="Business confidential" />
<script src="/scripts/wrapperadd.js" type="text/javascript"></script>
<script src="/scripts/portaldefaults.js" type="text/javascript"></script>
<link href="/merckury/styles/batchload.css" rel="stylesheet" type="text/css">
</head>
<body>
<!-- This is the include for the header -->
<script type="text/javascript">portalInsertHeader()</script>
<!-- Begin Breadcrumb Strip -->
<div class="portalbreadcrumb">
<a href="http://my.merck.com/index.jsp?epi-content=myMerckRedirectType&epi-process=home_redirect.jsp">myMerck home</a> >
batch load cases
</div>
<!-- End Breadcrumb Strip -->
<div id="pagecontent">
<br/>
<br/>
<form name="fileUploadForm" method="post" action="/merckury/batchFileUploadRequest" ENCTYPE="multipart/form-data" >
<table width='600' border='0' cellpadding="1" cellspacing="1" align="center" bgcolor="#666666">
<tr>
<th>
Merckury Batch Load Upload Page
</th>
</tr>
<tr>
<td>
<table width="100%" cellpadding="5" cellspacing="0" border="0" bgcolor="white">
<tr>
<td>
<br/>
File Name: <input type="file" name="file1" size="80" />
<br/>
<br/>
<div align="center">
<input type="submit" name="submitButton" value="Submit"/>
</div>
</td>
</tr>
<tr>
<td>
<a href="BatchLoad.xls">Get the batch load spreadsheet</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<table width='600' border='0' cellpadding="1" cellspacing="1" align="center" bgcolor="#666666">
<tr>
<th>
Look up ID Values
</th>
</tr>
<tr>
<td>
<table width="100%" cellpadding="5" cellspacing="0" border="0" bgcolor="white">
<tr>
<td>
<a href="/merckury/batchIdLookup?lookuptype=0">Product IDs</a><br>
<a href="/merckury/batchIdLookup?lookuptype=1">Category / Specialty Type / Detail IDs</a><br>
<a href="/merckury/batchIdLookup?lookuptype=4">Provider Group IDs</a><br>
<a href="/merckury/batchIdLookup?lookuptype=5">Attribute IDs</a><br>
<br>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<script type="text/javascript">portalInsertFooter()</script>
</body>
</html>
As I said before I'm justing trying to input the filename (which is standard) and then click submit. My project has a browser in it called "browser" that navigates to the website when the form is loaded"
Also, for future refrence - is there a way to program a scan function to scan a website and display what the item numbers are? So basiclly after going to a website I would hit a "scan" button and it would look at the website and tell me the text boxes and gives me there form and item number. Would be helpful.
Any suggestions?
UPDATE: I've went back and modified the browser to use the testpage that came with OP program to see if it can populate any box after the first using the : Browser.Document.Forms(0).GetElementsByTagName("Input").Item(0).SetAttribute("Value", "test1")
method and ran into the same problem. Even though I added more lines with higher Item number, it just populated the first box (txtbox in this case). Hope someone can help.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
It is a security limitation of the IE DOM.
Imagine you went to some webpage, and the webpage had a file upload input element on it, that was prefilled with some sensitive file from your computer, and when the page loads, javascript has the page automatically submit, and some personal file from your computer is uploaded to someones server....
For that reason, the Document Object Model does not expose the value property of <input type=file> elements. That means you can not set those via code.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by kleinma
It is a security limitation of the IE DOM.
Imagine you went to some webpage, and the webpage had a file upload input element on it, that was prefilled with some sensitive file from your computer, and when the page loads, javascript has the page automatically submit, and some personal file from your computer is uploaded to someones server....
For that reason, the Document Object Model does not expose the value property of <input type=file> elements. That means you can not set those via code.
Guess I set them wrong...just figured out a way. I wrote this handy little sub:
Private Sub update_text(ByVal field As String, ByVal input_text As String)
Browser.Document.All(field).Focus()
SendKeys.Send(input_text)
End Sub
So I just send that I want to update "file1" and the text. It sets the focus on the box and then used sendkeys to type in the file name.
Thanks for the info!
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
yeah, using sendkeys could work because sendkeys mimics user input. Since javascript doesn't have access to sendkeys, there is no direct browser security risk there.
Just make sure you do extensive testing with sendkeys, as it sends keystrokes to the active window, so you shoudl always make sure the desired window has focus before calling sendkeys
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by kleinma
yeah, using sendkeys could work because sendkeys mimics user input. Since javascript doesn't have access to sendkeys, there is no direct browser security risk there.
Just make sure you do extensive testing with sendkeys, as it sends keystrokes to the active window, so you shoudl always make sure the desired window has focus before calling sendkeys
That correct. I learned this the hard way when I was trying to debug the code and the program would hang on me. So I have to put a breakpoint after the sendkey command.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi,
I am a newbie on VB, using VS2005.
How do I use InvokeMember if the button does not have a name?
html - <input id="uploadButton" type="submit" value="Upload Video">
code - wb.Document.Forms("uploadVideoFileForm").InvokeMember("submit") - nothing happens
wb.Document.Forms("uploadVideoFileForm").InvokeMember(????)
what do i do? or is there a basic way to go around with this.
Thanks in Advance!
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
instead of using the form specifically, try Invoking a click on the submit button using its ID of "uploadButton"
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by kleinma
instead of using the form specifically, try Invoking a click on the submit button using its ID of "uploadButton"
It worked!
but you know what somewhere in my tests im sure i did that, ive been working with it for 4 hours and its almost 2am, now, how do I get rid of ghosts inside this program, hmmm... lesser errors to go! weeeeeeee
anyways BIG BIG thanks again,
knds ;)
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I'm attempting to
1) click a single checkbox on the loaded page (which should redirect the page in the process)
2) click a URL on the next page
Apparrently the checkbox is beyond my scope because I can't seem to get it to work. There are 5 forms on the page, and the check box is in the 4th (index 3?). Also in that form is a hidden value which is specified before the checkbox name. Here is some code I'm working with:
Code:
Public Class frmMain
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tmpStr As String = "http://localhost/CASE_NUMBER=" & CStr(TextBox1.Text)
wb.Url = New System.Uri(tmpStr)
End Sub
Private Function GetCurrentWebDoc() As MSHTML.HTMLDocument
Try
Return DirectCast(wb.Document, mshtml.HTMLDocument)
Catch ex As Exception
Return Nothing
End Try
End Function
Private Function GetCurrentWebForm() As MSHTML.HTMLFormElement
Try
If GetCurrentWebDoc.forms.length > 0 Then
Return DirectCast(GetCurrentWebDoc.forms.item(3), MSHTML.HTMLFormElement)
Else
Return Nothing
End If
Catch ex As Exception
Return Nothing
End Try
End Function
Private Sub ClickCheckBox()
Dim MyInputElement As MSHTML.HTMLInputElement = DirectCast(GetCurrentWebForm.item("checkBoxName", 3), MSHTML.HTMLInputElement)
MyInputElement.checked = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ClickCheckBox()
End Sub
End Class
Unfortunately I can't really post the HTML I'm working with, but I could cut and past relevant portions if I knew what would help.
Thanks for any suggestions!
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Is the checkbox actually called "checkBoxName" in the HTML code?
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
no, but I changed it to protect the innocent... I'll PM you the form code itself.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
it works fine. I PMed you with the code that works.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi, me again,
Can InvokeMember be used to click a dynamic button? If not is there a way around this for my auto login to work?
html code:
<a onclick="signInSubmit( document.signInForm.login.value, document.signInForm.password.value, document.signInForm.rememberLogin.checked, 'signInForm_err', document.signInForm.source.value )" class="dynaBtn" title="Sign In"><span>Sign In</span></a>
Im Using VB on VS2005
Thanks,
knds
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
if you look at my example project you will see an example of calling javascript that is in the HTML page from VB code. You could use that example to call the signInSubmit javascript function from VB code, passing the given values that it expects. That should do it.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by kleinma
if you look at my example project you will see an example of calling javascript that is in the HTML page from VB code. You could use that example to call the signInSubmit javascript function from VB code, passing the given values that it expects. That should do it.
I followed the script on your sample application, would there be reasons why my javascript function wont execute? Nothing is happening, I am now trying to click a link with a js function to turn off a flash part on the site so that I could write on the text box
vb code:
GetCurrentWebDoc.parentWindow.execScript("switch_non_flash_uploader()", "javascript")
html code:
<p> <a> onclick="switch_non_flash_uploader()" href="#"> Click Here </a> if you are having problem with the uploader
Thanks
knds
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I am not sure why it would not execute. It would be hard for me to guess without being able to see the actual page you are trying to manipulate. Is it a public URL so I can look at it?
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by knds
I followed the script on your sample application, would there be reasons why my javascript function wont execute? Nothing is happening, I am now trying to click a link with a js function to turn off a flash part on the site so that I could write on the text box
vb code:
GetCurrentWebDoc.parentWindow.execScript("switch_non_flash_uploader()", "javascript")
html code:
<p> <a> onclick="switch_non_flash_uploader()" href="#"> Click Here </a> if you are having problem with the uploader
Thanks
knds
Im not sure why my code doesn't fire the jv function but a friend of mine did this:
wb.Navigate("javascript:switch_non_flash_uploader();")
it worked... im a newbie on this and I didn't inquired further. well i just wanted to share so others may consider this...
thanks to kleinma, for your time... on answering my questions... :wave:
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I searched on this thread re: frames, does anyone had a success filling up values on a frame?
knds
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Sir guide me
My Problem I want to open vbforums.com but login using the windows application.
I just open the your link but how to set the value of user name and the password in that website!!
I am not getting please guide me
Thanks!!
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
if you are using my sample code, then you could use the GetCurrentWebDoc to get the current webpage document, and then grab whatever form you want by name or by its index in the collection
Code:
Dim MyForm As mshtml.HTMLFormElement = DirectCast(GetCurrentWebDoc.forms.item("form name here"), mshtml.HTMLFormElement)
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
yes in the getcurrentwebform method in my example code, you will see it is specifically grabbing form at index 0. Just change that 0 to whatever number index you want to grab. You could also change the function to allow you to pass in an integer as a parameter, and use that to indicate which form you actually want to retrieve from the webpage document.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
No problem.
Check back soon, I will be releasing source for an extended WB control that uses the .NET 2.0 built in webbrowser control instead of the COM based one, but has all the features that the 2 provide.