TestCaseOne.java

This is a sample selenium java program created to perform some action in the Google page and update the results into QC.

This Class is extended by the QcIntegration.java program which has function to perform operation in QC by invoking some inbuilt functions specified in the "OtiClient.Jar" file.

TestCaseOne.java

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class TestCaseOne extends QcIntegration{

    public static void main(String[] args){

        /**
        * @param args
        */
        String baseUrl="http://www.google.co.in";
        String strSearchKeyword = "test";
        String locSearchTextField = "q";
        String locSearchButton = "q";

        //Need to pass the Test case name
        String strTestCaseID = "<TestCaseName>";
        String strTestCaseStatus = "";

        WebDriver driver = null;

        try{
            driver = new FirefoxDriver();
            driver.get(baseUrl);
            driver.findElement(By.name(locSearchTextField)).sendKeys(strSearchKeyword);
            driver.findElement(By.name(locSearchButton)).submit();

            try {
            Thread.sleep(5000);
            } catch (InterruptedException e) {
            e.printStackTrace();
            }

            if(driver.getTitle().equals("")){
            strTestCaseStatus = "Failed";
            }
            else {
            strTestCaseStatus = "Passed";
            }
            //Calling the QC Test update Function
            sendRequest(strTestCaseID, strTestCaseStatus);

        }catch(Exception e){
            e.printStackTrace();
        }finally {
            //Close the browser
            driver.quit();
        }
    }

}

Popular posts from this blog

Selenium Webdriver Interview Questions with Answer

Selenium IDE Interview Questions with Answer

DLL to Jar file conversion