Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use the <code>System.Windows.Forms.WebBrowser</code> control (<a href="https://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser%28v=vs.110%29.aspx" rel="noreferrer">MSDN Documentation</a>). For testing, it allows your to do the things that could be done in a browser. It easily executes JavaScript without any additional effort. If something went wrong, you will be able to visually see the state that the site is in.</p> <p>example:</p> <pre><code>private void buttonStart_Click(object sender, EventArgs e) { webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted); webBrowser1.Navigate("http://www.wikipedia.org/"); } void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { HtmlElement search = webBrowser1.Document.GetElementById("searchInput"); if(search != null) { search.SetAttribute("value", "Superman"); foreach(HtmlElement ele in search.Parent.Children) { if (ele.TagName.ToLower() == "input" &amp;&amp; ele.Name.ToLower() == "go") { ele.InvokeMember("click"); break; } } } } </code></pre> <hr> <p>To answer your question: how to check a checkbox</p> <p>for the HTML:</p> <pre><code>&lt;input type="checkbox" id="testCheck"&gt;&lt;/input&gt; </code></pre> <p>the code:</p> <pre><code>search = webBrowser1.Document.GetElementById("testCheck"); if (search != null) search.SetAttribute("checked", "true"); </code></pre> <p>actually, the specific "how to" depends greatly on what is the actual HTML.</p> <hr> <p>For handling your multi-threaded problem:</p> <pre><code>private delegate void StartTestHandler(string url); private void StartTest(string url) { if (InvokeRequired) Invoke(new StartTestHandler(StartTest), url); else { webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted); webBrowser1.Navigate(url); } } </code></pre> <p><code>InvokeRequired</code>, checks whether the current thread is the UI thread (actually, the thread that the form was created in). If it is not, then it will try to run StartTest in the required thread.</p>
    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.
    3. 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