title: Selenium WebDriver, How to run/connect next class
body: <p>I'm new to Selenium Webdriver, I have a few question :</p>
  
  <p>First, I have 2 class, 'Login.java' and 'SelectCity.java</p>
  
  <p>Class 1 : Login.java</p>
  
  <ul>
  <li><p>invalidLogin</p></li>
  <li><p>validLogin</p></li>
  </ul>
  
  <p>Class 2 : SelectCity.java</p>
  
  <p>For now, in Login.java I wrote  </p>
  
  <pre><code>@After
  
  public void tearDown() throws Exception {
      driver.close();
  }
  </code></pre>
  
  <p>which mean the browser will closed after finish run right?</p>
  
  <p>Here is my question :</p>
  
  <ol>
  <li><p>How to make after I run validLogin, it will continue to run the next class (SelectCity.java)?
  Is it possible to do that?</p></li>
  <li><p>How to make last browser (which test valid login) didn't get close?</p></li>
  </ol>
  
  <p>My current Login.java class :</p>
  
  <pre><code>      public class Login  extends SelectCityAfterLogin{
  
    private WebDriver driver;
    private String baseUrl;
    private StringBuffer verificationErrors = new StringBuffer();
  
    @Before
    public void setUp() throws Exception {
      driver = new FirefoxDriver();
      baseUrl = "http://mysite/";
      driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }
  
  
    @Test 
    public void testLoginInvalidPass() throws Exception {
      driver.get(baseUrl + "/mysite/login.aspx");
      driver.findElement(By.id("txtUsername")).sendKeys("user1");
      driver.findElement(By.id("txtPassword")).sendKeys("somePassword");
      driver.findElement(By.id("lbLogin")).click();
  
      try {
        assertEquals("Invalid User or Password", driver.findElement(By.id("lblError")).getText());
      } catch (Error e) {
        verificationErrors.append(e.toString());
      }
    }
  
    @Test 
    public void testLoginInvalidUsername() throws Exception {
      driver.get(baseUrl + "/mysite/login.aspx");
      driver.findElement(By.id("txtUsername")).sendKeys("username");
      driver.findElement(By.id("txtPassword")).sendKeys("somepassword");
      driver.findElement(By.id("lbLogin")).click();
  
      try {
        assertEquals("Invalid User or Password", driver.findElement(By.id("lblError")).getText());
      } catch (Error e) {
        verificationErrors.append(e.toString());
      }
    }
  
    @Test 
    public void testLoginNoUsername() throws Exception {
      driver.get(baseUrl + "/mysite/login.aspx");
      driver.findElement(By.id("txtUsername")).sendKeys("");
      driver.findElement(By.id("txtPassword")).sendKeys("somePassword");
      driver.findElement(By.id("lbLogin")).click();
  
      try {
        assertEquals("Please fill username and password.", driver.findElement(By.id("lblError")).getText());
      } catch (Error e) {
        verificationErrors.append(e.toString());
      }
    }
  
    @Test 
    public void testLoginNoPassword() throws Exception {
      driver.get(baseUrl + "/mysite/login.aspx");
      driver.findElement(By.id("txtUsername")).sendKeys("username");
      driver.findElement(By.id("txtPassword")).sendKeys("");
      driver.findElement(By.id("lbLogin")).click();
  
      try {
        assertEquals("Please fill username and password.", driver.findElement(By.id("lblError")).getText());
      } catch (Error e) {
        verificationErrors.append(e.toString());
      }
    }
  
    @Test 
      public void testLoginValid() throws Exception{
      //SelectRoleAfterLogin selectRole = SelectRoleAfterLogin();  
  
      driver.get(baseUrl + "/mysite/login.aspx");
      driver.findElement(By.id("txtUsername")).sendKeys("myUsername");
      driver.findElement(By.id("txtPassword")).sendKeys("password");
      driver.findElement(By.id("lbLogin")).click();
      Thread.sleep(3000);     
    }  
  </code></pre>
  
  <p>}</p>
  
  <p>Thx</p>