package com.selenium.integration; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import testlink.api.java.client.TestLinkAPIResults; public class Example { private WebDriver driver; @BeforeSuite public void setUp() throws Exception { driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); } @AfterSuite public void tearDown() throws Exception { driver.quit(); } @Test(priority = 1) public void accessApplicationURL() throws Exception { try { driver.get("https://mail.google.com"); TestLinkUtils.reportResult("TC-1", null, TestLinkAPIResults.TEST_PASSED); } catch (Exception e) { TestLinkUtils.reportResult("TC-1", e.getMessage(), TestLinkAPIResults.TEST_FAILED); //Below line will fail Selenium test case as well, comment it if you don't want it to fail throw new Exception(e); } } @Test(priority = 2) public void enterLoginDetails() throws Exception { try { driver.findElement(By.id("Email")).clear(); driver.findElement(By.id("Email")).sendKeys("your username or email"); driver.findElement(By.id("Email")).clear(); driver.findElement(By.id("Passwd")).sendKeys("your password"); TestLinkUtils.reportResult("TC-2", null, TestLinkAPIResults.TEST_PASSED); } catch (Exception e) { TestLinkUtils.reportResult("TC-2", e.getMessage(), TestLinkAPIResults.TEST_FAILED); //Below line will fail Selenium test case as well, comment it if you don't want it to fail throw new Exception(e); } } }