Wednesday, July 29, 2015

Selenium Webdriver - Data driven framework

        Selenium Web driver Data-Driven Framework

                                             Selenium Web driver Data-Driven Framework is where test input and output values are from data files (ODBC sources, CVS files, Excel files, and DAO objects) and are loaded into variables in captured or manually coded scripts.
In this framework, variables are used for both the input values and output verification values. The framework should include navigation through the program, reading of the data files, and logging of test status and information. All the processes should be in the test scripts. The framework should have the following features:
·         Well defined architectural design
·         Less time to test large data
·         Script execution in multiple environments
·         Easier, faster, and efficient analysis of result logs
·         Communication of results
·         Easy debugging and script maintenance
·         Robust and stable due to error and exception handling
·         100% reliability of utility scripts, online execution and report packages.
      Automation architecture package should include:

·         Config - Keeps all the configuration files such as property files. Ex: Config, log4j and OR.
·         Db Connection - has files containing data base connection to retrieve the data from the tables.
·         sendEmail - Contains methods how to send an email-Testreport after test execution.
·         ResuableCode:- Contains reusable methods which are repeatedly using in test scripts.
·         Util package - Should contain all generic functions & business functions such as email configuration settings and all other utilities.
·         functionalLibrary: All the common, precondition and post conditional methods which are used in the test scripts.
·         TestReports - Contains Maven generated reports
·         testData: all the input data files for parameterization.
·         ScreenShots: all the failed scenarios screen shots will be captured in this folder.
·         TestLogs-Contain log file corresponding to tests



Automation Framework Design Structure.
·         Create a folder structure like below.

Folder Structure for Automation frame work.


1.       Create a Java Project and add the library files into JRE System Library.
The folder structure like above and create the below classes, file and folder.


·         OR. Properties.
·         Db Connection.
·         EmailSending
·         Test Script(s)
·         ResuableCode
·         Testutil
·         FunctionalLibrary files.
·         Screenshots.
·         testData
·         TestReport.
·         Pom.xml
·         Testing.xml
·         Suite.xml
·         Multibrowser.xml




1.    OR.Properties:

CONFIG.Properties:


