Saturday, October 19, 2013

Smoke Vs Sanity Vs Regression Beautiful Example

We can consider a River Analogy to understand the difference between Smoke Testing, Sanity Testing and Regression Testing better. Before moving to the analogy, lets consider the very basic definition of three of these testing:
  • Smoke Testing: Testing all (wide) areas related to new feature, not deeply. Determines if we should go for further testing.
  • Sanity Testing: Testing narrow areas related to new feature, deeply.
  • Regression testing: Testing all areas related to new feature, deeply.
If we consider a river, for instance, which has, for instance 1000 feet width, and contains “dusts” in its water (which can be considered as “bugs” in software), the goal for the corresponding three types of tests should be as follows:



For Regression Testing: to find out all the dusts that are available on surface and under the water in all over the river.

"Testing all areas related to the new features deeply."


For Smoke Testing: to find out the dusts in all over the surface of the river, which not includes the dusts under water.

"Testing all (Wide) areas related to the new features, Not deeply. It determines if we should do further testing."


For Sanity Testing: to find out the dusts in a specific width (for instance left side 200 feet), which not only includes the dusts on surface, but also includes the dusts under water, till the last depth of the river.

"It is same as regression testing but here you make a risk judgement call and compromise part of your testing."


Thursday, August 1, 2013

Automate the Calendar component in Selenium WebDriver using JAVA.

package TestOpt;

import java.util.Calendar;
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;

interface Xpaths
{
/*
* This inteface contains all the xpath's that are used in the program
*/
String calendarPopUpButtonxPath = "//*[@id='j_id354:j_id355PopupButton']";
String monthIncrementerxPath = "//*[@id='j_id354:j_id355Header']/table/tbody/tr/td[4]/div";
String monthDecrementerxPath = "//*[@id='j_id354:j_id355Header']/table/tbody/tr/td[2]/div";
String dayxPathPart1 = "//*[@id='j_id354:j_id355DayCell";
String dayxPathPart2 = "']";
String dayZeroxPath = "//*[@id='j_id354:j_id355DayCell0']";
String applyButtonxPath = "//*[@id='j_id354:j_id355Footer']/table/tbody/tr/td[6]/div";
}

interface Months
{
int JANUARY   = 1,
FEBRUARY  = 2,
MARCH     = 3,
APRIL     = 4,
MAY       = 5,
JUNE      = 6,
JULY      = 7,
AUGUST    = 8,
SEPTEMBER = 9,
OCTOBER   = 10,
NOVEMBER  = 11,
DECEMBER  = 12;
int MAX_DAY_IN_A_MONTH = 31;
}

public class AutomateJsfCalendar implements Xpaths,Months
{
/**Months
* @param args
*/
static int targetDay     = 0,
          targetMonth   = 0,
          targetYear    = 0;
static int currentDay    = 0,
          currentMonth  = 0,
          currentYear   = 0;
static int jumpMonthsBy  = 0,
              index = 0;

static boolean increment = true;
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.navigate().to("http://livedemo.exadel.com/richfaces-demo/richfaces/calendar.jsf");
driver.manage().timeouts().implicitlyWait(15L, TimeUnit.SECONDS);
driver.manage().window().maximize();
WebElement element = driver.findElement(By.xpath(calendarPopUpButtonxPath));
element.click();
//At this point, jsf calendar component is displayed.
//Today's date is 30/03/2013. Let us say we want to set the date as 15/07/2013
String dateToSet = "15/07/2013";

GetTargetDateMonthAndYear(dateToSet);
GetCurrentDateMonthAndYear();
CalculateHowManyMonthsToJump();
for(int i=0;i<jumpMonthsBy;i++)
{
if(increment)
element = driver.findElement(By.xpath(monthIncrementerxPath));
else
element = driver.findElement(By.xpath(monthDecrementerxPath));
element.click();
try
{
//sleep will let you see the automation happening.
Thread.sleep(1000);
} catch (InterruptedException e)
{
e.printStackTrace();
}
}
CalculateCorrectDayIndex(driver);
String completePath = dayxPathPart1 + index + dayxPathPart2;

element = driver.findElement(By.xpath(completePath));
element.click();
element = driver.findElement(By.xpath(applyButtonxPath));
element.click();

  //driver.quit();
}//end of main..
/*
*This method will bisect the target date and upadates  targetDay, targetMonth & targetYear variables.
*/
static void GetTargetDateMonthAndYear(String dateString)
{
int firstIndex = dateString.indexOf("/");
int lastIndex = dateString.lastIndexOf("/");
String month = dateString.substring(0, firstIndex);
targetDay = Integer.parseInt(month);
String day = dateString.substring(firstIndex+1, lastIndex);
targetMonth = Integer.parseInt(day);
String year = dateString.substring(lastIndex+1, dateString.length());
}
/*
* This method will fetch current date and updates currentDay, currentMonth & currentYear variables.
*/
static void GetCurrentDateMonthAndYear()
{
Calendar cal = Calendar.getInstance();
currentDay   = cal.get(Calendar.DAY_OF_MONTH);
currentMonth = cal.get(Calendar.MONTH)+1;//+1 because month values starts from 0. January = 0.
currentYear  = cal.get(Calendar.YEAR);
}
/*
* This method decides how many time this ">" element on the calendar component needs to be clicked to reach target month.
*/
static void CalculateHowManyMonthsToJump()
{
if((targetMonth - currentMonth) > 0 )
{
jumpMonthsBy = (targetMonth - currentMonth);
}
else
{
jumpMonthsBy = (currentMonth - targetMonth);
increment = false;
}
}

