Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No, there isn't any functionality built into WatiN to support this, but GarethStephenson's post was correct. You can write an NUnit test that will give you a pass/fail.</p> <p>First of all, for IE to work with NUnit you need to add the following to your app.config</p> <pre><code>&lt;configSections&gt; &lt;sectionGroup name="NUnit"&gt; &lt;section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/&gt; &lt;/sectionGroup&gt; &lt;/configSections&gt; &lt;NUnit&gt; &lt;TestRunner&gt; &lt;!-- Valid values are STA,MTA. Others ignored. --&gt; &lt;add key="ApartmentState" value="STA" /&gt; &lt;/TestRunner&gt; &lt;/NUnit&gt; </code></pre> <p>Here's an example test. It loads up the google home page, grabs some elements and asserts they exist: -</p> <pre><code>using WatiN.Core; using NUnit.Framework; namespace ConsoleApplication1 { [TestFixture] public class AutomatedTests { [Test] public void DoGoogleTest() { using (IE browser = new IE()) { browser.GoTo("www.google.co.uk"); Div logoDiv = browser.Div("hplogo"); Assert.IsTrue(logoDiv.Exists, "Logo div does not exist"); TextField searchText = browser.TextField("lst-ib"); Assert.IsTrue(searchText.Exists, "Search text field does not exist"); Button searchBtn = browser.Button(Find.ByName("btnK")); Assert.IsTrue(searchBtn.Exists, "Search button does not exist"); Button nonExistantButton = browser.Button("garbagegarbagegarbage"); // This will cause the test to fail because the link doesn't (shouldn't!) exist. // Comment it out and the test should pass Assert.IsTrue(nonExistantButton.Exists, "Non-existant button does not exist"); } } } } </code></pre> <p>Unfortunately, NUnit doesn't automatically integrate with Visual Studios Test View/Test List windows. Your options are: -</p> <ul> <li>Install <a href="http://www.bubblecloud.org/visualnunit" rel="nofollow">Visual NUnit</a></li> <li>Install <a href="http://www.gallio.org/" rel="nofollow">Gallio</a> (which will integrate and is good for reporting)</li> <li>Run your tests externally (<a href="http://www.marthijnvandenheuvel.com/2010/06/09/using-nunit-in-visual-studio-2010/" rel="nofollow">which can be done through VS</a>)</li> </ul> <p>The above code gives me the result: -</p> <pre><code>ConsoleApplication1.AutomatedTests.DoGoogleTest: Non-existant button does not exist Expected: True But was: False </code></pre> <p>If you comment out the last line you get no errors reported.</p> <p>If you need any more info then let me know. HTH!</p> <p><em><strong>EDIT</em></strong> Added link for Visual NUnit extension for VS2010</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