2.       DB Connection: how to connect to database, how to retrieve the information from the respective SQL tables.
#Code for SQL DB Connection:
package com.project.dBConnection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class SQLDBConnection {
            public static WebDriver driver1;
            String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
            String url = "jdbc:odbc://corp-sqlclci1/ci1/Triton";
            String username = "";
            String password = "";

            @BeforeClass
            public void setup() throws Exception {
                        driver1 = new FirefoxDriver();
                        driver1.get("SiteUrl");
            }

@Test
public void test() throws Exception {
                        Class.forName(driver);
                        Connection conn = DriverManager.getConnection(url, "DataBaseName",
                                                "Password");
                        System.out.println("Connection obj" + conn);

                        Statement st = conn.createStatement();
                        // st.executeUpdate("drop table survey;");
                        st.executeUpdate("create table suresh(id int,name varchar(30),Homesite varchar(30));");
                        st.executeUpdate("insert into suresh (id,name,Homesite) values (1,'SURESH','selenium-suresh.blogspot.com')");
                        st = conn.createStatement();
                        ResultSet rs = st.executeQuery("select top 50 * from member");
                        if (rs.next())
                                    ;
                        {
                                    String homesite = rs.getString(3);

                                    Thread.sleep(30000);
                        }
            }

@AfterClass
public void teardown() throws Exception {
                        driver1.close();
            }
}
----------------------------------------------------------------------------------------------------------------
3.     Email Sending: after executing the test scripts the test report automatically will be sent via email to corresponding emails.
# Code for EmailSend:
package com.project.eMailSending;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import org.testng.annotations.Test;
public class SendMail {
                @Test
                public static void sendMail() throws Exception, MessagingException, AddressException {

                                DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
                                Date date = new Date();
                                Properties props = System.getProperties();
                                zipDir("D:/XiiM_Reports", "E:/Reports/XiiM_Reports.zip");
                                try{
                                                // Setup mail server
                                                props.put("mail.smtp.host", "nextemail01.nextsphere.com");
                                                props.put("mail.smtp.auth", "false");
                                                props.put("mail.smtp.port", "25");
                                                props.put("mail.smtp.starttls.enable","false");
                                                // Get session
                                                Session session = Session.getDefaultInstance(props, null);
                                                // Define message
                                                MimeMessage message = new MimeMessage(session);
                                                // Set the from address
                                                message.setFrom(new InternetAddress("sairam.gundepuneni@nextsphere.com"));
                                                String[] to = {"ramesh.kudikala@nextsphere.com"};
                                                String[] cc = {"Desaiah.dana@nextsphere.com"};
                                                //     String[] bcc = {"ashok.pinnuri@nextsphere.com"};
                                                InternetAddress[] toAddress = new InternetAddress[to.length];
                                                InternetAddress[] ccAddress = new InternetAddress[cc.length];
                                                //   InternetAddress[] bccAddress = new InternetAddress[bcc.length];
                                                // get the to address
                                                for( int i=0; i < to.length; i++ ) {
                                                                toAddress[i] = new InternetAddress(to[i]);
                                                }
                                                // Set the to address
                                                for( int i=0; i < toAddress.length; i++) {
                                                                message.addRecipient(Message.RecipientType.TO, toAddress[i]);
                                                }
                                                // get the cc address
                                                for( int i=0; i < cc.length; i++ ) {
                                                                ccAddress[i] = new InternetAddress(cc[i]);
                                                }
                                                // Set the cc address
                                                for( int i=0; i < ccAddress.length; i++) {
                                                                message.addRecipient(Message.RecipientType.CC, ccAddress[i]);
                                                }
                                                // Set the subject
                                                message.setSubject("XiiM Automation test Reports_"+dateFormat.format(date).toString());
                                                // Create the message part
                                                BodyPart messageBodyPart = new MimeBodyPart();
                                                // Fill the message
                                                // messageBodyPart.setText("hi");
                                                messageBodyPart.setContent("Hello Team,\n\nPlease find the attached XiiM Automation reports.\n\nThanks & Regards,\nSairam Gundepuneni",  "text/plain");
                                                Multipart multipart = new MimeMultipart();
                                                multipart.addBodyPart(messageBodyPart);
                                                // Part two is attachment
                                                messageBodyPart = new MimeBodyPart();
                                                String filename = "XiiM_Reports"+"_"+dateFormat.format(date).toString()+".zip";
                                                //String filename = System.getProperty("user.dir")+"\\EnrollmentPortalReports.zip";
                                                System.out.println(filename);
                                                Thread.sleep(10000);
                                                DataSource source = new FileDataSource("E:/Reports/XiiM_Reports.zip");
                                                messageBodyPart.setDataHandler(new DataHandler(source));
                                                messageBodyPart.setFileName(filename);
                                                multipart.addBodyPart(messageBodyPart);
                                                // Put parts in message
                                                message.setContent(multipart);
                                                // Send message
                                                Transport.send(message,message.getAllRecipients());
                                                System.out.println("Mail Sent ....SUCCESSFULLY");

                                }catch(MessagingException e){
                                                System.out.println("Mail Not Sent.......");
                                                e.printStackTrace();
                                }

                }
                public static void zipDir(String dirName, String nameZipFile) throws Exception {
                                ZipOutputStream zip = null;
                                FileOutputStream fW = null;
                                fW = new FileOutputStream(nameZipFile);
                                zip = new ZipOutputStream(fW);
                                addFolderToZip("", dirName, zip);
                                zip.close();
                                fW.close();
                }

