Solved

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

Posted on 2010-11-14
2
996 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
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…

708 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

20 Experts available now in Live!

Get 1:1 Help Now