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

Web button click problem

Discussion in 'C, C++, C#' started by MisterNick, Jul 31, 2016.

  1. MisterNick

    MisterNick Registered Member

    Joined:
    Oct 22, 2014
    Messages:
    71
    Likes Received:
    51
    Occupation:
    Programmer
    Location:
    Tbilisi,Georgia
    Hello guys,

    So, i'm trying to make a login software and when i try to enter the login information and click at "Submit" the software or idk what exactly, clean the 'username' field and the website automatically says "enter the username"

    here's my code:
    HtmlDocument doc = browser.Document;
    HtmlElement elem1 = doc.GetElementById("pepName");
    elem1.Focus();
    elem1.InnerText = "pep";

    var buttons = browser.Document.GetElementsByTagName("button");

    foreach (HtmlElement button in buttons)
    {
    if (button.InnerText == "Submit")
    {
    button.InvokeMember("Click");
    }
    }

    any suggestion about how to make that problem disappear? or should i use something else?
     
  2. roadhamster

    roadhamster Regular Member

    Joined:
    Mar 12, 2012
    Messages:
    335
    Likes Received:
    242
    Could be a script in the webpage that clears the input field.
     
  3. MisterNick

    MisterNick Registered Member

    Joined:
    Oct 22, 2014
    Messages:
    71
    Likes Received:
    51
    Occupation:
    Programmer
    Location:
    Tbilisi,Georgia
    what about Selenium? if i'd use it will it make any difference?
     
  4. roadhamster

    roadhamster Regular Member

    Joined:
    Mar 12, 2012
    Messages:
    335
    Likes Received:
    242
    Don't know about Selenium, have no experience in that.
     
  5. Dev Warrior

    Dev Warrior Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 13, 2015
    Messages:
    253
    Likes Received:
    30
    Home Page:
    n
    Selenium is a good add-on for any project to automate webpages using any browser like chrome, firefox or any headless browsers like phantomjs etc.

    http://www.seleniumhq.org/projects/webdriver/
     
  6. MisterNick

    MisterNick Registered Member

    Joined:
    Oct 22, 2014
    Messages:
    71
    Likes Received:
    51
    Occupation:
    Programmer
    Location:
    Tbilisi,Georgia
    What about awesomium? i need something that can be inserted directly in my project. With Selenium i can only open the web browser right? but i need something to use directly in my project. Kinda change default IE browser with something better
     
  7. weedsmoker

    weedsmoker Junior Member

    Joined:
    May 2, 2011
    Messages:
    190
    Likes Received:
    79
    Maybe it's not enough to focus element, maybe site also checks for keypresses or hover events, like google and fb do for example. Probably you need to send native key presses to focused field, or send synthetisized keypress events if you're working with headless browsers (it can get tricky).