1 Replies - 1050 Views - Last Post: 27 May 2014 - 12:30 PM Rate Topic: -----

#1 thejenson   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-May 14

Webbrowser not refreshing

Posted 27 May 2014 - 12:00 PM

I've been working on what seems like a silly problem for hours with no luck, despite my best google-ing skills. Any help would be wonderful.

I've been trying to navigate this site with the eventual intent of scraping the XML, but for some reason when I try clicking the button to "Get Results" the webbrowser and/or the form its on do not reload/refresh so that I can start searching through the next page with the for loop at the bottom of my code. Instead of loading the page after I click the "Get Results" button it stays in the same place and the debug.print statements return information about the front page. And once the sub ends it all the sudden loads the second page (the "Get Results" page). It seems like the page just will not load/refresh until the code stops running and I have not been able to find a solution to get that page to load so that my for loop works through it instead of the front page. Please help me.. my brain is turning into mush.

Just a note: this is built in a Windows Form Application that just has the webbrowser and button1.

  Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

    Dim strURL As String

    strURL = "https://webgate.ec.europa.eu/rasff-window/portal/index.cfm"


    Do While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete

    WebBrowser1.document.GetElementById("WeekSwitcher").InvokeMember("Click")   'Select current week
    WebBrowser1.document.All("Btn_Search").InvokeMember("Click")                'Retrieve results

    Do While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete

    For Each Element As HtmlElement In WebBrowser1.document.GetElementsByTagName("td")
      If Element.InnerHtml.Contains("XmlConfirmation") Then
        Exit For
      End If

  End Sub

Is This A Good Question/Topic? 0
  • +

Replies To: Webbrowser not refreshing

#2 Sheepings   User is offline

  • D.I.C Addict

Reputation: 73
  • View blog
  • Posts: 571
  • Joined: 05-December 13

Re: Webbrowser not refreshing

Posted 27 May 2014 - 12:30 PM

For each is not specific; and is trying to invoke an element on a table cell but you are not specifying which cell element type you want to click. And by invoking click on Bnt_search it is going to change the URL, and you are not checking the browsers url so if the page does not load in time, it will be trying to get elements from the wrong pages anyway, so use an if statement to check the current url, and and put that if statement with your for each statement inside the document completed event on the web browser.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1