title: How do I check with the assert command?
body: <p>I am currently automating a web page with the <a href="http://en.wikipedia.org/wiki/Selenium_%28software%29" rel="nofollow noreferrer">Selenium</a> webdriver. I am getting stuck now. I want to use the assert command for my script. Here is the screenshot of Add client module.</p>
  
  <p><a href="https://i.stack.imgur.com/Li29W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Li29W.png" alt="Enter image description here"></a></p>
  
  <p>After entering client details it goes to another page. Here, I add a client name, "jason". Then click on submit and on the next page we can see the list of clients.</p>
  
  <p><a href="https://i.stack.imgur.com/ofxyM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ofxyM.png" alt="Enter image description here"></a></p>
  
  <p>Here is the page source:</p>
  
  <pre><code> &lt;ul id="rightMenu" class="right"&gt;
              &lt;li class="topmenu rtopmenu-display-event"&gt;
          &lt;a href="javascript:void(0)"&gt;&lt;span class=" ico fa fa-user"&gt;&lt;/span&gt;Hello Administrator&lt;/a&gt;
          &lt;ul&gt;
            &lt;li&gt;&lt;a href="http://doc.local/profile"&gt;&lt;span class="ico fa fa-user"&gt;&lt;/span&gt;&lt;span&gt;Profile&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="http://doc.local/password/change"&gt;&lt;span class="ico fa fa-key" style ="margin-right:7px;"&gt;&lt;/span&gt;Change Password&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="http://doc.local/logout"&gt;&lt;span class="ico fa fa-sign-out"&gt;&lt;/span&gt;Logout&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
        &lt;/ul&gt;
  &lt;/nav&gt;
  &lt;div id="content"&gt;
    &lt;div id="innerContent"&gt;
          &lt;div class="bread-container"&gt;
        &lt;ul class="bread-crumb"&gt;
                        &lt;li&gt;
           &lt;a href="javascript:void(0)"&gt;
             Admin
           &lt;/a&gt;
         &lt;/li&gt;
                        &lt;li&gt;
           &lt;a href="http://doc.local/admin/clients"&gt;
             Clients
           &lt;/a&gt;
         &lt;/li&gt;
  
         &lt;li&gt;
           &lt;a href="javascript:void(0)" class="page-title"&gt;List Clients         &lt;/a&gt;
         &lt;/li&gt;
              &lt;/ul&gt;
     &lt;/div&gt;
     &lt;div style="width:98%;" class="clearfix" id="search-container"&gt;
    &lt;form class="form-inline"&gt;
      &lt;div class="form-group"&gt;
        &lt;input name="name" value="" size="13" placeholder="Company Name" class="form-control" /&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;input name="group_name" value="" size="12" placeholder="Group Name" class="form-control" /&gt;
      &lt;/div&gt;
      &lt;input type="submit" value="Search" class="btn btn-info" /&gt;
    &lt;/form&gt;
    &lt;a href="http://doc.local/admin/clients/add" class=""&gt;&lt;i title="Add Client" class="fa fa-plus-square add-plus"&gt;&lt;/i&gt;&lt;/a&gt;
  &lt;/div&gt;
  &lt;div style="width:98%;" id="list-container"&gt;
    &lt;ul class="li-table"&gt;
      &lt;li class="clearfix title header"&gt;
        &lt;span style="width:3%;"&gt;&amp;nbsp;&lt;/span&gt;
        &lt;span style="width:6%;"&gt;Si.No&lt;/span&gt;
        &lt;span style="width:20%;" class=""&gt;
          &lt;a href="http://doc.local/admin/clients?&amp;sort=ASC&amp;order_by=name"&gt;Name&lt;/a&gt;
        &lt;/span&gt;
        &lt;span style="width:20%;" class=""&gt;
          &lt;a href="http://doc.local/admin/clients?&amp;sort=ASC&amp;order_by=group_name"&gt;Group Name&lt;/a&gt;
        &lt;/span&gt;
        &lt;span style="width:28%;" class=""&gt;
          &lt;a href="http://doc.local/admin/clients?&amp;sort=ASC&amp;order_by=registered_on"&gt;Registered On&lt;/a&gt;
        &lt;/span&gt;
        &lt;span style="width:16%;" class=""&gt;
          &lt;a href="http://doc.local/admin/clients?&amp;sort=ASC&amp;order_by=status"&gt;Status&lt;/a&gt;
        &lt;/span&gt;
      &lt;/li&gt;
              &lt;li  class="clearfix li-row  "&gt;
        &lt;span style="width:3%;"&gt;
          &lt;a href="javascript:void(0)"&gt;
            &lt;i class="fa fa-arrow-circle-o-down show-actions"&gt;&lt;/i&gt;
          &lt;/a&gt;
          &lt;ul class="list-actions"&gt;
            &lt;li&gt;&lt;a href="http://doc.local/admin/clients/edit/1?"&gt;&lt;i class="fa fa-pencil c-black"&gt;&lt;/i&gt;Edit&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a class="delete-item" href="javascript:void(0)" rel="http://doc.local/admin/clients/delete/1?"&gt;&lt;i class="fa fa-trash"&gt;&lt;/i&gt;Delete&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
        &lt;/span&gt;
        &lt;span style="width:6%;"&gt;1.&lt;/span&gt;
        &lt;span style="width:20%;"&gt;Demo&amp;nbsp;&lt;/span&gt;
        &lt;span style="width:20%;"&gt;TBI&amp;nbsp;&lt;/span&gt;
        &lt;span style="width:28%;"&gt;2nd Oct'15&amp;nbsp;&lt;/span&gt;
        &lt;span style="width:16%;"&gt;Active&amp;nbsp;&lt;/span&gt;
      &lt;/li&gt;
          &lt;li  class="clearfix li-row even "&gt;
        &lt;span style="width:3%;"&gt;
          &lt;a href="javascript:void(0)"&gt;
            &lt;i class="fa fa-arrow-circle-o-down show-actions"&gt;&lt;/i&gt;
          &lt;/a&gt;
          &lt;ul class="list-actions"&gt;
            &lt;li&gt;&lt;a href="http://doc.local/admin/clients/edit/4?"&gt;&lt;i class="fa fa-pencil c-black"&gt;&lt;/i&gt;Edit&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a class="delete-item" href="javascript:void(0)" rel="http://doc.local/admin/clients/delete/4?"&gt;&lt;i class="fa fa-trash"&gt;&lt;/i&gt;Delete&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
        &lt;/span&gt;
        &lt;span style="width:6%;"&gt;2.&lt;/span&gt;
        &lt;span style="width:20%;"&gt;Jason&amp;nbsp;&lt;/span&gt;
        &lt;span style="width:20%;"&gt;Tbi&amp;nbsp;&lt;/span&gt;
        &lt;span style="width:28%;"&gt;28th Oct'16&amp;nbsp;&lt;/span&gt;
        &lt;span style="width:16%;"&gt;Active&amp;nbsp;&lt;/span&gt;
      &lt;/li&gt;
              &lt;li class="clearfix title footer"&gt;
        &lt;span style="width:3%;"&gt;&amp;nbsp;&lt;/span&gt;
        &lt;span style="width:6%;"&gt;Si.No&lt;/span&gt;
        &lt;span style="width:20%;" class=""&gt;
          &lt;a href="http://doc.local/admin/clients?&amp;sort=ASC&amp;order_by=name"&gt;Name&lt;/a&gt;
        &lt;/span&gt;
        &lt;span style="width:20%;" class=""&gt;
          &lt;a href="http://doc.local/admin/clients?&amp;sort=ASC&amp;order_by=group_name"&gt;Group Name&lt;/a&gt;
        &lt;/span&gt;
        &lt;span style="width:28%;" class=""&gt;
          &lt;a href="http://doc.local/admin/clients?&amp;sort=ASC&amp;order_by=registered_on"&gt;Registered On&lt;/a&gt;
        &lt;/span&gt;
        &lt;span style="width:16%;" class=""&gt;
          &lt;a href="http://doc.local/admin/clients?&amp;sort=ASC&amp;order_by=status"&gt;Status&lt;/a&gt;
        &lt;/span&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  </code></pre>
  
  <p>Here is the test script..</p>
  
  <pre><code>package Pages;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.support.FindBy;
  import org.openqa.selenium.support.PageFactory;
  import org.openqa.selenium.support.ui.Select;
  
  public class ClientPage
  {
      private WebDriver driver;
      @FindBy(linkText="Admin")
      WebElement admin;
      @FindBy(linkText="Clients")
      WebElement clients;
      @FindBy(xpath="//*[@id='search-container']/a/i")
      WebElement search;
      @FindBy(id="name")
      WebElement name;
      @FindBy(id="groupname")
      WebElement groupname;
      @FindBy(id="address")
      WebElement address;
      @FindBy(id="status")
      WebElement status_dropdown;
      @FindBy(className="btn-primary")
      WebElement button;
  
      // Constructor
      public ClientPage(WebDriver driver)
      {
          PageFactory.initElements(driver, this);
      }
      public void set_Admin()
      {
          admin.click();
      }
      public void set_Client()
      {
          clients.click();
      }
      public void set_Search()
      {
          search.click();
      }
      public void set_Name(String nam)
      {
          name.clear();
          name.sendKeys(nam);
      }
      public void set_Groupname(String grp)
      {
          groupname.clear();
          groupname.sendKeys(grp);
      }
      public void set_Address(String add)
      {
          address.clear();
          address.sendKeys(add);
      }
      public void select_List(String status)
      {
          Select statusdropdown=new Select(status_dropdown);
          statusdropdown.selectByVisibleText(status);
      }
      public void set_Button()
      {
          button.submit();
      }
  }
  
  
  package Test;
  import org.testng.annotations.Test;
  
  import Pages.ClientPage;
  import Pages.LoginPage;
  import Pages.RolesPage;
  
  import org.testng.Assert;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.firefox.FirefoxDriver;
  import org.testng.annotations.BeforeTest;
  
  public class ClientTest
  {
      WebDriver driver;
      @BeforeTest
      public void setup()
      {
          System.setProperty("webdriver.firefox.marionette","pathToGeckodriver");
          driver=new FirefoxDriver();
          driver.manage().window().maximize();
          driver.get("http://doc.loc");
      }
      @Test(priority=1)
      public void verify1()
      {
          LoginPage login=new LoginPage(driver);
          login.set_username("docm");
          login.set_password("1");
          login.click_button();
          Assert.assertTrue(driver.getPageSource().contains("Hello Administrator"));
      }
      @Test(priority=2)
      public void verif2()
      {
          ClientPage client=new ClientPage(driver);
          client.set_Admin();
          client.set_Client();
          client.set_Search();
          client.set_Name("Jason");
          client.set_Groupname("Tbi");
          client.set_Address("Ernakulam");
          client.select_List("active");
          client.set_Button();
      Assert.
      }
  }
  </code></pre>