Use IE object to Navigate to URL, then click link - using VB.NET

I found the code below posted by an expert.  It works to open a browser to the specified URL.  I would like to be able to click on an HREF link after the page loads.  Can this be done?  Once I visit the URL, the link I want to click looks like this <a href='javascript:audit(this);'> audit this asset. </a>

I'm fairly new to .NET... so let me know if there are any references or declarations needed
'go to Project -> REFERENCES and select Microsoft Internet Controls
'Private WithEvents IE As SHDocVw.InternetExplorer
    Try
      IE = New SHDocVw.InternetExplorer
      IE.Navigate("www.google.com")
      IE.Visible = True
 
    Catch ex As Exception
     'System.Windows.Forms.MessageBox.Show(ex.ToString)
    End Try

Open in new window

LVL 1
sarg_manAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

William ElliottSr Tech GuruCommented:
if you know what the link is, then why not just go to the link directly?
i'm not sure you could do this w/out some tricky mouse event work.

do you have the page you are referring to? or is this an internal app?
0
sarg_manAuthor Commented:
It is an internal application.  The first link sends a person to a URL that authenticates (pass-through) and redirects them to the main page (a helpdesk end-user portal).  The javascript link to audit a persons workstation in on that page, but doesn't work if you go directly to the hyperlink page.
0
William ElliottSr Tech GuruCommented:
it doesn't work, because you have to pass additinal paremeters in order to get it to work, the designer of the application should be able to add a way to do this directly. unless it is some out of the box software, then you'll have to go to the vender,.. yadda yadda,...

anywho,. let's see what we can do.

personally i'd find the .js file that contains the code for the "audit" function.
then i would extract the information from that function we could directly pull out thedata we need or setup a new page that will have just the data you want.


or you can simply
file - saveas- saveas type = webpage complete
zip this and upload it here (in doing this it shouldn't have any 'personal' data in it)
and i'll try to extract a link that will get you what you need out of it.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

William ElliottSr Tech GuruCommented:
another option is to
maximize the browser window,
get the exact position(x,y) of the link you want to click
and send a mouseclick event to that location

downside of thisis if you change the resolution of your monitor, then you will have to change the code.
0
sarg_manAuthor Commented:
Sending the mouse-click would be pretty tough since we have a number of different machines and resolution sizes.  The software is Numara Track-It 8.1 (http://www.numarasoftware.com/demo.asp).  Since we have a large remote workforce that only connects via the VPN, I'm writing a Windows Service that will "check in" every so often.  Since the audit feature ports the data over http, I was hoping to be able to silently run the asset audit every week or so when they connect to the VPN.  It just doesn't appear that they intended to have a single URL kick off the audit. :(  You can see the link and code for your self if you want to download the demo...  thanks for your interest.
0
sarg_manAuthor Commented:
Here is the function that the link I posted calls:
<script language="VBScript">
	function audit(obj)
		if vbOK = msgbox("Audit results are displayed after Technicians perform an audit merge.", vbOKCancel, "Web Audit") then
			top.workSpace.location.replace "../audit.asp?mode=wizard"
		end if
	end function
</script>

Open in new window

0
William ElliottSr Tech GuruCommented:
convenient.. the website download portion is giving internal errors.
i'll try to download later unless you can upload a copy for me to look at
0
sarg_manAuthor Commented:
I tried manually navigating to the main page, then from that page navigating to ../audit.asp?mode=wizard
Didn't work.  I tried looking through the audit.asp page to see if there was a silent mode or something that I could find, no luck...

That's why I was hoping that VB.Net had some way to execute or click a hyperlink on a page.
0
William ElliottSr Tech GuruCommented:
it is most likely buried in a series of .js files that you don't see
do this.
file - saveas- saveas type = webpage complete
then look to see if their are any .js files
0
William ElliottSr Tech GuruCommented:
<script language="VBScript">
this is an audit function, but a vbscript one, they put this there to confuse you.
0
sarg_manAuthor Commented:
Well after much searching, I could not find any way to use vb.net to visit a web page and click a link.  Instead, I have written a Windows Service using vb.net to accomplish what I was after using another method.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.