Wednesday, 13 December 2017

Set up testlink with Selenium Framework

To Integrate Testlink with selenium add following jars in your setup


  • testlink-api-client-2.0.jar
  • xmlrpc-common-3.1.jar
  • xmlrpc-client-3.1.jar
  • ws-commons-util-1.0.2.jar
All above files can be add by maven dependency except  testlink-api-client-2.0.jar.
So we need to do it manually 


  1. Copy jar file at some location in project. Lets assume it is :
    src\main\resources\jar_library\testlink-api-client-2.0.jar
  2. Now move to your pom.xml file path in CMD or Terminal (mostly root folder of project)
  3. For windows user, use below command to add jar as maven dependency :
mvn install:install-file -Dfile=src\main\resources\jar_library\testlink-api-client-2.0.jar -DgroupId=com.testlink.client -DartifactId=testlink-api-client -Dversion=2.0 -Dpackaging=jarmvn install:install-file -Dfile=src\main\resources\jar_library\testlink-api-client-2.0.jar -DgroupId=com.testlink.client -DartifactId=testlink-api-client -Dversion=2.0 -Dpackaging=jar
  4.At last, add dependency in your pom.xml as under and start using it :
<dependency>
    <groupId>com.testlink.client</groupId>
    <artifactId>testlink-api-client</artifactId>
    <version>2.0</version>
</dependency>

How to generate extent report

To generate Extent Report  need to add these codes



package main.java.listener;

import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.GherkinKeyword;
import com.aventstack.extentreports.markuputils.Markup;
import com.aventstack.extentreports.markuputils.MarkupHelper;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
import com.aventstack.extentreports.reporter.ExtentXReporter;
import com.aventstack.extentreports.reporter.configuration.ChartLocation;

import gherkin.formatter.Formatter;
import gherkin.formatter.Reporter;
import gherkin.formatter.model.*;

import java.io.File;
import java.util.LinkedList;
import java.util.List;

/**
 * A cucumber based reporting listener which generates the Extent Report
 */
public class ExtentCucumberFormatter implements Reporter, Formatter {

 private static ExtentReports extentReports;
 private static ExtentHtmlReporter htmlReporter;
 private static ThreadLocal<ExtentTest> featureTestThreadLocal = new InheritableThreadLocal<>();
 private static ThreadLocal<ExtentTest> scenarioOutlineThreadLocal = new InheritableThreadLocal<>();
 static ThreadLocal<ExtentTest> scenarioThreadLocal = new InheritableThreadLocal<>();
 private static ThreadLocal<LinkedList<Step>> stepListThreadLocal = new InheritableThreadLocal<>();
 static ThreadLocal<ExtentTest> stepTestThreadLocal = new InheritableThreadLocal<>();
 private boolean scenarioOutlineFlag;

 public ExtentCucumberFormatter(File file) {
  setExtentHtmlReport(file);
  setExtentReport();
  stepListThreadLocal.set(new LinkedList<Step>());
  scenarioOutlineFlag = false;
 }

 private static void setExtentHtmlReport(File file) {
  if (htmlReporter != null) {
   return;
  }
  if (!file.exists()) {
   file.getParentFile().mkdirs();
  }
  htmlReporter = new ExtentHtmlReporter(file);
  htmlReporter.config().setTestViewChartLocation(ChartLocation.BOTTOM);
  htmlReporter.config().setDocumentTitle("ExtentReports - Automation");
  htmlReporter.config().setReportName("ExtentReports - Automation");
  // htmlReporter.config().setAutoCreateRelativePathMedia(true);
 }

 static ExtentHtmlReporter getExtentHtmlReport() {
  return htmlReporter;
 }

 private static void setExtentReport() {
  if (extentReports != null) {
   return;
  }
  extentReports = new ExtentReports();
  extentReports.attachReporter(htmlReporter);

  // Starting ExtentX Server.
  /*ExtentXReporter extentx = new ExtentXReporter("localhost", 27017);
  extentx.config().setProjectName("Yaskawa");
  extentx.config().setReportName("Login");
  extentReports.attachReporter(htmlReporter, extentx);
  extentx.config().setServerUrl("http://localhost:1337");*/
  //extentx.flush();
 }

 static ExtentReports getExtentReport() {
  return extentReports;
 }

