?
Solved

Automated WebBrowser C#

Posted on 2004-04-22
5
Medium Priority
?
5,686 Views
Last Modified: 2013-11-13
So my situation is I have a c# windows app with a WebBrowser in it.   The web browser is automated to direct to google adwords login page, put in the specified user/pass and click the login button.   After it has loaded the campaign page it scraps the page for the stuff I want and databases it, then it clicks the log out link and directs back to the login page.  This all works fine.  The code is set to wait for the page to load etc...  I have the program sleep for a couple minutes and then recurse on the code so that it runs again (Iam trying to keep a log of the click changes throughout the day).  The problem is that after the first time it logs in, each sequential time it logs in it is the same page with no updated statistics.  I have to shut the progam down and resart for it to get an update.  Is there possibly a way that I could clear my cache or delete my cookies or restart the session so that this doesn't happen?  Thanks
-Ty
0
Comment
Question by:TCash11
[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
  • 3
5 Comments
 

Author Comment

by:TCash11
ID: 10893962
I have tried to simply call the refresh fxn for the axWebBrowser every 2 minutes but it does not refresh properly; though If I manually do it (right click on the axWebBrowser and select refresh) it does it just fine.  What am I missing?
0
 
LVL 1

Assisted Solution

by:someman4oneman
someman4oneman earned 500 total points
ID: 10895102
Would you not consider using the webrequest and webresponse object to suck the page down
as this will give you more control.
If the user has to see the page you could set the
content of the browser to be what ever you recieved from the server.
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebresponseclasstopic.asp
0
 

Author Comment

by:TCash11
ID: 10896207
I am familiar with web requests and would do so, as I know they would probably offer me my solution, but I have the browser automated to login through the textboxs on the adwords login page so I need the browser.  Can I log in with the browser then do a web request?  Is their some way to tie the two together?  The user does not need to see the page, I just need to get an updated version of the page right after login every few minutes.  Thanks for your help it is much appreciated.
0
 

Author Comment

by:TCash11
ID: 10903994
I figured it out.  I added a class to my code to delete the internet cache.  I found the code for this class at http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q326/2/01.asp&NoWebContent=1
I did have to make a few changes to the code from that page though because it got stuck in the while loops if there was nothing in the cache.  In the first while loop (in Main()) add this to the very top:
if (ERROR_NO_MORE_ITEMS == Marshal.GetLastWin32Error()
      || ERROR_FILE_NOT_FOUND == Marshal.GetLastWin32Error())
{break;}

and in the second while loop (in Main) add this right below the first line (internetCacheEntry = ....) :
if (ERROR_NO_MORE_ITEMS == Marshal.GetLastWin32Error())
{break;}

After each time i loged in to adwords, got my stats, and logged back out, I ran the main fxn in the DeleteCache class (I had to name it something else rather than main since it was in the same namespace as the main of my program) and did a Thread.Sleep for a couple of minutes and started over.  Everything seems to work great now.  Thanks for your suggestions someman4oneman.  
-TCash
0
 
LVL 1

Accepted Solution

by:
games0802 earned 500 total points
ID: 10906392
You can actually set your internet explorer to get a new page every time.  Go to Tools -> Internet Options -> Settings.  Look for "Check for newer version of stored pages:" and select "Every Visit".
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes

719 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