Thursday, 18 September 2014

Email XSLT Report Through ANT Automatically

Step -1 : Install ANT and configure from Here


Step -2 : Configure XSLT Report:


1. Download tsetng-xslt-1.1.2.zip file from Here

2. Unzip tsetng-xslt-1.1.2.zip file.

3. Unzip it and copy the testng-results.xsl from testng-xslt1.1.2 folder(testng-xslt1.1.2\src\main\resources\testng-results.xsl). and paste into the project.

4. Now Copy saxon-8.7 and SaxonLiaison library from (testng-xlt1.1.2\lib\saxon-8.7.jar).and paste into the project Jar Folder.

5. Create Build.xml from Here

Step -3 : Sending mail through ANT:


1. Download javax.mail.jar zip from here and javax.activation zip from here
2. Unzip Both file.
3. Copy both jar file and go to your ant lib folder and paste both jar file.
4. In build.xml , I have taken the example of gamil.com and if you may take some other SMTP server and port according to your need. 

How can we run build.xml:


  1. open the command promt .
  2. Go to the your project location.( D:\workspace\GetIt_Project)
  3. Type ant and press enter it is automatically run the build.xml and send the email.

Wednesday, 16 July 2014

Generate XSLT Report With ANT & Test NG

ANT Installation And Configuration :

Step -1 : First of all, we will install the Java in the system from Download Java and download jdk-7u60-windows-i586.exe for window 7.

Step -2 : Download the apache-ant-1.9.4-bin .zip file from http://ant.apache.org/bindownload.cgi

Step -3 : Unzip the downloaded file into C drive.

Step -4 : Set the environment for windows7:

a) Right click on My computer > properties >advanced System setting > Environment Variables> In system variables and Click New>Enter Variable name ANT_HOME and Enter variable value “C:\apache-ant-1.9.4-bin\apache-ant-1.9.4”(Give the path of apache-ant-1.9.4)
b) Again In system variable, go to the path and click edit and add the path of your apache-ant-1.9.4 bin folder “ C:\apache-ant-1.9.4-bin\apache-ant-1.9.4\bin”.

Step -5 : Download testng-xslt-1.1.2 report from download xslt.zip

Step -6 : Unzip it and copy the testng-results.xsl from testng-xslt1.1.2 folder(testng-xslt1.1.2\src\main\resources\testng-results.xsl). and paste into the project.

Step -8 : Now Copy saxon-8.7 and SaxonLiaison library from (testng-xlt1.1.2\lib\saxon-8.7.jar).and paste into the project Jar Folder.

Step -9 : Copy tool.jar file from java jdk and paste into ant library.

Step -10 : Modify your build.xml -


<?xml version="1.0" encoding="UTF-8" ?>
<project name="GetIt_Project" default="sendMail"
basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="project.dir" location="${basedir}" />
<property name="jar.dir"
location="D:\workspace\GetIt_Project\Jars" />
<property name="build.dir" location="${basedir}/build" />
<property name="src.dir" location="${basedir}/src" />
<property name="ng.result" value="test-output" />

<!-- Setting Classpath for jar files -->

<target name="setClassPath">
<path id="classpath_jars">
<pathelement path="${basedir}/" />
<fileset dir="${jar.dir}">
<include name="*.jar" />
</fileset>
</path>
<pathconvert pathsep=":" property="test.classpath" refid="classpath_jars" />
</target>

<!-- Loading Testng -->
<target name="loadTestNG" depends="setClassPath">
<taskdef resource="testngtasks" classpath="${test.classpath}" />
</target>


<!-- Deleting directories -->

<target name="clean">
<echo message="deleting existing build directory" />
<delete dir="${build.dir}" />
</target>

<!-- Creating build folder to store compiled classes -->

<target name="init" depends="clean,setClassPath">
<mkdir dir="${build.dir}" />
</target>


<!-- Compiling java files -->

<target name="compile" depends="clean,init,setClassPath,loadTestNG">
<echo message="" />
<echo message="compiling………." />
<javac destdir="${build.dir}" srcdir="${src.dir}"
includeantruntime="false" classpath="${test.classpath}" />
</target>