 public void syntaxError(String state, String event, List<String> legalEvents, String uri, Integer line) {

 }

 public void uri(String uri) {

 }

 public void feature(Feature feature) {
  featureTestThreadLocal.set(getExtentReport()
    .createTest(com.aventstack.extentreports.gherkin.model.Feature.class, feature.getName()));
  ExtentTest test = featureTestThreadLocal.get();

  for (Tag tag : feature.getTags()) {
   test.assignCategory(tag.getName());
  }
 }

 public void scenarioOutline(ScenarioOutline scenarioOutline) {
  scenarioOutlineFlag = true;
  ExtentTest node = featureTestThreadLocal.get().createNode(
    com.aventstack.extentreports.gherkin.model.ScenarioOutline.class, scenarioOutline.getName());
  scenarioOutlineThreadLocal.set(node);
 }

 public void examples(Examples examples) {
  ExtentTest test = scenarioOutlineThreadLocal.get();

  String[][] data = null;
  List<ExamplesTableRow> rows = examples.getRows();
  int rowSize = rows.size();
  for (int i = 0; i < rowSize; i++) {
   ExamplesTableRow examplesTableRow = rows.get(i);
   List<String> cells = examplesTableRow.getCells();
   int cellSize = cells.size();
   if (data == null) {
    data = new String[rowSize][cellSize];
   }
   for (int j = 0; j < cellSize; j++) {
    data[i][j] = cells.get(j);
   }
  }
  test.info(MarkupHelper.createTable(data));
 }

 public void startOfScenarioLifeCycle(Scenario scenario) {
  if (scenarioOutlineFlag) {
   scenarioOutlineFlag = false;
  }

  ExtentTest scenarioNode;
  if (scenarioOutlineThreadLocal.get() != null
    && scenario.getKeyword().trim().equalsIgnoreCase("Scenario Outline")) {
   scenarioNode = scenarioOutlineThreadLocal.get()
     .createNode(com.aventstack.extentreports.gherkin.model.Scenario.class, scenario.getName());
  } else {
   scenarioNode = featureTestThreadLocal.get()
     .createNode(com.aventstack.extentreports.gherkin.model.Scenario.class, scenario.getName());
  }

  for (Tag tag : scenario.getTags()) {
   scenarioNode.assignCategory(tag.getName());
  }
  scenarioThreadLocal.set(scenarioNode);
 }

 public void background(Background background) {

 }

 public void scenario(Scenario scenario) {

 }

 public void step(Step step) {
  if (scenarioOutlineFlag) {
   return;
  }
  stepListThreadLocal.get().add(step);
 }

 public void endOfScenarioLifeCycle(Scenario scenario) {

 }

 public void done() {
  getExtentReport().flush();
 }

 public void close() {

 }

 public void eof() {

 }

 public void before(Match match, Result result) {

 }

 public void result(Result result) {
  if (scenarioOutlineFlag) {
   return;
  }

  if (Result.PASSED.equals(result.getStatus())) {
   stepTestThreadLocal.get().pass(Result.PASSED);
  } else if (Result.FAILED.equals(result.getStatus())) {
   stepTestThreadLocal.get().fail(result.getError());
  } else if (Result.SKIPPED.equals(result)) {
   stepTestThreadLocal.get().skip(Result.SKIPPED.getStatus());
  } else if (Result.UNDEFINED.equals(result)) {
   stepTestThreadLocal.get().skip(Result.UNDEFINED.getStatus());
  }
 }

 public void after(Match match, Result result) {

 }

 public void match(Match match) {
  Step step = stepListThreadLocal.get().poll();
  String data[][] = null;
  if (step.getRows() != null) {
   List<DataTableRow> rows = step.getRows();
   int rowSize = rows.size();
   for (int i = 0; i < rowSize; i++) {
    DataTableRow dataTableRow = rows.get(i);
    List<String> cells = dataTableRow.getCells();
    int cellSize = cells.size();
    if (data == null) {
     data = new String[rowSize][cellSize];
    }
    for (int j = 0; j < cellSize; j++) {
     data[i][j] = cells.get(j);
    }
   }
  }

  ExtentTest scenarioTest = scenarioThreadLocal.get();
  ExtentTest stepTest = null;

  try {
   stepTest = scenarioTest.createNode(new GherkinKeyword(step.getKeyword()),
     step.getKeyword() + step.getName());
  } catch (ClassNotFoundException e) {
   e.printStackTrace();
  }

  if (data != null) {
   Markup table = MarkupHelper.createTable(data);
   stepTest.info(table);
  }

  stepTestThreadLocal.set(stepTest);
 }

