Solved

How to get HTMLInputElement if there is no Id and no name

Posted on 2010-11-14
2
1,002 Views
Last Modified: 2012-05-10
Hello Experts,
I am using VB 2010
my application downloads a web page
somewhere inside this webpage there is this line

<input type="submit" value="login" class="text rounded" style="position:relative; top:20px; left:116px; font-size:11px;  height:25px; width:95px; font-weight:bold; color:#006187;" />
 
I am trying to CLICK() on this button using:
 DirectCast(GetCurrentWebForm.item("cmdSubmitMe", 0), mshtml.HTMLButtonElement).click()

But as you can see there is no ID of Name in the source line
Please your advice,
0
Comment
Question by:rguillermo
2 Comments
 
LVL 29

Accepted Solution

by:
nffvrxqgrcfqvvc earned 500 total points
ID: 34132898
One way would be to search by the type and value members. You will first want to get a collection of Input tags using GetElementsByTagName then you can filter using GetAttribute for "type" and "value".

Here is some example using the WebBrowser Class
Dim inputElements As HtmlElementCollection = webBrowser1.Document.GetElementsByTagName("input")

        MsgBox(inputElements.Count)

        For Each element As HtmlElement In inputElements

 

            If element.GetAttribute("TYPE").ToLower.Equals("submit") AndAlso _

                element.GetAttribute("VALUE").ToLower.Equals("login") Then

                '// TODO: Work with this HtmlElement

                'element.InvokeMember("click")

                'element.InvokeMember("submit")

            End If

            

        Next

Open in new window

0
 

Author Closing Comment

by:rguillermo
ID: 34133024
Perfect!!
thank you very much!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now