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.