?
Solved

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

Posted on 2010-11-14
2
Medium Priority
?
1,058 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

839 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