Sunday, 24 April 2016

Write Positive and Negative test cases for login page

This is one of frequent question asked by interviewer. In order to answer this question, you need to understand the difference between what a positive test case and a negative test case is.

  •       A positive test case confirms some expected functionality. E.g.: A user with a valid username and the corresponding password can log in successfully.
  •      A negative test case tests for unexpected or invalid conditions, and confirms that the code can hold up in these circumstances. 
·         Positive Test Case
               1.       Verify the Correct username, Correct password - Login Successfully.
·         Negative Test Cases
                            1.       Verify the Incorrect username, incorrect password- Can't Login
                            2.       Verify valid username and empty password. -Can't Login
                            3.       Verify empty username and valid password. - Can't Login
                            4.       Verify some password(can be a registered/unregistered)- Can't Login
                            5.       Verify case changed username /password.- Can't Login
                            6.       Verify registered user's login id and password -Can't Login
                            7.       Verify registered username and password.- Can't Login
                            8.       Verify to enter disable(Blocked) email address.- Can't Login
                    9.     Verify to unverified Email address. - Can't Login

Wednesday, 13 April 2016

How To Continue With Script Even If NoSuchElement Exception is Thrown

The Problem
If you selenium script fails to find element on page by provided locator, it throws NoSuchElement exception. NoSuchElement is an exception which is basically like crashing the program into a wall. Whenever this error comes, script execution gets stopped.

A Solution
As an automation developer, I can ensure uninterrupted script execution in two ways
1.       Using try/catch block

Let’s try to implement it in an example –

NoSuchElement error without Try/Catch Handling
     public static void main(String[] args) {
                                WebDriver driver = new FirefoxDriver();

                                driver.get("http://thebuddhatree.blogspot.in/");

                                driver.findElement(By.id("name")).click();
                }

Note – This program will generate error and script execution gets stopped if element with provided locator is not on page.

NoSuchElement error with Try/Catch Block

import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class NoSuchElementError {

                public static void main(String[] args) {
                                WebDriver driver = new FirefoxDriver();
                                driver.get("http://thebuddhatree.blogspot.in/");
                                try {
                                                driver.findElement(By.id("name")).click();
                                } catch (NoSuchElementException e) {
                                                System.out.println("In Catch Block");
                                }
                                System.out.println("Outside Block, resume executing other code");
                }
}

Note – This program will generate error but script execution will continue for remaining code.

2.       Using FindElements() method
Build into Selenium is an ability to search multiple elements using single action
findElements() method behavior can be summarized as follows  -

·         On Zero Match : return an empty list
·         On One Match : returns list of one WebElement only
·         On One+ Match : returns list with all matching elements

NoSuchElement error using FindElements()
public static void main(String[] args) {
                                WebDriver driver = new FirefoxDriver();
                                driver.get("http://google.in/");
                               
                                List <WebElement> elements  =driver.findElements(By.id("name"));
                                if (elements.size() == 0){
                                                System.out.println("Element Not Found");
                                }
                }
Expected Behavior
  • ·         Open the Browser
  • ·         Load the page
  • ·         Search for an element
  • ·         Fails to find element
  • ·         Script execution continued

Conclusion
Happy Learning

Please ask questions on Testing Forum, in case of any issues or doubts or questions.

Saturday, 9 April 2016

Fundamental Requirements For an Entry Level QA Engineer

There are different types of roles in Software industry - like problem-solving, problem-finding, problem-defining. As a general rule, programmers focus on solving problems, where testers or QA Engineer focus on finding and defining problems. In other words, QA Engineer focus tends to be more "did we build the right it". If you love finding & defining problems, welcome to world of QA Engineers.

That said, there are generalities I would consider for entry-level QA positions:
·         Ability to communicate and prioritize - QA people needs to create bug reports and convince others that the problems they reported need to be fixed. They are also needed to evaluate the severity of any problems they run into. You need to be good in verbal & written communication and explain defects in simple terms.
·         Fast learner - no matter what level or domain of software QA someone starts at, there's a large learning curve.
·         Any kind of programming skill is a bonus because it helps in automating tests. As of now,  most IT companies require all of their QA resources to write test automation code
·         Analytic mindset
·         Be Curios & Ability to research
·         Ability to multitask and adapt to a constantly changing environment
·         Build good rapport with Developer, it helps you understanding working of application
·         Ability to take decision, as a QA, you are need to advise the business on whether or not to release. Being a QA, I should know every part of system better than anyone else.


Having said that feel free to add skill which you feel should be added.