title: Selenium Webdriver using TestNG
body: <p>Selenium Webdriver :   In this code My Test case is passing for one Test Email Account but for the second test mail it is skipping the code , it does not pass the second test email </p>
  
  <pre><code>package Packet;
  
  import java.util.concurrent.TimeUnit;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.chrome.ChromeDriver;
  import org.testng.annotations.AfterMethod;
  import org.testng.annotations.AfterTest;
  import org.testng.annotations.BeforeMethod;
  import org.testng.annotations.BeforeTest;
  import org.testng.annotations.Test;
  
  public class NewTest {
      public WebDriver driver;
      // = new ChromeDriver();
      // System.setProperty("webdriver.chrome.driver","/Users/rohit/Desktop/chromedriver");
      public String baseurl = "http://google.com";
  
      @BeforeTest
      public void launchbrowser()
  
      {
          System.out.println("LaunchBrowser called...");
          System.setProperty("webdriver.chrome.driver", "/Users/rohit/Desktop/chromedriver");
          driver = new ChromeDriver();
          driver.get(baseurl);
      }
      // *[@id="gmail-sign-in"]//*[@id="gbw"]/div/div/div[1]/div[1]/a
  
      @BeforeMethod
      public void Beforemethod() {
          System.out.println("Hello Before Method");
      }
  
      @Test(priority = 0)
      public void GmailTap() {
          System.out.println("Test priority 0 called...");
          driver.findElement(By.xpath("//*[@id=\"gbw\"]/div/div/div[1]/div[1]/a")).click();
          // driver.findElement(By.xpath("//*[@id=\"gmail-sign-in\"]")).click();
  
          System.out.println("hello");
          driver.findElement(By.id("Email")).sendKeys("abc@gmail.com");
          driver.manage().timeouts().implicitlyWait(10, TimeUnit.HOURS);
          // Thread.sleep(8000);
          // driver.close();
          // findElement(By.cssSelector(""))
          driver.findElement(By.name("signIn")).click();
          // CharSequence charSequence = new
          boolean flag = true;
          while (flag) {
              try {
                  driver.findElement(By.name("Passwd")).sendKeys("123456");
                  System.out.println("Executed");
                  flag = false;
              } catch (Exception e) {
              }
          }
  
          driver.findElement(By.id("signIn")).click();
  
          driver.findElement(By.xpath("//*[@id=\"gb\"]/div[1]/div[1]/div[2]/div[4]/div[1]/a/span")).click();
          driver.findElement(By.xpath("//*[@id=\"gb_71\"]")).click();
  
      }
      // _____________
  
      @Test(priority = 1)
      public void GmailTap2() {
          System.out.println("Test priority 1 called...");
          // driver.findElement(By.xpath("//*[@id=\"gbw\"]/div/div/div[1]/div[1]/a")).click();
  
          System.out.println("hello");
          driver.findElement(By.id("Email")).sendKeys("abc1@gmail.com");
          driver.manage().timeouts().implicitlyWait(10, TimeUnit.HOURS);
  
          driver.findElement(By.name("signIn")).click();
          boolean flag = true;
          while (flag) {
              try {
                  driver.findElement(By.name("Passwd")).sendKeys("123456");
                  System.out.println("Executed");
                  flag = false;
              } catch (Exception e) {
              }
          }
  
          driver.findElement(By.id("signIn")).click();
  
          driver.findElement(By.xpath("//*[@id=\"gb\"]/div[1]/div[1]/div[2]/div[4]/div[1]/a/span")).click();
          driver.findElement(By.xpath("//*[@id=\"gb_71\"]")).click();
  
      }
  
      // ____________
  
      @AfterMethod
      public void aftersignout1() {
          driver.findElement(By.xpath("//*[@id=\"account-chooser-link\"]")).click();
          driver.findElement(By.xpath("//*[@id=\"account-chooser-add-account\"]")).click();
      }
  
      @AfterTest
      public void aftersignout() {
          System.out.println("aftersignOut called...");
          // New Accnt
          driver.close();
      }
      // *[@id="account-chooser-add-account"]
  
  }
  </code></pre>
  
  <p>Output is shown as :</p>
  
  <pre><code>LaunchBrowser called...
  Starting ChromeDriver 2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b) on port 25912
  Only local connections are allowed.
  Hello Before Method
  Test priority 0 called...
  hello
  Executed
  Hello Before Method
  Test priority 1 called...
  [340.657][SEVERE]: Unable to receive message from renderer
  </code></pre>