                public static void addFolderToZip(String path, String srcFolder, ZipOutputStream zip) throws Exception {
                                File folder = new File(srcFolder);
                                if (folder.list().length == 0) {
                                                addFileToZip(path , srcFolder, zip, true);
                                }
                                else {
                                                for (String fileName : folder.list()) {
                                                                if (path.equals("")) {
                                                                                addFileToZip(folder.getName(), srcFolder + "/" + fileName, zip, false);
                                                                }
                                                                else {
                                                                                addFileToZip(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip, false);
                                                                }
                                                }
                                }
                }

       public static void addFileToZip(String path, String srcFile, ZipOutputStream zip, boolean flag) throws Exception {
                                File folder = new File(srcFile);
                                if (flag) {
                                                zip.putNextEntry(new ZipEntry(path + "/" +folder.getName() + "/"));
                                }
                                else {
                                                if (folder.isDirectory()) {
                                                                addFolderToZip(path, srcFile, zip);
                                                }
                                                else {
                                                                byte[] buf = new byte[1024];
                                                                int len;
                                                                FileInputStream in = new FileInputStream(srcFile);
                                                                zip.putNextEntry(new ZipEntry(path + "/" + folder.getName()));
                                                                while ((len = in.read(buf)) > 0) {
                                                                                zip.write(buf, 0, len);
                                                                }
                                                }
                                }
                }
}

4.     Test Script for Login:

package com.project.module1;

import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import junit.framework.Assert;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import com.project.testUtil.TestUtil;

public class TS02_Login extends TestUtil {
                public static Logger logger = Logger.getLogger(TS02_Login.class.getName());

                @Parameters("browser")
                @BeforeClass
                public void OpenBrowser(String browser) {
                                if (browser.equalsIgnoreCase("firefox")) {
                                                driver = new FirefoxDriver();
                                } else if (browser.equalsIgnoreCase("chrome")) {
                                                // Set Path for the executable file
                                                System.setProperty("webdriver.chrome.driver",
                                                                                System.getProperty("user.dir")
                                                                                + "src\\test\\resources\\drivers\\chromedriver.exe");
                                                driver = new ChromeDriver();
                                } else if (browser.equalsIgnoreCase("ie")) {
                                                // Set Path for the executable file
                                                System.setProperty(
                                                                                "webdriver.ie.driver",
                                                                                System.getProperty("user.dir")
                                                                                + "src\\test\\resources\\drivers\\IEDriverServer.exe");
                                                driver = new InternetExplorerDriver();
                                } else {
                                                throw new IllegalArgumentException("The Browser Type is Undefined");
                                }
                                // Browser Launch
                                driver.get(config.getProperty("testSiteName"));
                                driver.manage().window().maximize();
                                logger.info("Browser is launched successfully with URL "
                                                                + config.getProperty("testSiteName"));
                }

                @Test(dataProvider = "Login_InvalidEmailid")
                public void Xiim_inValid_Login(String EmailAddress, String password)
                                                throws IOException {
                                try {

                                                driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

                                                getObject("Login_link").click();

                                                logger.info("User Clicked on Login hyper Link");

                                                if (getObject("Login_UN_lbl") != null &&

                                                                                getObject("Login_UN_lbl") != null) {

                                                                typeData("login_UN_txt", EmailAddress);
                                                                logger.info("User Entered Email Address into Email textbox");

                                                                typeData("login_Pwd_txt", password);
                                                                logger.info("User Entered Password into password textbox");

                                                                getObject("login_btn").click();
                                                                logger.info("User Clicked on Login button");

                                                                String Errormsg = getObject("Login_Errormsg").getText();
                                                                logger.info("User Captured the Text as " + Errormsg);
                                                                Assert.assertEquals(Errormsg,
                                                                                                "Error! Please enter a valid Email Address and Password.");

                                                } else {
                                                                System.out.println("Object not found");
                                                }

                                } catch (Exception e) {
                                                String error_msg = e.getMessage().toString();
                                                logger.info(error_msg);
                                                takeScreenShot("Xiim_InValid_Login", "Screenshots", "Login");

                                }
                }