/*
* This calculates the current index that holds the targetDay value that we need to click in the calendar control.
*/
static void CalculateCorrectDayIndex(WebDriver driver)
{
int tempMonth = targetMonth - 1;
if(tempMonth == 0)
{
//if target month is January, control will come inside.
tempMonth = DECEMBER;
}
WebElement element = driver.findElement(By.xpath(dayZeroxPath));
String str = element.getText();
int dayValueAtZeroIndex = Integer.parseInt(str);

if(dayValueAtZeroIndex == 1)
{
index = targetDay - 1;
}
else
{
switch(tempMonth)
{
case JANUARY:
case MARCH:
case MAY:
case JULY:
case AUGUST:
case OCTOBER:
case DECEMBER:
{
index = ((MAX_DAY_IN_A_MONTH - dayValueAtZeroIndex) + targetDay);
break;
}
case FEBRUARY:
{
/*
* Separate case is needed for feb because Feb contains only 28(MAX_DAY_IN_A_MONTH - 3) days.
*/
index = (((MAX_DAY_IN_A_MONTH - 3) - dayValueAtZeroIndex) + targetDay);
break;
}
default:
{
//Control will come here for months that consists of 30(MAX_DAY_IN_A_MONTH - 1) days.
index = (((MAX_DAY_IN_A_MONTH - 1) - dayValueAtZeroIndex) + targetDay);
break;
}
}
}
}
}//end of class.

Selenium Solutions: Purpose: Selecting any date from JQuery Date Picke...

Selenium Solutions: Purpose: Selecting any date from JQuery Date Picke...: Purpose: Selecting any date from JQuery Date Picker using Selenium Web Driver Automating JQuery Date Picker is not as easy as selecting Da...

Wednesday, June 12, 2013

Selenium Web Driver Command List

Command;                                                       Description

driver.get("http://www.google.com"); To open an application
driver.findElement(By.id("passwd-id")); Finding Element using Id
driver.findElement(By.name("passwd")); Finding Element using Name
driver.findElement(By.xpath("//input[@id=’passwd-id’]")); Finding Element using Xpath
element.sendKeys("some text"); To type some data
element.clear(); clear the contents of a text field or text area
driver.findElement(By.xpath("//select")); Selecting the value
select.findElements(By.tagName("option")); Selecting the value
select.deselectAll(); This will deselect all Option's from the first SELECT on the page
select.selectByVisibleText("Edam"); select the OPTION with the displayed text of “Edam”
findElement(By.id("submit")).click(); To click on Any button/Link
driver.switchTo().window("windowName"); Moving from one window to another window
driver.switchTo().frame("frameName"); swing from frame to frame (or into iframes)
driver.switchTo().frame("frameName.0.child"); to access sub-frames by separating the path with a dot, and you can specify the frame by its index too.
driver.switchTo().alert(); Handling Alerts
driver.navigate().to("http://www.example.com"); To Navigate Particular URL
driver.navigate().forward(); To Navigate Forward
driver.navigate().back(); To Navigate Backward
driver.close() Closes the current window
driver.quit() Quits the driver and closes every associated window.
driver.switch_to_alert() Switches focus to an alert on the page.
driver.refresh() Refreshes the current page.
driver.implicitly_wait(30) Amount of time to wait
driver.set_script_timeout(30) The amount of time to wait
driver.get_screenshot_as_file('/Screenshots/foo.png') The full path you wish to save your screenshot to
driver.get_screenshot_as_base64() Gets the screenshot of the current window as a base64 encoded string which is useful in embedded images in HTML

Saturday, March 9, 2013

Difference between keyword driven and data driven framework ?

Data-Driven Testing
Simple test scripts have test data embedded into them. This leads to a problem that when test data needs to be updated actual script code must be changed. This might not be a big deal for the person who originally implemented the script but for a test engineer not having much programming experience the task is not so easy. If the script is long and non-structured the task is hard for everyone. Another problem with having the test data inside test scripts is that creating similar tests with slightly different test data always requires programming. The task may be easy original script can be copied and test data edited but at least some programming knowledge is still required. This kind of reuse is also problematic because one particular change in the tested system may require updating all scripts. Because of these problems embedding test data into scripts is clearly not a viable solution when building larger test automation frameworks. A better approach is reading the test data from external data sources and executing test based on it. This approach is called data-driven testing External test-data must be easily editable by test engineers without any programming skills. It is often in tabular format and edited in spreadsheet programs.

