Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Check out your 4th line, you're setting <code>userName</code> again when you should be setting <code>password</code></p> <p><strong>EDIT</strong></p> <p>Besides the problem above I'm guessing that you're trying to invoke the click too soon. The button is created using JavaScript so you have to wait a bit before clicking it. Unfortunately there's no event that you can listen for to determine when the JavaScript is <code>done</code> although you could test various properties probably. The safest thing is to probably just wait a couple seconds after load before invoking <code>click</code>.</p> <p>The code below works for me (although I don't have a valid username and password). I've got one button called <code>button1</code> and one webbrowser called <code>webBrowser1</code>. Once the page is visually loaded in the browser clicking the button on the form correctly invokes the <code>click</code> event in the browser.</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.webBrowser1.Navigate("https://www.salesgenie.com/Account/LogOn"); } private void button1_Click(object sender, EventArgs e) { string SomeUserName = "Test"; string SomePassword = "Test"; HtmlElement userName = webBrowser1.Document.GetElementById("username"); Console.WriteLine(userName.GetAttribute("value")); userName.SetAttribute("value", SomeUserName); userName.RemoveFocus(); HtmlElement password = webBrowser1.Document.GetElementById("password"); Console.WriteLine(userName.GetAttribute("value")); password.SetAttribute("value", SomePassword); HtmlElement logonForm = webBrowser1.Document.GetElementById("logon-submit"); logonForm.InvokeMember("click"); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload