Results 1 to 6 of 6

Thread: How to access the elements in a aspx page hold by the webbrowser control

  1. #1
    New Member
    Join Date
    Aug 12
    Posts
    3

    Red face How to access the elements in a aspx page hold by the webbrowser control

    Hi, Everyone:

    I am new to vb and this forums. What I am trying to do is to write an automation program for our sales. The program needs to auto login to our customer's web site, then go a aspx page to get a sales table from customer's database. I am using a webbrowser control navigate to the customer site, and was able to automatically login and jump to the aspx page directly. I can see the web page in the webbrowser control window and the code in the code window. But when I trying to access its elements. that is trying to assign value of the element in order to extract certain data from the database, somehow I failed. The error message said there is no object exist, so the value is NULL. I am not quite understand this?
    Can anyone point me a direction? Or give me some example of how to access the elements in a aspx page.

    Thanks a lot.

  2. #2
    Super Moderator koolsid's Avatar
    Join Date
    Feb 05
    Location
    Mumbai, India
    Posts
    11,405

    Re: How to access the elements in a aspx page hold by the webbrowser control

    Welcome to the forums jchi1207

    Are you doing this in asp.net or some other language?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - Till Date IMP Links : Acceptable Use Policy, FAQ

    MyGear:
    Sony VGN-FZ27G with a triple boot between (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008) and (Win7+Office 2010+VS2010) || Sony VPCCB-45FN with a Win7+Office 2010+VS2010. VM: (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008), (Win8+Office 2010+VS2012) || Mac Book Pro (10.6.8) with Office 2011

  3. #3
    PowerPoster
    Join Date
    Feb 06
    Posts
    8,564

    Re: How to access the elements in a aspx page hold by the webbrowser control

    Looks like plain old Web scraping to me. Probably belongs in one of the programming language forums but I guess we can't tell which.

    The whole description smells a lttle funny though. To sell to customers you scrape data from their sites? Hopefully this isn't just spelunking these customers' contact info for spamming purposes.

  4. #4
    New Member
    Join Date
    Aug 12
    Posts
    3

    Re: How to access the elements in a aspx page hold by the webbrowser control

    Quote Originally Posted by koolsid View Post
    Welcome to the forums jchi1207

    Are you doing this in asp.net or some other language?
    Hi, Koolsid:

    Thanks for the reply. I am doing this in VB 2010 express. I was able to auto login to this web site, and directly jump to the inquiry form (for the sales data). But somehow I could not access the elements in the page. If I use manual process, I will first login to the website, then select the menu item twice to enter the inquiry form. After log in to the web site, the page actually is composed by 3 frames. (the inquiry form is one of the page frame). What I am doing is directly jump to the page display only the inquiry form.


    Hope you guys can help me. I am quite new to the web programming.

  5. #5
    New Member
    Join Date
    Aug 12
    Posts
    3

    Re: How to access the elements in a aspx page hold by the webbrowser control

    I tried some new method last week, and now I could not even jump to the frame page anymore. Maybe I should sates what I had done to clear this issue.

    I first use webBrowser navigagte to the customer's website,
    Then do the auto login
    Me.wbTest.Document.GetElementById("txtUSER_ID").InnerText = "myid"
    Me.wbTest.Document.GetElementById("txtUSER_PASSWORD").InnerText = "mypassword"
    Me.wbTest.Document.GetElementById("tb_CheckDA").InnerText = validation code
    Me.wbTest.Document.GetElementById("btnOK").InvokeMember("click")
    Me.wbTest.Document.Window.DomWindow.execscript(_doPostBack())
    Although VB issue me an error saying this javascript was protected, but still I was able to jump to the data request form.
    This form was composed by 3 frames, top.aspx, home.aspx, and menu.aspx
    when I click the option from the menu.aspx frame, it will post the data request form in home.aspx frame's area.
    I garbed the URL from the menu.aspx page, and was able to navigate to the request form in a web browser.
    But when I did the same in my program to ask the webbrowser to navigate to that URL, it back into the login page.
    ( https://b2b.tk3c.com.tw/tk3cb2b/B2BC...ProdNM=Nothing)
    Can anyone tell me why? And how can I navigate to the data request frame page and access its input elements to automate the process?

  6. #6
    Super Moderator koolsid's Avatar
    Join Date
    Feb 05
    Location
    Mumbai, India
    Posts
    11,405

    Re: How to access the elements in a aspx page hold by the webbrowser control

    Quote Originally Posted by jchi1207 View Post
    Hi, Koolsid:

    Thanks for the reply. I am doing this in VB 2010 express.
    Moved to Visual Basic .NET from General Developer Forum
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - Till Date IMP Links : Acceptable Use Policy, FAQ

    MyGear:
    Sony VGN-FZ27G with a triple boot between (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008) and (Win7+Office 2010+VS2010) || Sony VPCCB-45FN with a Win7+Office 2010+VS2010. VM: (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008), (Win8+Office 2010+VS2012) || Mac Book Pro (10.6.8) with Office 2011

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •