Click here to Skip to main content
15,891,951 members

automatic web form filling with vb.net

amit_upadhyay asked:

Open original thread
the free microsoft word plugin is driving me nuts. Iam trying to fill html forms through vb.net using web browser control and GetElementById method.

On blogger home page when i try to login, i have to fill user name, passowrd and then click on submit button. When viewing the HTML source of the page, i get the elements as :


<big></big><h2>Sign in to use Blogger<br> with your Google Account</br></h2>
<div class="input-holder"><label for="Email">Username (Email):</label>
<input type="text" size="10" name="Email" id="Email" class="text" dir="ltr" tabindex="1"></input></div>
<div class="input-holder"><label for="Passwd">Password:
(<a href="http://www.blogger.com/forgot.g" title="Forgot your password?">?</a>)</label>
<input type="password" size="10" tabindex="2" name="Passwd" id="Passwd" class="text" autocomplete="off" dir="ltr"></input></div>
<div id="PersistentCookie-holder"><input type="checkbox" name="PersistentCookie" id="PersistentCookie" tabindex="3" value="yes">

<label for="PersistentCookie">Remember me</label>
(<a href="http://help.blogger.com/bin/answer.py?answer=42054" target="_top" title="What is "remember me"?">?</a>)</input></div>
<div id="signin-btn-holder"><script type="text/javascript">
  document.write("\x3cspan id\x3d\x22signin-btn\x22 class\x3d\x22ubtn\x22 onclick\x3d\x22if (this.className.indexOf(\x26quot;ubtn-disabled\x26quot;) \x3d\x3d -1) {var e \x3d document[\x26#39;login\x26#39;].ok;(e.length) ? e[0].click() : e.click(); if (window.event) window.event.cancelBubble \x3d true; return false;}\x22\x3e\x3cspan class\x3d\x22left\x22\x3e\x3cspan\x3e\x26nbsp;\x3cimg src\x3d\x22/img/blank.gif\x22 width\x3d\x221\x22 height\x3d\x221\x22 alt\x3d\x22\x22\x3e\x26nbsp;\x3c/span\x3e\x3c/span\x3e\x3cspan class\x3d\x22i\x22\x3e\x3ca href\x3d\x22javascript:void(0)\x22 tabindex\x3d\x224\x22 onclick\x3d\x22return false;\x22\x3eSign in\x3c/a\x3e\x3c/span\x3e\x3cspan class\x3d\x22right\x22\x3e\x3cspan\x3e\x26nbsp;\x3cimg src\x3d\x22/img/blank.gif\x22 width\x3d\x221\x22 height\x3d\x221\x22 alt\x3d\x22\x22\x3e\x26nbsp;\x3c/span\x3e\x3c/span\x3e\x3c/span\x3e");
</script>
<script type="text/javascript">
  document.write("\x3cinput type\x3d\x22submit\x22 id\x3d\x22signin-btn-hidden\x22 name\x3d\x22ok\x22 value\x3d\x22Sign in\x22 tabindex\x3d\x22-1\x22 style\x3d\x22position:absolute; display:block; width:0; padding:0;                z-index:-1; border:none; top:-5000px; left:-5000px\x22\x3e");
</script>
<noscript><input type="submit" id="signin-btn-ns" class="ubtn ubtn-inline" name="ok" tabindex="4" value="Sign in"></input></noscript></div>
<div class="r"></div>



so i get the elements by their id and now my code is :

<big>WebBrowser1.Document.GetElementById("Email").SetAttribute("value", "amit.tcet")
            WebBrowser1.Document.GetElementById("Passwd").SetAttribute("value", "151100151105")
            WebBrowser1.Document.GetElementById("signin-btn-ns").InvokeMember("click")</big>


but the button is not clicked and hence i cannot login.

any ideas what is wrong?
Tags: Visual Basic, HTML, .NET (.NET 3.5), Visual Studio (Visual Studio 2008), WebForms

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900