 public void embedding(String mimeType, byte[] data) {

 }

 public void write(String text) {

 }
}

package main.java.listener;

import java.io.File;

/**
 * An enum which holds the properties to be set for extent reporter
 */
public enum ExtentProperties {
    INSTANCE;
    private String reportPath;
    private String extentXServerUrl;
    private String projectName;

    ExtentProperties() {
        this.reportPath = "output" + File.separator + "Run_" + System.currentTimeMillis() + File.separator
                + "report1.html";
        this.projectName = "default";
    }

    /**
     * Gets the report path
     * @return The report path
     */
    public String getReportPath() {
        return reportPath;
    }

    /**
     * Sets the report path
     * @param reportPath The report path value
     */
    public void setReportPath(String reportPath) {
        this.reportPath = reportPath;
    }

    /**
     * Gets the ExtentX server URL
     * @return The ExtentX server URL
     */
    public String getExtentXServerUrl() {
        return extentXServerUrl;
    }

    /**
     * Sets the ExtentX server URL
     * @param extentXServerUrl The ExtentX server URL
     */
    public void setExtentXServerUrl(String extentXServerUrl) {
        this.extentXServerUrl = extentXServerUrl;
    }

    /**
     * Gets the project name
     * @return The project name
     */
    public String getProjectName() {
        return projectName;
    }

    /**
     * Gets the project name
     * @param projectName The project name
     */
    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }
}

package main.java.listener;

import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * This class houses few utilities required for the report
 */
public class Reporter {
    private static Map<String, Boolean> systemInfoKeyMap = new HashMap<>();

    private Reporter() {
        // Defeat instantiation
    }

    /**
     * Gets the {@link ExtentHtmlReporter} instance created through listener
     *
     * @return The {@link ExtentHtmlReporter} instance
     */
    public static ExtentHtmlReporter getExtentHtmlReport() {
        return ExtentCucumberFormatter.getExtentHtmlReport();
    }

    /**
     * Gets the {@link ExtentReports} instance created through the listener
     *
     * @return The {@link ExtentReports} instance
     */
    public static ExtentReports getExtentReport() {
        return ExtentCucumberFormatter.getExtentReport();
    }

    /**
     * Loads the XML config file
     *
     * @param xmlPath The xml path in string
     */
    public static void loadXMLConfig(String xmlPath) {
        getExtentHtmlReport().loadXMLConfig(xmlPath);
    }

    /**
     * Loads the XML config file
     *
     * @param file The file path of the XML
     */
    public static void loadXMLConfig(File file) {
        getExtentHtmlReport().loadXMLConfig(file);
    }

    /**
     * Adds an info message to the current step
     *
     * @param message The message to be logged to the current step
     */
    public static void addStepLog(String message) {
        getCurrentStep().info(message);
    }

    /**
     * Adds an info message to the current scenario
     *
     * @param message The message to be logged to the current scenario
     */
    public static void addScenarioLog(String message) {
        getCurrentScenario().info(message);
    }

    /**
     * Adds the screenshot from the given path to the current step
     *
     * @param imagePath The image path
     * @throws IOException Exception if imagePath is erroneous
     */
    public static void addScreenCaptureFromPath(String imagePath) throws IOException {
        getCurrentStep().addScreenCaptureFromPath(imagePath);
    }

    /**
     * Adds the screenshot from the given path with the given title to the current step
     *
     * @param imagePath The image path
     * @param title     The title for the image
     * @throws IOException Exception if imagePath is erroneous
     */
    public static void addScreenCaptureFromPath(String imagePath, String title) throws IOException {
        getCurrentStep().addScreenCaptureFromPath(imagePath, title);
    }

    /**
     * Adds the screen cast from the given path to the current step
     *
     * @param screenCastPath The screen cast path
     * @throws IOException Exception if imagePath is erroneous
     */
    public static void addScreenCast(String screenCastPath) throws IOException {
        getCurrentStep().addScreencastFromPath(screenCastPath);
    }