                @Test(dataProvider = "LoginwithValid")
                public void Xiim_Valid_Login(String EmailAddress, String password)
                                                throws IOException {

                                try {
                                                driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

                                                getObject("Login_link").click();

                                                logger.info("User Clicked on Login hyper Link");

                                                if (getObject("Login_UN_lbl") != null &&

                                                                                getObject("Login_UN_lbl") != null) {

                                                                typeData("login_UN_txt", EmailAddress);
                                                                logger.info("User Entered Email Address into Email textbox");

                                                                typeData("login_Pwd_txt", password);
                                                                logger.info("User Entered Password into password textbox");

                                                                getObject("login_btn").click();
                                                                logger.info("User Clicked on Login button");

                                                                Thread.sleep(3000);
                                                                String Welcome = getObject("Xiim_DashBoard").getText();
                                                                logger.info("User Captured the Text as " + Welcome);
                                                                Assert.assertEquals(Welcome, "Dashboard");
                                                            waitForElementPresent("Welcome_UserProfileMenu");
                                                                getObject("Welcome_UserProfileMenu").click();
                                                                getObject("Signout_link").click();
                                                                Thread.sleep(1000);
                                                                // Assert.assertEquals(getObject("Login_link").getAttribute("value"),
                                                                // "Login");

                                                } else {
                                                                System.out.println("Object not found");
                                                }

                                } catch (Exception e) {
                                                String error_msg = e.getMessage().toString();
                                                logger.info(error_msg);
                                                takeScreenShot("Xiim_Valid_Login", "Screenshots", "Login");

                                }
                }

                @AfterClass
                public void close() {
                                logger.info("Closing the Browser instance");
                                driver.close();
                                driver.quit();
                                logger.info("Quiting the Browser Opened");
                }

                @DataProvider(name = "Login_InvalidEmailid")
                public Object[][] Login_ValidData() throws Exception {

                                Object[][] retobjArr = getExcelData(location, sheetname1,
                                                                "LoginwithInavalid", "LoginwithInavalid1");

                                return (retobjArr);
                }

                @DataProvider(name = "LoginwithValid")
                public Object[][] Login_InvalidEmailid() throws Exception {
                                Object[][] retobjArr = getExcelData(location, sheetname1,
                                                                "Loginwithvalid", "Loginwithvalid1");

                                return (retobjArr);
                }

}


5.    ReusableCode:

·        get Object:
Get object concept will use in the test scripts. Like
# Code for getObject:    

   public WebElement getObject(String xpathkey) throws IOException {
                        try {
                                    return         driver.findElement(By.xpath(props.getProperty(xpathkey)));
                        } catch (Throwable t) {
                                    System.out.println("error:\t" + xpathkey);
                                    return null;
                        }
            }
 Here we have to use this method as
getObject(“Xpath given in the property file”).click();
getObject(“Xpath”).getTitle();
getObject(“Xpath”).getText();...etc...in the test scripts
------------------------------------------------------------------------------------------------------

·         waitForElementPopulate : this method will use in case of any
# Code for waitForElementPopulate:    

                      public void waitForElementPopulate(String xpathkey) throws Exception {

                        int i = 0;
                        String expdata = null;
                        while (i <= 20) {
                                    System.out.println(expdata + "\t" + i);
                                    Thread.sleep(2000L);
                                    new Actions(driver).moveToElement(getObject(xpathkey)).click().perform();
                                    getObject(xpathkey).click();
                                    Thread.sleep(2000L);
                                    expdata = getObject(xpathkey).getText().trim();
                                    System.out.println(expdata);
                                    if (expdata != null) {
                                                System.out.println(expdata);
                                                break;
                                    } else {
                                                Thread.sleep(500L);
                                                i++;
                                    }
                        }
            }

