1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

C# Fill Web Controls - Need Some Help

Discussion in 'C, C++, C#' started by seoweb, Apr 6, 2012.

  1. seoweb

    seoweb Registered Member

    Joined:
    Jan 20, 2009
    Messages:
    56
    Likes Received:
    2
    Location:
    Romania (at the end of world...)
    hello,
    i have small browser (c# ) with a webbrowser control.

    and a button fill login:

    that button fills the webform with my login details:

    for example is working good for my mail on yahoo, i don't need to write the username/pass... just click fill and then click on login ( haven't yet succeeded to click from c# )

    but on other websites i have some problems because they use an popup ( iframe/ frame with the input fields....).

    for example http://www.yellowpages.com/ i can't fill the login form.

    i tried:

    HtmlElementCollection tagsCollection = getCurrentBrowser().Document.Window.Frames[0].Document.GetElementsByTagName("input");
    foreach (HtmlElement currentTag in tagsCollection)
    {
    currentTag.SetAttribute("value", "eureka");
    }

    but i can't pass the "0x80070005 (E_ACCESSDENIED))"

    i really, really need some help.


    Thank you!
     
  2. roster67

    roster67 Registered Member

    Joined:
    Mar 27, 2012
    Messages:
    69
    Likes Received:
    10
    You are trying to access a http iframe redirected to a https form from a http page.
    Basically, its not possible for security reason.

    But... {see my next post}
     
    • Thanks Thanks x 1
  3. roster67

    roster67 Registered Member

    Joined:
    Mar 27, 2012
    Messages:
    69
    Likes Received:
    10
    Not sure what you want to do exactly but, you can try to open a new browser window directly to the login form {https[...]/login}
    Go back to site home, your user will be logged.

    Or, you can try to convert IHTMLWindow2 to IServiceProvider, then use IServiceProvider to get IWebBrowser2 object. Then, you'll access to the DOM from IWebBrowser2.
    You can find many samples on the net.
     
    • Thanks Thanks x 1
    Last edited: Apr 6, 2012
  4. goodvery

    goodvery Junior Member

    Joined:
    Jun 29, 2010
    Messages:
    101
    Likes Received:
    23
    get the link of that redirect and open it in webbrowser control instead. after you finish login you can open your main link.
     
    • Thanks Thanks x 1
  5. goodvery

    goodvery Junior Member

    Joined:
    Jun 29, 2010
    Messages:
    101
    Likes Received:
    23
    I've checked yellowpages and could not find login form at all.
     
    • Thanks Thanks x 1
  6. roster67

    roster67 Registered Member

    Joined:
    Mar 27, 2012
    Messages:
    69
    Likes Received:
    10
    It is:
    https[://]login.[DOMAIN]/login
     
    • Thanks Thanks x 1
    Last edited: Apr 6, 2012
  7. seoweb

    seoweb Registered Member

    Joined:
    Jan 20, 2009
    Messages:
    56
    Likes Received:
    2
    Location:
    Romania (at the end of world...)


    thank you for answer, i will need to find IHTMLWindow2 solution because there are , manny websites that use popup iframes, and not only for the login....

    basically i want my alternative for roboform in this way...


    thank you all for answers
     
  8. SwagBotPlus

    SwagBotPlus Newbie

    Joined:
    Mar 8, 2012
    Messages:
    16
    Likes Received:
    5
    Actually, this can be done.

    For the YP.com website login:

    You will need to first get the HtmlElement of id "yp-main-login-link" for the sign in link. After you got that element found, you then need to click it using element.InvokeMemeber("Click").

    Now you will have the pop up window appear, you now need to get the HtmlElement of id "user_password" & "user_user_name" then set the innerHtml to your username and password strings.

    Now all we need to do is click the Submit button, you need to collect all HtmlElements with type "input", after you have objects you need to parse threw them. You then do a string check, like... if(elmcollection.GetAttribute("value").Contains("Sign In")), if that is detected, then proceed to click the button... elmcollection.InvokeMember("Click")

    Hope this helps and isn't too crazy sounding. :D goodluck. My syntax may be a little different since I use c++.
     
    Last edited: May 6, 2012
  9. Sparkphase

    Sparkphase Junior Member

    Joined:
    Mar 7, 2011
    Messages:
    118
    Likes Received:
    32
    Location:
    United Kingdom
    Home Page:
    I think that opening up the login form in a web control will be the best most reliable way of doing it.