    /**
     * Sets the system information with the given key value pair
     *
     * @param key   The name of the key
     * @param value The value of the given key
     */
    public static void setSystemInfo(String key, String value) {
        if (systemInfoKeyMap.isEmpty() || !systemInfoKeyMap.containsKey(key)) {
            systemInfoKeyMap.put(key, false);
        }
        if (systemInfoKeyMap.get(key)) {
            return;
        }
        getExtentReport().setSystemInfo(key, value);
        systemInfoKeyMap.put(key, true);
    }

    /**
     * Sets the test runner output with the given list of strings
     *
     * @param log The list of string messages
     */
    public static void setTestRunnerOutput(List<String> log) {
        getExtentReport().setTestRunnerOutput(log);
    }

    /**
     * Sets the test runner output with the given string
     *
     * @param outputMessage The message to be shown in the test runner output screen
     */
    public static void setTestRunnerOutput(String outputMessage) {
        getExtentReport().setTestRunnerOutput(outputMessage);
    }

    /**
     * Sets the author name for the current scenario
     * @param authorName The author name of the current scenario
     */
    public static void assignAuthor(String... authorName) {
        getCurrentScenario().assignAuthor(authorName);
    }

    private static ExtentTest getCurrentStep() {
        return ExtentCucumberFormatter.stepTestThreadLocal.get();
    }

    private static ExtentTest getCurrentScenario() {
        return ExtentCucumberFormatter.scenarioThreadLocal.get();
    }
}

How to generate Logs

To generate logs write log4j.properties as



#Root Logger Option
log4j.rootLogger=INFO,file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=D:\\eclipse\\WorkSpace\\Yaskawa\\src\\main\\resources\\LogMaster.log
log4j.appender.file.MaxFileSize=5120KB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout = balle.logging.ANSIColorLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5 %c<strong>{1}</strong>:%L - %m%n
log4j.appender.file.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} %-4r [%t]  %-5p %c: %x %m %n
log4j.appender.file.Append=false
and that will write logs on  LogMaster.log






Writing Steps and Pages (java code)

Now write steps according to the feature files

Example

package test.java.steps;

import org.testng.Assert;

import cucumber.api.PendingException;
import cucumber.api.java.en.Then;
import test.java.pages.ContentAdminPage;
import test.java.pages.HomePage;
import test.java.pages.PartnerHomePage;
import test.java.util.DriverFactory;
import test.java.util.VideoReord;

public class ContentAdminSteps extends DriverFactory {
 VideoReord videoStart = new VideoReord();

 @Then("^Web Content page should get opened$")
 public void web_Content_page_should_get_opened() throws Throwable {
  Assert.assertTrue(new ContentAdminPage(driver).isContentPageLoaded());
 }

 @Then("^Search and select a training class$")
 public void click_on_Browse_By_and_Click_on_Training_Classes() throws Throwable {
  new ContentAdminPage(driver).select_training_class();
 }

 @Then("^Web Content editor should opened$")
 public void web_Content_editor_should_opened() throws Throwable {
  Assert.assertTrue(new ContentAdminPage(driver).isWebContentEditorLoaded());
 }

 @Then("^Select Prerequesties Required as YES$")
 public void select_Prerequesties_Required_as_YES() throws Throwable {
  new ContentAdminPage(driver).Prerequesties_select();
 }

 @Then("^Click in publish$")
 public void click_in_publish() throws Throwable {
  new ContentAdminPage(driver).publish();
 }

 @Then("^Success Message should display$")
 public void success_Message_should_display() throws Throwable {
  Assert.assertTrue(new ContentAdminPage(driver).isSuccessMessageDisplayed());
 }

 @Then("^Search and select a training schedule$")
 public void search_and_select_a_training_schedule() throws Throwable {
  new ContentAdminPage(driver).select_training_schedule();
 }

 /*@Then("^Enter start date as \"([^\"]*)\" and end date as \"([^\"]*)\"$")
 public void enter_start_date_and_end_date(String startdate, String enddate) throws Throwable {
  new ContentAdminPage(driver).enter_date(startdate, enddate);
 }*/

 @Then("^Do logout$")
 public void do_logout() throws Throwable {
  new PartnerHomePage(driver).do_logout();
 }

 @Then("^Home Page should display$")
 public void home_Page_should_display() throws Throwable {
  new HomePage(driver).isLoginlinkDisplayed();

 }
}
package test.java.pages;