<target name="run" depends="compile">
<testng classpath="${test.classpath}:${build.dir}">
<xmlfileset dir="${basedir}" includes="testng.xml" />
</testng>
</target>

<!-- adding XSLT report target to produce XSLT report -->
<target name="makexsltreports" depends="run">

<delete dir="${project.dir}/XSLT_Reports/output">
</delete>
<mkdir dir="${project.dir}/XSLT_Reports/output" />

<xslt in="${ng.result}/testng-results.xml" style="${basedir}/testng-results.xsl"
out="${project.dir}/XSLT_Reports/output/index.html" classpathref="classpath_jars"
processor="SaxonLiaison">
<param name="testNgXslt.outputDir" expression="${project.dir}/XSLT_Reports/output/" />
<param name="testNgXslt.showRuntimeTotals" expression="true" />
<param expression="true" name="testNgXslt.sortTestCaseLinks" />
<param expression="FAIL,SKIP,PASS,CONF,BY_CLASS" name="testNgXslt.testDetailsFilter" />
</xslt>
<!-- <echo message="This is a message" />-->
</target>

<!-- using javax.mail.jar and javax.activation.jar trying to send report as zip file -->

<target name="sendMail" depends="makexsltreports">

<!-- Compressing all the output file of XSLT report -->
<zip destfile="${project.dir}/XSLT_Reports/output.zip" basedir="${project.dir}/XSLT_Reports/output" />

<mail
tolist="persia.scorpio@gmail.com"
from="persia.scorpio@gmail.com"
subject="Email subject"
mailhost="smtp.gmail.com"
mailport="465"
ssl="true"
user="test@gmail.com"
password="8826181801">
<attachments>
<fileset dir="${project.dir}/XSLT_Reports/">
<include name="**/*.zip"/>
</fileset>
</attachments>

</mail>

</target>
</project>


How can we run build.xml:

  1. open the command promt .
  2. Go to the your project location.( D:\workspace\GetIt_Project)
  3. Type ant and press enter it is automatically run the build.xml.



Monday, 30 June 2014

Paramerization With Selenium

Parameterization in Selenium: In the most cases you will come across the scenario where the business logic requires a hugely varying number of test cases. Basically parameterized tests allow to developer to run the same over and over again using different values.

Test NG lets you pass parameters directly to your test method in two different ways:
  • With testng.xml
  • With Data Provider
    We define the simple parameters in the testng.xml file. When you need to pass complex parameters or parameters that need to be created from java (complex object ,object read from the properties file or database etc.) in such cases parameters can be pass using Data Providet.
package packageName;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.annotations.AfterMethod;


public class ClassName {
WebDriver driver;
private String baseurl;
@Test(dataProvider = "getData")
public void gmailverify(String username, String pwd,String message) throws InterruptedException {
System.out.println(username+"----"+pwd+"---"+message);
WebElement userName = driver.findElement(By.xpath(".//*[@id='Email']"));
userName.clear();
userName.sendKeys(username);
WebElement Password = driver.findElement(By.xpath(".//*[@id='Passwd']"));
Password.clear();
Password.sendKeys(pwd);
driver.findElement(By.xpath(".//*[@id='signIn']")).submit();
Thread.sleep(2000);
String msg = driver.findElement(By.className("error-msg")).getText();
Assert.assertEquals(message, msg);
}
@BeforeTest
public void setUp() {
driver = new FirefoxDriver();
baseurl = "http://www.gmail.com/";
driver.get(baseurl);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

@AfterMethod
public void tearDown() {
// driver.quit();
}

@DataProvider
public Object[][] getData(){
Object[][] data = new Object[3][3];
data[0][0]= "sdfsf";
data[0][1]="Pass@123";
data[0][2]="The email or password you entered is incorrect. ?";
data[1][0]=" ";
data[1][1]="word@123";
data[1][2]="Enter your email address.";
data[2][0]="tommy_...@gmail.com";
data[2][1]=" ";
data[2][2]="Enter your password.";
return data;
}

}

Sunday, 29 June 2014

Test NG With Selenium

What is Test NG ? :We are using Test NG with Selenium For execution of multiple test cases and generate the XSLT report format . Test NG is an Open Source Automated Testing framework , where NG of Test NG means Next Generation . Test NG is similar to Junit but its not a Junit extension. It is designed to better than Junit.


Feature of Test NG -

