Solved

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

Posted on 2010-11-14
2
1,023 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

696 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