import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoSuchElementException;
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;
import main.java.listener.DateFormatter;
import main.java.listener.Reporter;
import test.java.util.Screenshot;
import test.java.util.SeleniumControls;
import test.java.util.WebElementExtender;

public class ContentAdminPage {
 
 @FindBy(xpath = ".//*[@id='cpPortletTitle']/span[1]")
 private WebElement WebContentText;
 
 @FindBy(linkText = "Browse by Structure")
 private WebElement browseBy;
 
 @FindBy(linkText = "Training Classes")
 private WebElement trainigClasses;
 
 @FindBy(id = "_15_keywords")
 private WebElement searchBox;
 
 @FindBy(xpath = ".//*[@id='_15_simple']/div/button")
 private WebElement searchButton;
 
 
 @FindBy(linkText = "Hands-on Troubleshooting for 2000")
 private WebElement trainigclassLink;
 
 @FindBy(xpath = ".//*[@id='_15_fm2']/div[1]/a/div[2]/span[1]")
 private WebElement handson;
 
 @FindBy(xpath = ".//*[@id='_15_journalArticleBody']/div/div[2]/div/label")
 private WebElement title;
 
 @FindBy(name = "_15_prerequisites_required_INSTANCE_yayo")
 private WebElement preReqSelect;
 
 @FindBy(id = "_15_publishButton")
 private WebElement publishButton;
 

 @FindBy(xpath = ".//*[@id='portlet_15']/div/div/div/div[1]")
 private WebElement successMessage;
 
 @FindBy(id = "_15_start__date__INSTANCE__cgeo")
 private WebElement startDate;
 
 @FindBy(id = "_15_end__date__INSTANCE__dson")
 private WebElement endDate;
 
 @FindBy(xpath = ".//*[@id='_15_entriesContainer']/div[1]/a/div[2]/span[1]")
 private WebElement newSchedule;
 
 @FindBy(xpath = ".//*[@id='_15_publishButton']")
 private WebElement schedulePublish;
 
 WebDriver driver;
 Logger log = Logger.getLogger("");

 public ContentAdminPage(WebDriver driver) {
  this.driver = driver;
  PageFactory.initElements(driver, this);
 }

 public boolean isContentPageLoaded() throws IOException {
  
  try {
   log.info("Content Admin Page is Loaded Successfully");

  } catch (NoSuchElementException e) {
   log.error("Content Admin Page is not loaded");

   FileUtils.copyFile(Screenshot.captureElementBitmap(WebContentText),
     new File("D:/eclipse/WorkSpace/Yaskawa/Screenshots/WebContentText.png"));
   Reporter.addScreenCaptureFromPath("D:/eclipse/WorkSpace/Yaskawa/Screenshots/WebContentText.png");
  }
  
  return WebContentText.isDisplayed();
 }

 public void select_training_class() throws IOException, InterruptedException {
  
  try {
   log.info("search by keyword");
   WebElementExtender.highlightElement(searchBox);
   SeleniumControls.populateTextBox(searchBox, "Hands");
   //searchBox.sendKeys("Hands");
   
   log.info("click on search button");
   WebElementExtender.highlightElement(searchButton);
   searchButton.click();
   
   log.info("click on training class");
   WebElementExtender.highlightElement(handson);
   handson.click();
  } catch (NoSuchElementException e) {
   log.error("Trainig Class is not found");

   FileUtils.copyFile(Screenshot.captureElementBitmap(trainigClasses),
     new File("D:/eclectlipse/WorkSpace/Yaskawa/Screenshots/browseBy.png"));
   Reporter.addScreenCaptureFromPath("D:/eclipse/WorkSpace/Yaskawa/Screenshots/browseBy.png");
  }
 }

 public boolean isWebContentEditorLoaded() throws IOException {
  
  try {
   log.info("Web Content Editor is Loaded Successfully");

  } catch (NoSuchElementException e) {
   log.error("Web Content Editor is not loaded");

   FileUtils.copyFile(Screenshot.captureElementBitmap(WebContentText),
     new File("D:/eclipse/WorkSpace/Yaskawa/Screenshots/WebContentText.png"));
   Reporter.addScreenCaptureFromPath("D:/eclipse/WorkSpace/Yaskawa/Screenshots/WebContentText.png");
  }
  
  
  // TODO Auto-generated method stub
  return title.isDisplayed();
 }