  1. Test NG uses more java and OO feature.
  2. Annotation.
  3. It is flexible with testing integrated classes. It means we don't need to create new test classes instance for every test method.

How To configure Test NG with selenium :

  1. Open the Eclipse.
  2. Go to the Help> Install New Software > Add and give the name of the plug in is Test NG and Enter the url: http://beust.com/eclipse
  3. Install the Test NG with eclipse.


    How can we run Test NG with Eclipse:

1.create a new package in your Project src folder.
2. create a new class in new created package.


@Test
public void TestcasesName()
{

// Here you can write your test cases .
baseurl = "http://google.com";
FirefoxDriver driver = new FirefoxDriver();
driver.get(baseurl);
if(driver.getTitle().contains("Google"))
System.out.println("Test passed");
else
System.out.println("Test Failed");

}
Note :
  1. When we are using first time Test NG the we are add the Test NG library into the @Test .
  2. Import the Test(import org.testng.annotations.Test;) into the @Test.
  3. Run The java Program Test with Test NG.
  4. Find the all test result with summary.

Show the summary report:

  1. Refresh the java project. And test output folder is visible at the bottom of the project Explorer.
  2. Open the index.html file from test output folder

Saturday, 21 June 2014

Selenium Tool Installation

Prerequisites Tool:

1. Java
2. Eclipse 
3. Selenium Tool
Selenium Tool is using for testing automation on the web and we can easy to automate the web application.We are using three type of selenium.
1. Selenium IDE
2. Selenium RC
3. Selenium WebDriver
We can automate the web application on different browsers like as Firefox, Google Chrome, Internet Explorer, Opera etc.


 STEP -1 :  JAVA Installation : Before eclipse installation we will need to java and we can download the java from https://www.java.com/en/download/


STEP -2 :  Eclipse SDK Installation :  We use the eclipse sdk to automate the android application.We will no need to install the eclipse sdk , just unzip the downloaded folder anywhere in local drive. After the downloading of the eclipse we will execute the  eclipse.exe file and define the workplace folder of eclipse anywhere in local drive. we can download the eclipse sdk from -

DOWNLOAD URL:  http://www.eclipse.org/epsilon/download/

How can we create a New Project from eclipse
a) Open the eclipse.
b) We will go the File>New>Java Project

STEP -3: Install the Selenium : Selenium is basically work with six programming language like as Java, PHP, Perl, Python, Ruby and C#.So we will choose any one specific language for the project.We can download the Selenium from http://docs.seleniumhq.org/download/ . After download we will just unzip the downloaded folder anywhere in local drive.

STEP -4: Configure eclipse project with Selenium: We will open the eclipse project and add all selenium jar files into your project.

a) Right click on your eclipse Project.
b) Choose the path Properties> Java Build Path>Libraries>Add External Jars>select all Jar file from download selenium folder.

 Write first java program with selenium web automation:

a) Create a New Package in your Project  : Right click on Project folder and Choose Path New>Package>Enter the Package Name according to your project.

b) Create a New Class in your Project  : Right click on Project folder and Choose Path New>Class>Enter the Class Name according to your project.

Write a first automation program-

package name;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;



public class name {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
driver.get("http://google.com");

}

}








Thursday, 19 June 2014

How to configure the monkey talk for Android Mobile Automation


STEP -1: Import your targeted automation project into Eclipse:

a) Open the Eclipse Project.
b) You must have source code of your targeted  automation apps. 
c) Then we will go the File>Import>Existing Project into Workplace>Select your project location and import it.


STEP -2: Configure your project with Aspect J Plug-in:

a) Right click on your project 
b) And go the Configure>Convert To Aspect J Plug-in.

STEP -3 : Add Monkey Talk library info your project:

a) First of all  open your Monkey Talk unzip folder.
b) And we will go the agent\android\monkeytalk-agent-2.0.4 . 
c) Copy monkeytalk-agent-2.0.4  jar file.
d) Then paste into your project lib folder
e)  We will add to Aspect path into your monkey talk library so right click on monkey talk library and choose the path Aspect Tool>Add To Aspect  path.


