Showing posts with label Tools. Show all posts
Showing posts with label Tools. Show all posts

Monday, May 12, 2014

How to pass the Data to test script through xml or How to use @Parameters in TestNG ?

Ans- use @Parameters to pass the input through xml.

Ex-

import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class PassInputThruXML {
@Test
@Parameters({"para1","para2"})
public void passInput(String para1, double para2){
    System.out.println(para1);
    System.out.println(para2);
}
}


testng.xml->


<suite name="Suite" parallel="none">
  <test name="Test">
    <parameter name="para1" value="selenium-makeiteasy" />
    <parameter name="para2" value="5.0" />
      <classes>
          <class name="TestNg.PassInputThruXML"/>
      </classes>
  </test>
</suite>

Integrate Automation framework with Build using Jenkins.

‘Jenkins’ is a tool which is used for continuous integration testing.

Please follow the below steps to configure the Jenkins with your Automation Framework-

Step1- click on this link : http://jenkins-ci.org/
Step2- click on ‘Long term support release’ tab which is there in right side.
Step3- click on 'older but stable' then one pop-up will come to save the file & there in pop-up click ‘OK’ which will save Jenkins the war file in the Downloads folder, copy paste the downloaded file inside the project.
Step4- Open the command prompt (cmd) and go to project directory.
For ex- say your project directory is -> C:\selenium\SpiceJet\Owler
so here you open cmd, then give command as cd C:\selenium\SpiceJet\Owler and hit enter
Step5- Then type the command ‘java –jar jenkins.war’ & hit enter.
Step6- If Jenkins server is loaded successfully it will display following message in command prompt.      Jenkins is fully up and running

Step7- Now open the browser & enter the following URL in the address bar “local host:8080” which will display homepage of the Jenkins server.
Step8- Click on New Job & specify the job name
For ex: AutomationFramework
Step9- Select the first radio button ‘Build a free-style software project’ then click on OK.
Step10- Click on ‘Advanced’ & select last checkbox 'use custom workspace' under ‘Advanced Project options’ section.
Step11- Type the java project path in the directory (For ex- the java project path –
C:\selenium\SpiceJet\Owler)
Step12- Go down, There you will find Build section, there click on ‘Add Build Step’ & select ‘Execute Windows Batch Command’ & type ‘RunMe.bat’ in the command field.
**How to create RunMe.bat file -
             a) open notepad
             b) paste this command- java -cp bin;jars/* org.testng.TestNG testng.xml
             c) save the file as RunMe.bat
Step13- Go down and click on Save button.
Step14- Now you are all set to use Jenkins. Click on Build Now. It will start the execution of your framework.
Note- In order to create a Build, Developer clicks on ‘Build Now’ which will start the Build creation process once the build is created it will start Framework execution automatically. Every time when we run the build, Jenkins will display a link under Build History, the name of the link will be current system Date & Time, when we click that link it will take us to Build details page where if we click on ‘Console output’ link it will display output of the Automation Framework which is printed on the command prompt.

Please find snapshot below, where you should put .bat file and jenkins.war

screenshot of project

Please leave your valuable feedback. Thanks!!

Saturday, May 10, 2014

What is the command to run the testng.xml or How to save bat file to excute textng.xml

step1. open notepad.
step2. paste this command
           java -cp bin;jars/* org.testng.TestNG testng.xml

step3. save this as filename.bat and put it inside the project directory.
step4. Now to execute the script through testng.xml , open the project and click on this bat file.
This will open the cmd and will run the entire suite.

Friday, May 9, 2014

ANT Build Tool

ANT Build Tool

Ant is a build tool which is used to create a build for a particular application. By default ant triggers build.xml. Apache Ant is a Java library and command-line tool that help building software.

Steps to download ANT and install ANT

1) Download the latest apache ant from this link     https://ant.apache.org/bindownload.cgi
     (download - .zip archive: apache-ant-.......) 
2) Extract the downloaded apache ant -> Copy the folder -> go to C:  drive and paste it.
3) Go to my computer -> right click -> properties -> advanced system setting -> environment variables -> under system variables -> search for variable 'path' and click on edit.
4)  Go to C: drive, open apache and go to till bin folder (i.e. open bin folder then copy the path) then copy the complete path.
5) Under environment variable go to end of line insert ; (semi-colon) and paste the path. Click on Ok just one time.
6) Under system variable click on new, and give the variable name as ANT_HOME. Under variable value: paste the path till parent of bin(don't open bin folder). Again click on Ok just one time.
7) Under system variable again click on new, give the variable name as JAVA_HOME. Under variable value paste the path till the parent of bin folder of JDK. (from Program Files(x86) or Program Files).
8) Click on 3 times ok.
9) To confirm ANT is installed or not, go to cmd and type -> ant -version
You will get something like depends on your version-> Apache Ant(TM) version 1.9.3 compiled on December 23 2013



10) Now you have done with the installation, so lets go to use it now.

How to use ANT tool

1) Write the build.xml inside the project (for example take this project- LinkedIN_Project_By_POM).
Note- Only change the project name as your project name in the above given build.xml and directly you can use the same.

Below is the snap shot of project-



2) Open cmd and give the path of build.xml
3) Type ant and hit enter.



4) It will create a folder inside project as build and run all the test cases and will give the report in cmd screen.