Keyword-Driven Testing
Previous section introduced data-driven testing and stated that it has multiple promises. It also mentioned that its biggest limitation is that all test cases are similar and creating totally new tests requires programming effort. A solution for this limitation, among others, is the keyword-driven approach where not only the test data but also directives telling what to do with the data are taken from test scripts and put into external input files. These directives are called keywords and test engineers can use them to construct test cases freely. The basic idea reading test data from external files and running tests based on it stays the same as in data-driven testing. keyword-driven testing is a logical extension to data-driven testing. 


Data Driven Framework :
It is nothing but data driven test, performing the same functionality with multiple input values by using parametrization with the help of data table or data source is called Data Driven Test.

Keyword Driven Framework :
It is nothing but keyword driven test or keyword view, used for parametrization.
It is dividing into 4 parts.
1. item     2. operation     3. value      4. documentation     ----> in QTP 8.2
In QTP 6.5 keyword view is nothing but Tree View. It displays the list of objects along with logical names.

Parametrization:
passing the run-time input values with the help of data-table or data-source is called parametrization.
Any queries

prashantlogic@gmail.com

Monday, January 21, 2013

Difference Between JUnit And TestNG Annotations



Difference Between JUnit And TestNG Annotations

Features JUnit Annotations TestNG Annotations
Test annotation. @Test @Test
Run before all test in this suite have run. -- @BeforeSuite
Run after all test in this suite have run. -- @AfterSuite
Run before the test. -- @BeforeTest
Run after the test. -- @AfterTest
Run before the first test method that belongs to any of these group is invoked. -- @BeforeGroup
Run after the last test method that belongs to any of these group is invoked. -- @AfterGroup
Run before the first test method in the current class is invoked. @BeforeClass @BeforeClass
Run after all the test method in the current class have been run. @AfterClass @AfterClass
Run before each test method. @Before @BeforeMethod
Run after each test method. @After @AfterMethod
IgnoreTest @ignore @Test(enable=false)
Expected Exception @Test(Expected=ArithmeticException.Class) @Test(ExpectedExceptions=ArithmeticException.Class)
TimeOut @Test(timeout=1000) @Test(timeout=1000)
Thanks From Prashant Chauhan

5 Questions You Should Never Ask in a Job Interview


Could these words be costing you your dream job?

By Catherine Conlan, Monster Contributing Writer

Hiring managers and HR pros will often close out a job interview by asking an applicant if he or she has any questions themselves. This is a great opportunity to find out more about the job and the company's expectations, but you can't forget that the interviewer hasn't stopped judging YOU. Here are 5 questions that can make a bad impression on your interviewer, scuttling your chances for getting the job.

1. When will I be promoted ?


This is one of the most common questions that applicants come up with, and it should be avoided, says Rebecca Woods, Vice President of Human Resources at Doherty Employer Services in Minneapolis. "It's inappropriate because it puts the cart before the horse."  Instead of asking when the promotion will occur, Woods says a better approach is to ask what you would need to do to get a promotion.

2. What's the salary for this position ?


Asking about salary and benefits in the first interview "always turns me off," says Norma Beasant, founder of Talento Human Resources Consulting and an HR consultant at the University of Minnesota. "I'm always disappointed when they ask this, especially in the first interview." Beasant says the first interview is more about selling yourself to the interviewer, and that questions about salary and benefits should really wait until a later interview.

3. When can I expect a raise ?


Talking about compensation can be difficult, but asking about raises is not the way to go about it, Woods says. So many companies have frozen salaries and raises that it makes more sense to ask about the process to follow or what can be done to work up to higher compensation level. Talking about "expecting" a raise, Woods says, "shows a person is out of touch with reality."

4. What sort of flextime options do you have ?


This kind of question can make it sound like you're interested in getting out of the office as much as possible. "When I hear this question, I'm wondering, are you interested in the job?" Beasant says. Many companies have many options for scheduling, but asking about it in the first interview is "not appropriate," Beasant says.

5. Any question that shows you haven't been listening. 


Woods said she interviewed an applicant for a position that was 60 miles from the person's home. Woods told the applicant that the company was flexible about many things, but it did not offer telecommuting. "At the end of the interview, she asked if she would be able to work from home," Woods says. "Was she even listening? So some 'bad questions' can be more situational to the interview itself."

With the economy the way it is, employers are much more choosy and picky, Beasant says. Knowing the questions to avoid in an interview can help you stand out -- in a good way.


Thursday, January 10, 2013

The Difference Between Cookies and Sessions.

The main difference between cookies and sessions is that cookies are stored in the user's browser, and sessions are not. This difference determines what each is best used for.

A cookie can keep information in the user's browser until deleted. If a person has a login and password, this can be set as a cookie in their browser so they do not have to re-login to your website every time they visit. You can store almost anything in a browser cookie. The trouble is that a user can block cookies or delete them at any time. If, for example, your website's shopping cart utilized cookies, and a person had their browser set to block them, then they could not shop at your website.

Sessions are not reliant on the user allowing a cookie. They work instead like a token allowing access and passing information while the user has their browser open. The problem with sessions is that when you close your browser you also lose the session. So, if you had a site requiring a login, this couldn't be saved as a session like it could as a cookie, and the user would be forced to re-login every time they visit.

You can of course get the best of both worlds! Once you know what each does, you can use a combination of cookies and sessions to make your site work exactly the way you want it to.