Ex: waitForElementPopulate(“xpathkey”);
·        TakeScreenShot:
#Code for takeScreenShot
  public void takeScreenShot(String fileName,String folderName,String Modname ) throws IOException
            {
            File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(scrFile, new File(System.getProperty("user.dir")+"//screenshots//"+folderName+"//"+Modname+"//"+fileName+".png"));              
    }

Ex: takeScreenShot(“Filename”,”folder”,”Modname”);

·         WaitForElementPresent: It will wait for Element present in the Web page. Until the web element present in the web page it will wait.

# Code for WaitForElementPresent:    


       public WebElement WaitForElementPresent(String xpathkey) throws Exception {

                        WebElement present = null;
                        int i = 0;
                        while (i <= 10) {
                                    Thread.sleep(2000L);
                                    present = getObject(xpathkey);
                                    if (present != null) {
                                                break;
                                    } else {
                                                System.out.println("i is: "+i);
                                                i++;
                                    }
                        }
                        return present;
            }

Ex: WaitForElementPresent(“propertyfilexpath”);




·         SelectfromDropDown:  this will select an option from drop down list.

public void selectFromDropdown(String xpathkey, String value) throws Exception{
                        /*waitFor5Seconds();*/
                        WebElement table6 = getObject(xpathkey);
                        List<WebElement> tds6 = table6.findElements(By.tagName("option"));
                        for (WebElement option : tds6) {
                                    if (option.getText().equals(value)) {
                                                option.click();
                                    }
                        }

·         WaitFor5Seconds: it will wait for 5 second to execute a single line or command.
·        # Code for WaitFor5Seconds:    

public void waitFor5Seconds() throws Exception {

                        int i = 0;
                        while (i <= 5) {
                                    Thread.sleep(1000L);
                                    System.out.println("i is: "+i);
                                    i++;
                        }
            }
Ex: waitFor5Seconds();
-------------------------------------------------------------------------------------------------------------------
·         typeData : This  will help you to enter the data in Text field in the web page.
#Code for typeData
      public void typeData(String xpathkey, String value) throws Exception {

                        try {
                                    getObject(xpathkey).sendKeys(value);
                        } catch (Exception t) {
                                    t.printStackTrace();
                        }
            }
Ex: TypeData(“Xpath from propertyfile”,”Value you want to enter into text field”);
·         GetExcelData(“Xpath”,”SheetName”,”TableName1”,”Tablename2”);
  
------------------------------------------------------------------------------------------------------------------

6.     TestUtil :

·         Initialize.
·         Initialize.  Read properties  file data. Like below
 # Code for reading properties:    

    public static void intialize() throws IOException {
                        try {
            Properties props = new Properties();
            FileInputStream fis = new FileInputStream(System.getProperty("user.dir")+"\\src\\OR.properties");
                                    System.out.println(fis);
                                    props.load(fis);
                        } catch (FileNotFoundException e) {
                                    e.printStackTrace();
                        }
      }

****** here we have to create an instance for properties and read through file input stream and load the props file .
7 .
#Code for getExcelData:
                     This method will read the excel data and send the data into text fields in the application.
public String[][] getExcelData(String xlPath, String shtName, String tbName, String tbName1) throws Exception{
                String[][] tabArray=null;
                Workbook workbk = Workbook.getWorkbook(new File(xlPath));
                Sheet sht = workbk.getSheet(shtName);
                int sRow,sCol, eRow, eCol,ci,cj;
                Cell tableStart=sht.findCell(tbName);
                sRow=tableStart.getRow();
                sCol=tableStart.getColumn();
                Cell tableEnd= sht.findCell(tbName1);
                eRow=tableEnd.getRow();
                eCol=tableEnd.getColumn();
                System.out.println("startRow="+sRow+", endRow="+eRow+", " + "startCol="+sCol+", endCol="+eCol);
                tabArray=new String[eRow-sRow-1][eCol-sCol-1];
                ci=0;
                for (int i=sRow+1;i<eRow;i++,ci++){
                  cj=0;
                  /*System.out.println("Row"+i);
                  System.out.println("Column"+sCol);*/
                  for (int j=sCol+1;j<eCol;j++,cj++){
                          /*System.out.println("Row1"+i);
                          System.out.println("Column1"+j);*/
                          tabArray[ci][cj]=sht.getCell(j,i).getContents();
                  }
                }
                return(tabArray);
              }
-----------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------



So far we discussed about TestUtil file....
Now we are going to discuss about the test data.

2.       Test Data :
        This is an excel file which contains Test data to test the application. Please find the sample test data file.


·         GetExcelData(“Location”,”SheetName”,”TableName1”,”Tablename2”);


3.       TestNg.xml
4.       MultiBrowser.xml
5.  <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
6.  <suite name="Parallel test suite">
7.    <test name="Firefox Test">
8.    <parameter name="browser" value="firefox"/>
9.      <classes>
10.       <class name="com.project.module1.TS02_Login"/>
11.       <methods>
12.                         <include name="Xiim_inValid_Login" />
13.                         <include name="Xiim_Valid_Login" />
14.                  </methods>
15.     </classes>
16.   </test>
17.   <test name="Chrome Test">
18.   <parameter name="browser" value="chrome"/>
19.     <classes>
20.         <class name="com.project.module1.TS02_Login"/>
21.         <methods>
22.                         <include name="Xiim_inValid_Login" />
23.                         <include name="Xiim_Valid_Login" />
24.                  </methods>
25.     </classes>
26.   </test>
27.     <test name="Internet Explorer Test">
28.     <parameter name="browser" value="IE"/>
29.     <classes>
30.        <class name="com.project.module1.TS02_Login"/>
31.        <methods>
32.                         <include name="Xiim_inValid_Login" />
33.                         <include name="Xiim_Valid_Login" />
34.                  </methods>
35.     </classes>
36.   </test>
37.   </suite>

5.      Maven : POM.xml


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
       <modelVersion>4.0.0</modelVersion>
       <groupId>SeleniumAutomation</groupId>
       <artifactId>NewFramework</artifactId>

       <version>0.0.1-SNAPSHOT</version>

       <packaging>jar</packaging>

       <name>XiiMed</name>
       <url>http://maven.apache.org</url>

       <properties>
              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       </properties>

       <dependencies>
           <dependency>
       <groupId>net.sf.saxon</groupId>
       <artifactId>saxon</artifactId>
       <version>8.7</version>
</dependency>
<dependency>
       <groupId>net.sf.saxon</groupId>
       <artifactId>Saxon-HE</artifactId>
       <version>9.4</version>
</dependency>
          
           <dependency>
       <groupId>org.uncommons</groupId>
       <artifactId>reportng</artifactId>
       <version>1.1.4</version>
</dependency>

              <dependency>
                     <groupId>com.relevantcodes</groupId>
                     <artifactId>extentreports</artifactId>
                     <version>1.41</version>
              </dependency>
              <dependency>
                     <groupId>net.sourceforge.jexcelapi</groupId>
                     <artifactId>jxl</artifactId>
                     <version>2.6</version>
              </dependency>

              <dependency>
                     <groupId>org.testng</groupId>
                     <artifactId>testng</artifactId>
                     <version>6.8.8</version>
                     <scope>test</scope>
              </dependency>

              <dependency>
                     <groupId>mysql</groupId>
                     <artifactId>mysql-connector-java</artifactId>
                     <version>5.1.31</version>
              </dependency>
              <dependency>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-plugin</artifactId>
                     <version>2.12.4</version>
                     <type>maven-plugin</type>
              </dependency>
              <dependency>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-site-plugin</artifactId>
                     <version>3.3</version>
              </dependency>

              <dependency>
                     <groupId>org.seleniumhq.selenium</groupId>
                     <artifactId>selenium-server</artifactId>
                     <version>2.44.0</version>
              </dependency>
              <dependency>
                     <groupId>org.apache.httpcomponents</groupId>
                     <artifactId>httpclient</artifactId>
                     <version>4.3.5</version>
              </dependency>
              <dependency>
                     <groupId>org.seleniumhq.selenium</groupId>
                     <artifactId>selenium-api</artifactId>
                     <version>2.42.2</version>
              </dependency>
              <dependency>
                     <groupId>org.seleniumhq.selenium</groupId>
                     <artifactId>selenium-firefox-driver</artifactId>
                     <version>2.42.2</version>
              </dependency>
              <dependency>
                     <groupId>org.seleniumhq.selenium</groupId>
                     <artifactId>selenium-java</artifactId>
                     <version>2.44.0</version>
              </dependency>

              <dependency>
                     <groupId>org.apache.poi</groupId>
                     <artifactId>poi</artifactId>
                     <version>3.10-beta2</version>
              </dependency>

              <dependency>
                     <groupId>log4j</groupId>
                     <artifactId>log4j</artifactId>
                     <version>1.2.16</version>
              </dependency>

              <dependency>
                     <groupId>org.apache.poi</groupId>
                     <artifactId>poi-ooxml</artifactId>
                     <version>3.10-beta2</version>
              </dependency>

              <dependency>
                     <groupId>xml-apis</groupId>
                     <artifactId>xml-apis</artifactId>
                     <version>1.4.01</version>
              </dependency>

              <dependency>
                     <groupId>xalan</groupId>
                     <artifactId>xalan</artifactId>
                     <version>2.7.1</version>
              </dependency>

              <dependency>
                     <groupId>javax.mail</groupId>
                     <artifactId>mail</artifactId>
                     <version>1.4</version>
              </dependency>


       </dependencies>
       <pluginRepositories>
              <pluginRepository>
                     <id>reporty-ng</id>
                     <url>https://github.com/cosminaru/reporty-ng/raw/master/dist/maven</url>
              </pluginRepository>
       </pluginRepositories>
       <build>
              <plugins>
                     <plugin>
                           <groupId>org.apache.maven.plugins</groupId>
                           <artifactId>maven-release-plugin</artifactId>
                           <version>2.4</version>

                     </plugin>
                     <plugin>
                           <artifactId>maven-clean-plugin</artifactId>
                            <version>2.6.1</version>

                     </plugin>
                     <plugin>
                           <artifactId>maven-compiler-plugin</artifactId>
                           <version>2.5.1</version>
                     </plugin>
                     <plugin>
                           <groupId>org.apache.maven.plugins</groupId>
                           <artifactId>maven-surefire-plugin</artifactId>
                           <version>2.10</version>
                           <configuration>
                                  <suiteXmlFiles>
                                         <suiteXmlFile>testng.xml</suiteXmlFile>
                                  </suiteXmlFiles>
                           </configuration>
                     </plugin>
              </plugins>
       </build>
       <reporting>
              <plugins>
                     <!-- TestNG-xslt related configuration. -->
                     <plugin>
                           <groupId>org.reportyng</groupId>
                           <artifactId>reporty-ng</artifactId>
                           <version>1.2</version>
                           <configuration>
                                  <!-- Output directory for the testng xslt report -->
                                  <outputDir>/target/testng-xslt-report</outputDir>
                                  <sortTestCaseLinks>true</sortTestCaseLinks>
                                  <testDetailsFilter>FAIL,SKIP,PASS,CONF,BY_CLASS</testDetailsFilter>
                                  <showRuntimeTotals>true</showRuntimeTotals>
                           </configuration>
                     </plugin>
              </plugins>
       </reporting>


</project>



How to run POM.xml through command prompts.











TestNG - Can i use the 2 different data providers to same @test methods in TestNG?

public Object [][] dp1 () { return new Object [][] { new Object [] { "a" , "b" }, new Obje...