Question website login automation with webbrowser?

Mrt

Member
Joined
May 18, 2010
Messages
16
Programming Experience
1-3
Hello, recently I've been going through some website login automation and ended up with creating a simple my own browser quite happily, to open websites and login straight away.

But I found out that I can't automate some of the websites I was going for, because the html code of the login forms is not shared and cannot be seen in the source.

So I'll give you guys a couple of websites I can't deal with and please advice if it is possible to do stuff with them:

Please have a look at the following:
Tempest
https://portal.xps.murphx.com/

Thank you
 
Hello, again, I am still trying to do this.

I'll post some sample code so you understand what method I am using:

VB.NET:
For i As Integer = 0 To wb.Document.All.Count - 1
                    elm = wb.Document.All.Item(i)

                    If Not elm.TagName Is Nothing Then
                        If elm.TagName.ToUpper() = "input" Then
                            If CType(elm, System.Windows.Forms.HtmlElement).Name = "username" Then 'Get User ID Element
                                CType(elm, System.Windows.Forms.HtmlElement).InnerText = "qwerty"
                            ElseIf CType(elm, System.Windows.Forms.HtmlElement).Name = "password" Then 'Get Password Element
                                CType(elm, System.Windows.Forms.HtmlElement).InnerText = "123"
                            End If
                        End If
                    End If
                Next

                With Me.wb
                    For Each ele As HtmlElement In .Document.GetElementsByTagName("input")
                        If ele.GetAttribute("name") = "username" Then
                            ele.SetAttribute("text", "hellp")
                        ElseIf ele.GetAttribute("name") = "password" Then
                            ele.SetAttribute("text", "hellp")
                        End If
                    Next
                End With

                For Each el As HtmlElement In wb.Document.GetElementsByTagName("input")
                    If el.GetAttribute("Value") = "Login" Then
                        el.InvokeMember("Click")
                    End If
                Next


the code is actually fine, looks like I am using wrong names for the username, password texboxes and the login button controls on the website.

the only thing I need is somebody more advanced could have a look at those websites I've posted and tell me is it possible to get to the controls and automate the login
 
Last edited:
The value for HTML input tag is set with 'value' attribute, there is no 'text' attribute. You can use GetElementById to get username/password elements.
VB.NET:
web.Document.GetElementById("username").SetAttribute("value", "user")
You can also get the form element and call its 'submit' method, instead of finding and 'clicking' the submit button.
VB.NET:
web.Document.Forms(0).InvokeMember("submit")
A brief look at the first Tempest link you posted shows that the login page is a separate page displayed with a iframe. Perhaps you can load the login page directly in browser and go from there.
 
Perhaps you can load the login page directly in browser and go from there.

That's a good catch but how do I define the webpage of the login form??? There are iframes on both of the website's I've posted it could really help :)
 
The source show the url for the login page, as I said. Try loading the login page.
 
oh, right, I got it for the tempest website and it works perfect.

but not the other one, I found this in the source of murphx website but can't find this webpage:

HTML:
<td class="content" height="100%" valign="top" colspan="2">
					<iframe id="xcontent" name="xcontent" frameborder=0 src="/pages/render.php?phpsessid=20711496e6768376fc70e5bbfada8ecc&p=login" name="xcontent" height="100%" width="100%"></iframe>
				</td>
 
Back
Top