STEP -4: Configure Java Build Path:
a) Open the eclipse.
b) Right click on your project and go the Properties>Java Build Path>Select Aspect J Run time library
c) Click on ok.


STEP -5: Configure the permission with your Eclipse Project:


a) We will give the permission for GET_TASK and INTERNET to eclipse project.
b) We will open the eclipse project and open the Manifest.xml file
c) Then we will go to the permission tab and click on add .
d) Select user permission  and give the permission for
android.permission.GET_TASKS
android.permission.INTERNET

Write a first UI Monkey Talk Script for Sign In Form : 

Label enterEmailPsw verify "Please enter your credentials"
Input Username verify
Input Password verify
Button #1 verify " SIGN IN"
Button #2 verify CANCEL





Wednesday, 18 June 2014

Testing Automation : Monkey Talk Tool For Mobile Automation

HOW TO INSTALL MONKEY TALK :

Pre-requisites Tools:


  1. Eclipse SDK
  2. Android SDK
  3. ADT Plug-in for Eclipse
  4. Monkey Talk Tool
  5. AJDT (For Aspect J Conversion)
  6. PDANET
  7. WINDOW 7 
  8. JAVA

STEP -1 :  JAVA Installation: Before eclipse installation we will need to java and we can download the java from https://www.java.com/en/download/

STEP -2 :  Eclipse SDK Installation :  We use the eclipse sdk to automate the android application.We will no need to install the eclipse sdk , just unzip the downloaded folder anywhere in local drive. After the downloading of the eclipse we will execute the  eclipse.exe file and define the workplace folder of eclipse anywhere in local drive. we can download the eclipse sdk from -
DOWNLOAD URL:  http://www.eclipse.org/epsilon/download/

How can we create a New Project from eclipse
a) Open the eclipse.
b) We will go the File>New>Project


STEP -3 :How can we add the ADT Plug-in with Eclipse:


a) Open the eclipse and choose path Help>install new software> click ADD
b) Enter the name of Plug-in (ADT Plug -in ) and Type the download url  https://dl-ssl.google.com/android/eclipse/
c) After Install ADT Plug-in We should restart the eclipse.

STEP -4 : AJDT (For Aspect J Conversion):

Note:We will download Aspect J  according to your eclipse version.
a) Open the eclipse and choose path Help>install new software> click ADD
b) Enter the name of Plug-in (AJDT Plug -in ) and Type the download url  http://download.eclipse.org/tools/ajdt/43/update 
c) After Install AJDT Plug-in We should restart the eclipse.


 STEP -5 : Android SDK Installation:


a) We can download the Android SDK from-
     DOWNLOAD URL : http://developer.android.com/sdk/index.html#download
b) After download the zip file ,just unzip downloaded folder anywhere in local drive.
c) Open the unzip folder and execute the SDK Manager.exe file
d) Select the no. of packages according to your project requirement and install it.
e) We use the AVD Manager for create new virtual device (emulator).
f) Then execute the AVD Manager.exe file from unzip android sdk folder.

STEP -6 : Monkey Talk Installation : We  will no need to install the Monkey Talk,just unzip the downloaded folder anywhere in local drive.
DOWNLOAD URL : https://www.cloudmonkeymobile.com/download/monkeytalk-professional
Note: Always download monkey talk with New register user.

How can we create new project from Monkey Talk:


a) We can define the workplace anywhere in local drive but it should different from eclipse workplace folder.
b) Then we will go the File >New>Project and give the any name of your project.
c) Click on Finish.


How can we show the element of Monkey Talk like as Console , Component Tree, Project Explorer :


a) We will go the Window>show View>Other>Select Project Explorer.
b) We will go the Window>show View>Other>Select Component Tree.
c)We will go the Window>show View>Other>Select Console.



STEP -7 : PDAnet 

DOWNLOAD URL : http://junefabrics.com/android/downloadold.php 
install the PdaNet mobile client on your Android. Then, connect your Android phone using the USB cable, and your computer should pick up the data connection from your phone and be able to piggyback on that.