Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As @AD.Net already said, your test is working as expected.</p> <p>You could catch the exception in case the link was not found but I don't see the point to do that. If the link is not found then the <code>registerLink</code> will be <code>null</code>. What's the point of asserting on a null object's property?</p> <p>Your test works fine, just delete the <code>Assert</code> line.</p> <p>However, if you also want to test the link's text try the following code:</p> <pre><code>[TestMethod()] public void RegisterLinkExistTest() { try { IWebElement registerLink = genericBrowserDriver.FindElement(By.PartialLinkText ("Register1")); Assert.AreEqual("Register here", registerLink.Text, "Register's link text mismatch"); } catch(NoSuchElementException) { Assert.Fail("The register link was not found"); } } </code></pre> <p><strong>EDIT</strong></p> <p>You can seperate your test, the first test will check if the link exists and the second will assert it's properties.</p> <pre><code>[TestMethod()] public void RegisterLinkExistTest() { IWebElement registerLink = genericBrowserDriver.FindElement(By.PartialLinkText ("Register1")); } [TestMethod()] public void RegisterLinkTextTest() { IWebElement registerLink = genericBrowserDriver.FindElement(By.PartialLinkText ("Register1")); Assert.AreEqual("Register here", registerLink.Text, "Register's link text mismatch"); } </code></pre> <p>Then use an <a href="http://msdn.microsoft.com/en-us/library/ms182631%28v=vs.100%29.aspx" rel="nofollow">OrderedTest</a> and add them in that order so the <code>RegisterLinkExistTest</code> will be executed first. If it fails then the second test will not run.</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.
 

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