Solved

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

Posted on 2010-11-14
2
1,008 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

770 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