Skip to main content

Posts

Showing posts matching the search for testng

TestNG Annotation in Selenium Framework

TestNG Annotation in Selenium Framework:- Annotation :-  It is used to provide extra functionality during application flow in selenium program . Annotation always will be started from @ symbol in Java programming language. TestNG provide multiple annotation to implement Test Script. 1) @Test:-   this is the mandatory annotation in TESTNG Program ,it is used to write Multiple TestScript in Single Test Class. @Test void fun1() { } @Test void fun2() { } @Test void fun3() { } Example of TestNG :- import org.testng.annotations.Test; public class AnnotationExample {   @Test   public void f1() {   System.out.print("Test1");   }   @Test   public void f2() {   System.out.print("Test2");   }   @Test   public void f3() {   System.out.print("Test3");   } } ........................................................................................................................

Test Suite in TestNG

Test Suite in TestNG:- The test suite is used to execute more than one test class using a single XML file. Test Suite always will be defined by an XML file that contains multiple test classes using XML tag. First Create two different Test Case Classes  package scs; import org.testng.annotations.Test; import org.testng.annotations.BeforeTest; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterSuite; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeSuite; public class Test1 { @BeforeClass public void bclass(){ System.out.println("Before Class1"); } @AfterClass public void aclass(){ System.out.println("After Class1"); } @BeforeSuite public void bsclass(){ System.out.println("Before SUIT1"); } @AfterSuite public void asclass(){ System.out.println("After Suit1"); }   @Test   public void f() {   System.o...

Groups in TestNG

Groups in TestNG:- It is used to logically subdivide the test case method, based on its usability.  to create a group, tesng provides "groups" attribute, and " beforegroups" and " aftergroups" annotation will be called for each grouping method. Example 1st:- package scs; import org.testng.annotations.*; public class TestNGExampleNew { @BeforeGroups("car")     public void bg1()     {            System.out.println("Car1");     }     @AfterGroups("car")     public void bg2()     {     System.out.println("Car2");     }    @Test(groups={"car"})    public void car1()    {    System.out.println("Car3");    }   @Test(groups={"car"})    public void car2()    {   System.out.println("Car4");    }   @Test(groups={"scooter"})    public void scooter1()    { ...

TEST NG in Selenium?

It is an Automation Framework that provides a set of annotations to create and execute a test script. It provides a structured approach to writing code that is easily understandable by automation developers. it provides a test script, test code, and annotation to write a program. It is upgraded from Web Driver and a modified form of JMeter. TestNG Command, Locators are similar to Web Drivers. TESNG Provides HTML Test REPORT With all Test methods separately. Type of Annotation:- @Test // it represents Test Method @Test void fun1() { } ........................................................................................................................... @BeforeTest:- This annotation will be executed before the Test Method, It will be declared only once in one Test Class. @AfterTest:- This annotation will be executed after the execution of all Test methods .it will be declared only once in one test case. @Test:- It is used to create a Test Case Method, We can create more than ...

TESTNG Installation and display report

1) O pen eclipse -----> Help---->  Eclipse Marketplace . 1.1)  A new window would open up, wherein you need to type “TestNG” in the Find text box and click on the Go button. 1.2)  You will now see the search results with TestNG for Eclipse at the top. All you need to do now is click on the Install button next to it. 1.3)  Select the “ Keep my installation the same ” option and again click on the  Confirm  button. After successfully installing res-start eclipse. 2)  Create New JAVA Project -----> Build Path---> Add Selenium JAR File- 3)  Build Path---> Add Library 4)  Create a Package and Create TestNG Class 5)   Right Click on TestNG Class and Run by TestNG 6)   Refresh the Project folder to right-click on the project and choose the refresh option. 7)   it will create test-output and open index.html to right-click on the file and show the report if TestNG is not installed then you can follow another installa...

Selenium Framework, Data Driven, Keyword and Hybrid Framework Tutorials by Shiva Sir

It provides predefined libraries to implement a test script with a design pattern. The framework uses an external file to take test data which will be implemented into the test script. We will perform file handling operations using the Apache POI library by Jar integration or Maven. Type of Selenium Framework:- 1 Data-Driven Framework:-      we will create an external excel file or CSV file and define all Test data which will be read by File Handling operation and implemented in Test Script. 1.1 Create Environment using APACHE POI, SELENIUM, TestNG Download apache poi using the following link https://archive.apache.org/dist/poi/release/bin/ 1.2 Create Excel File I have created scs.excel 1.3 Write the following Code Data Driven Framework Code using Maven Project;- Java File:- package com.scs; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.xssf.usermodel.XSSFCell; im...