 public void Prerequesties_select() throws IOException, InterruptedException {
  try {
   log.info("Prerequesties selection as yes");
   WebElementExtender.highlightElement(preReqSelect);
   Thread.sleep(6000);
   /*Select drpPreReq =new Select(preReqSelect);
   drpPreReq.selectByVisibleText("Yes");
   */
   SeleniumControls.populateDropDown(preReqSelect, "Yes");

  } catch (NoSuchElementException e) {
   log.error("No option is selected");

   FileUtils.copyFile(Screenshot.captureElementBitmap(WebContentText),
     new File("D:/eclipse/WorkSpace/Yaskawa/Screenshots/WebContentText.png"));
   Reporter.addScreenCaptureFromPath("D:/eclipse/WorkSpace/Yaskawa/Screenshots/WebContentText.png");
  }
  
 }

 public void publish() throws IOException, InterruptedException {
  
  try {
   log.info("Click in Publish");
   WebElementExtender.highlightElement(publishButton);
   publishButton.click();
   Thread.sleep(6000);

  } catch (NoSuchElementException e) {
   log.error("Some mandatory fields are not filled");

   FileUtils.copyFile(Screenshot.captureElementBitmap(WebContentText),
     new File("D:/eclipse/WorkSpace/Yaskawa/Screenshots/WebContentText.png"));
   Reporter.addScreenCaptureFromPath("D:/eclipse/WorkSpace/Yaskawa/Screenshots/WebContentText.png");
  }
   
 }

 public boolean isSuccessMessageDisplayed() throws IOException {
  
  try {
   log.info("Success Message is displaying");
   WebElementExtender.highlightElement(successMessage);
   

  } catch (NoSuchElementException e) {
   log.error("Success Message is not displaying");

   FileUtils.copyFile(Screenshot.captureElementBitmap(WebContentText),
     new File("D:/eclipse/WorkSpace/Yaskawa/Screenshots/WebContentText.png"));
   Reporter.addScreenCaptureFromPath("D:/eclipse/WorkSpace/Yaskawa/Screenshots/WebContentText.png");
  }
  // TODO Auto-generated method stub
  return successMessage.isDisplayed();
 }


 public void select_training_schedule() throws IOException {
  try {
   log.info("search by trainig schedule");
   WebElementExtender.highlightElement(searchBox);
   SeleniumControls.populateTextBox(searchBox, "New Schedule");
   //searchBox.sendKeys("New Schedule");
   
   log.info("click on search button");
   WebElementExtender.highlightElement(searchButton);
   searchButton.click();
   
   log.info("click on training schedule");
   WebElementExtender.highlightElement(newSchedule);
   newSchedule.click();
  } catch (NoSuchElementException e) {
   log.error("Trainig Schedule  is not found");

   FileUtils.copyFile(Screenshot.captureElementBitmap(newSchedule),
     new File("D:/eclectlipse/WorkSpace/Yaskawa/Screenshots/browseBy.png"));
   Reporter.addScreenCaptureFromPath("D:/eclipse/WorkSpace/Yaskawa/Screenshots/browseBy.png");
  }
  
 }
 
public void enter_date(String start, String end) throws IOException {
  
  try {
   log.info("Enter Start Date");
   WebElementExtender.highlightElement(startDate);
   SeleniumControls.populateTextBox(startDate,DateFormatter.getStartDate(start));
   
   log.info("Enter end Date");
   WebElementExtender.highlightElement(endDate);
   SeleniumControls.populateTextBox(endDate, DateFormatter.geEndtDate(end));
   

  } catch (NoSuchElementException e) {
   log.error("Success Message is not displaying");

   FileUtils.copyFile(Screenshot.captureElementBitmap(WebContentText),
     new File("D:/eclipse/WorkSpace/Yaskawa/Screenshots/WebContentText.png"));
   Reporter.addScreenCaptureFromPath("D:/eclipse/WorkSpace/Yaskawa/Screenshots/WebContentText.png");
  }
 }

 public void do_publish() {
  // TODO Auto-generated method stub
  
 }

}

Set up testlink with Selenium Framework

To Integrate Testlink with selenium add following jars in your setup testlink-api-client-2.0.jar xmlrpc-common-3.1.jar xmlrpc-client-...