Showing posts with label TestNG. Show all posts
Showing posts with label TestNG. Show all posts

Saturday, 12 September 2015

SeleniumFramework - A simple web testing framework based on open source technology Selenium WebDriver, TestNG, Java, Apache POI

#Selenium #WebDriver #Maven #TestNG #Framework #POI #Jenkins

This framework is designed to help you get started with Web testing quickly, to grow as needed, and to avoid common pitfalls. it just allows you to manipulate browser.
Who Will Cry When You Die?

Main features:
  • Provides browser automation using Selenium WebDriver
  • Page Object Model is used to design pattern to create Object Repository for web UI elements.
  •  Running test case against multiple set of test data
  • Automation Suite Configuration using Java properties file
  • TestNG.xml file which provides feature to run selective test suite
  • Screenshot capturing capability for failed test scenario (Take screenshots on demand and save on disk.)
  • Uses Apache logger for generating test execution logs
  • Build Tool : Maven
  • Programming language: Java
  • Test Data Management: data stored in Excel worksheet : Apache POI
  • Parallel Execution : Using Selenium Grid to run simultaneous test execution
  • CI Integration : Integrated with Jenkins
  • Exceptions handling : Using Java try/Catch exception handling feature
  • Reports : Custom html reports are generated and available in test-output folder

To download Framework, visit link - Download Here

Note - If any doubt/query/suggestion, pls post in forum - Testing Forum

Thursday, 10 July 2014

Cucumber vs TestNG : Which is better?

I have been a long time user of TestNG.  Few months back, I started exploring about Cucumber. It was a wish from my client to create automation framework using Cucumber. I searched on web & found many blogs on Cucumber & its implementation. I started with assumption that Cucumber will replace TestNG. After working for few months, I came to following conclusion they are as follows -

                    Cucumber
                        TestNG
  • Cucumber is a collaboration tool, which lets non-technical people write executable specifications. Those executable specifications test your app from the outside - like a black box.
  • Cucumber is not meant to be used as a unit testing tool.
  •  It allows to write automated acceptance tests, functional requirements and software documentation into one format that would be understandable by non-technical people as well as testing tools
  • You can implement your tests using the same language you use to discuss them with the business. 
  • Cucumber adds the overhead of plain English (or other native language) to executable code conversion
  • Good for acceptance testing

  • TestNG are unit testing tools. They are great for testing individual classes, but not great for executable specifications that are readable (and writeable) by non-technical people.
  • It facilitates to test individual classes.
  •  You can group tests using tags.
  •  TestNG supports a lot of complicated practices like priorities, grouping, listener etc. 
  •  Useful when you have to automate large number of test case


Monday, 10 February 2014

How to Verify Broken Links using Selenium WebDriver

This program reads all link from a web page, sends open connection request to URL, checks for response code. Based on response code, broken link is identified & get printed on console.

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class Links_Broken {

    @Test
      public void saveAllLinks(){
          FirefoxDriver firefoxDriver = new FirefoxDriver(); //Starts Firefox browser
                  
          firefoxDriver.navigate().to("
http://google.co.in"); //opens Web Page
               
           List <WebElement>linksList = firefoxDriver.findElements(By.tagName("a")); // finds link  elements & stores in a list

//traverse each link from collection
          for(WebElement linkElement: linksList){
              String link =linkElement.getAttribute("href");
              if(link!=null){
                verifyLinkActive(link);
              }
          }
          firefoxDriver.quit(); // close Firefox browser
      }
          
      /**
       * This method verifies that link is active
       * @param link - link(URL)
       * @return - true/false
       */
       public void verifyLinkActive(String linkUrl){
          try {
             URL url = new URL(linkUrl);
             HttpURLConnection httpURLConnect=(HttpURLConnection)url.openConnection();
             httpURLConnect.setConnectTimeout(3000);
             httpURLConnect.connect();

             if(httpURLConnect.getResponseCode()==200){
                 System.out.println(linkUrl+" - "+httpURLConnect.getResponseMessage());
              }
            if(httpURLConnect.getResponseCode()==HttpURLConnection.HTTP_NOT_FOUND)  

             {
                 System.out.println(linkUrl+" - "+httpURLConnect.getResponseMessage() + " - "+                  HttpURLConnection.HTTP_NOT_FOUND);
              }
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
}

Friday, 29 November 2013

Selenium TestNG - How to disable HTML Report Generation


Steps to disable TestNG default HTML Report generation is as follows - 
  1. Right Click on [Java Project] 
  2. Select [Properties] 
  3. Select [TestNG] 
  4. Select [Disable default Listeners]
  5. Click on [Ok] button
Note - This would work if you have installed TestNG as Eclipse plug-in.

Wednesday, 30 October 2013

How to Install TestNG in Eclipse

  • Open Eclipse
  • Go to Help – Install New Software – Click Add
  • In Add Repository box, type TestNG and type the URL http://beust.com/eclipse
  • TestNG plugin will added into Available Software List.
  • Click on Next and follow the installation screen to complete the setup
  • Restart Eclipse and go to Run menu and open Run Configurations