Monday, July 29, 2019


       WebDriver drivernew FirefoxDriver();
                  (vs)
       FirefoxDriver drivernew FirefoxDriver();

WebDriver -> is an Interface
FirefoxDriver, ChromeDriver, IEDriver -> are classes

All the abstract methods of Webdriver interface are implemented in RemortWebDriver class which is extended by browser classes such as FirefoxDriver, ChromeDriver etc.,

In the above first statements we are creating objects for the browser class and casting it to WebDriver interface reference variable. 
In the statement FirefoxDriver driver =  new FirefoxDriver();,
The FirefoxDriver instance which gets created will be only able to invoke and act on the methods implemented by FirefoxDriver.. Using this statement, we can run our scripts only on Firefox Browser

To act with other browsers we have to specifically create individual objects as below:
ChromeDriver driver =  new ChromeDriver();
InternetExplorerDriver driver =  new InternetExplorerDriver();

To achieve we go for 
WebDriver driver =  new FirefoxDriver();
Whenever object is creating for the browser class and casting it to same driver reference variable
It helps you when you do testing on multiple browsers.
This is happening in dynamically run time. So that we can dynamic Polymorphism is applying here.
Question: How do you check whether a table data(values) is sorted or not? Sorting happens when clicking on Table Header(Ex: Name, which is a link).
Name
Venu
Avinash
Dharma
Answer:
We can take an array of String type as expected values and consider the column values which need to be verify are as actual values. Which can be resolved by below example.


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class CompareTwoLists {
       public static void main(String[] ar){
              List<String> expdValues = new ArrayList<String>();
              expdValues.add("venu");
              expdValues.add("avinash");
              expdValues.add("dharma");
              Collections.sort(expdValues);     //to arrange given list in sorting
             
              List<String> actValues = new ArrayList<String>();
              actValues.add("dharma");
              actValues.add("venu");
              expdValues.add("avinash");
              Collections.sort(actValues);
             
              if(expdValues.equals(actValues)){
                     System.out.println("Given Lists are Matched");
              }else{
                     System.out.println("Given lists are not matched");
              }
       }
}



Sunday, July 7, 2019

What is java?

Java is a programming language and a computing platform for application development.
It was first released by Sun Microsystem in 1995 and later acquired by Oracle Corporation in 2010.
In 2006 Sun started to make Java available under the GNU General Public License (GPL).
Lets see the phases of execution of a Java program:

  1. Writing of the program is of course done by java programmer
  2. Compilation of program is done by javac compiler, javac is the primary java compiler included in java development kit (JDK). It takes java program as input and generates java bytecode as output.
  3. In third phase, JVM executes the bytecode generated by compiler. This is called program run phase.
So, now that we understood that the primary function of JVM is to execute the bytecode produced by compiler. Each operating system has different JVM, however the output they produce after execution of bytecode is same across all operating systems. That is why we call java as platform independent language.
Note: To execute any java program, need to install the JDK

Why java language and its features?

Java is popular because of the following features:
  1. Simple programming language
  2. Object Oriented Language
  3. Distributed
  4. Robust
  5. Architecture Neutral or Machine Independent
  6. Portable
  7. Interpreted
  8. High Performance
  9. Multithreaded
  10. Dynamic



  1. Selenium 1 = Selenium Remote Control
  2. Selenium 2 = Selenium Webdriver, which combines elements of Selenium 1 and Webdriver.
  3. Selenium 3 = Selenium  1 + Selenium 2 (RC is deprecated and moved to legacy package)



What is Selenium:

Selenium is an Automation Testing Framework which automates web applications for testing purposes.
It is an open source and mainly used for automating functional tests and regression tests.

Note: It can be integrated with automation test tools such as Maven, Jenkins, & Docker to achieve continuous testing. It can also be integrated with tools such as TestNG, & JUnit for running test cases and generating reports.

Features of selenium:

Selenium is popular because of the below features:
  1. Selenium is an Open-Source.
  2. Selenium supports multiple languages like Java, C#, python, Ruby, Perl, Php, Java script.
  3. Supports multiple browsers like IE, Chrome, Firefox, Safari, Opera etc., (cross browser testing)
  4. Supports multiple Operating Systems like Windows, Mac, Linux etc., (Cross platform testing)
  5. Selenium supports for mobile platforms android and iOS
  6. Supports parallel test execution
  7. It can be integrated with other automation tools such as Maven, Jenkins and Docker etc.,
  8. Can be integrated with test management tools such as Jira and ALM

Limitations of Selenium:

Below are the limitations with selenium but we can we can overcome these using some integration tools:
  1. Selenium does not support automation testing for desktop applications
  2. We should know at least one of the supported programming languages
  3. Selenium does not have any inbuilt reporting capability
  4. It does not have built-in Object Repository
  5. It is not possible to perform testing on images
  6. Since Selenium is open source software, you have to rely on community forums to get your technical issues resolved


What is Test Automation:
Test Automation or Automation Testing is a method of automating execution of tests and then 
compares actual test results with predicted or expected results using special software.
                                                                  (or)
Test automation means using a software tool to run repeatable tests against the application to be
tested.

Advantages of Automation Testing:

  1. Faster execution and rapid feedback to developers
  2. Supports regression testing.
  3. Frequent execution and gives accurate results.
  4. Lesser Investment in Human Resources (Better ROI)
  5. Disciplined documentation of test cases
  6. Customized defect reporting
  7. Running tests anytime, anywhere un-attended
  8. Better Test Coverage
  9. Support for Agile and extreme development methodologies
Tools used for Automation Testing:
Below are some of the tools used for Test Automation
  1. Selenium (Open Source or Free ware) - Owned by Thougtworks
  2. UFT (Unified Functional Testing) (formerly QTP) (Commercial) – Owned by HP
  3. RFT (Rational Functional Tester)(Commercial) - Owned by IBM
  4. TestComplete (Commercial) – Owned by SmartBear Software
  5. Ranorex (Commercial) – Owned by Ranorex



Manual testing is a testing process that is carried out manually(executing test cases) in order to find defects without the usage of tools or automation scripting.
It is the most primitive of all testing types and helps find bugs in the software system.
Manual Testing does not require knowledge of any testing tool.
Advantages of Manual Testing:
  • Faster execution and rapid feedback to developers
  • Supports regression testing.
  • Frequent execution and gives accurate results.
  • Lesser Investment in Human Resources (Better ROI)
  • Disciplined documentation of test cases
  • Customized defect reporting.
  • Running tests anytime, anywhere un-attended.
  • Better Test Coverage.
  • Support for Agile and extreme development methodologies
Limitations of Manual Testing:
  • More people are required.
  • More tedious. (Tiresome, As repeating thing get tired)
  • More time is consumed.
  • Can’t be repeated so easily.
  • Concurrency is missing. (i.e. all the users cannot give request at the same instant of time)

What is Software Testing:
Software Testing is a process of verifying or validating an application with the intention of finding bugs or defects.
This can be done through either manually or using automation tool.
Definition of a Defect
It is a deviation from the requirement specification. (difference between expected result and actual result)

Importance of Software Testing:
  • It is an essential since it makes sure of the Customer’s reliability and their satisfaction in the application.
  • It is very important to ensure the Quality of the product. Quality product delivered to the customers helps in gaining their confidence.
  • Testing is required for an effective performance of software application or product.
  • It is important to ensure that the application should not result into any failures because it can be very expensive in the future or in the later stages of the development.







      Wednesday, June 19, 2019

      Encapsulation is to make sure that "sensitive" data is hidden from users. To achieve this, you must:

      • declare class variables/attributes as private (only accessible within the same class)
      • provide public setter and getter methods to access and update the value of a private variable

      In encapsulation, you never expose your data to an external party. Which makes your application secure.
      Java encapsulation is referred as data hiding. But more than data hiding, encapsulation concept is meant for better management or grouping of related data.
      With encapsulation, developers can change one part of the code easily without affecting other.

      If a data member is declared "private", then it can only be accessed within the same class. No outside class can access data member of that class. If you need to access these variables, you have to use public "getter" and "setter" methods.
      The get method returns the variable value, and the set method sets the value.

      Example:

      public class Person {
        private String name; // private = restricted access
        // Getter  public String getName() {
          return name;
        }

        // Setter  public void setName(String newName) {
          this.name = newName;
        }
      }

      public class MyClass {
        public static void main(String[] args) {
          Person myObj = new Person();
          myObj.name = "John";  // error    System.out.println(myObj.name); // error    }
      }

      Example explained

      The get method returns the value of the variable name.
      The set method takes a parameter (newName) and assigns it to the name variable. The this keyword is used to refer to the current object.
      However, as the name variable is declared as private, we cannot access it from outside this class:


      Thursday, February 28, 2019

      What is mean by immutable object/class?
      Assume we have a below class A as mutable:
      Class A{
      int i = 10;
      int j = 20;

      A a = new A();
      }



      a.i = 30;
      a.j = 40;

      Changing state of objects, so A is mutable.

      Immutable: once object is created, we cannot change the content of the object.

      String str = "Venu" -> We ca not change the state of str because string is immutable
      str.concate("gopal) -> Creates a new object with modified content
      s.o.p (str) = Venu

      If asign ablove concatenate operation to a string s and print s then
      String s = str.concate("gopal) ==> Venugopal

      Why String is immutable in Java?

      What is SCP:
      The Java string constant pool is an area in heap memory where Java stores literal string values. The heap is an area of memory used for run-time operations.

      String str = "Venu"

      Class Student{
      String str = "Venu"
      String str1 = "Venu"
      String str2 = "Venu"
      Str2.concate("gopal")
      }

      line1: Whenever create using string leteral, an Object is created inside SCP with the contant "Venu"
      line2: Creating same as string literal, which is already available with the same contant in SCP so a new reference is point out to existing the object.
      (Duplicates are not allowed in SCP)
      line3: Same happens as happened in line 2.

      How SCP helps for memory optimization:
      Suppose we have 10,000 students with same name, 10,000 objects will be created inside the memory, performance will be reduced.
      We should not create a more objects, SCP has been implemented inside JVM it will create once object referece to same object if trying to create with the same name.

       Str2.concate("gopal") -> instead it point of str2, creates new object in Heap area as we are going some runtime operation. (Note: str, str1 also get effected if strings are mutable)


      String s1 = new String("Venu") -> new keyword always creates a new object in Heap memory.

      But, if we want to restrict to create a new object and retrieving same object which is created with the String literal then we can use intern() method.
      if(str == s1){
      True;
      }

      String intern():
      is method in String class. It returns a canonical representation for the string object.
      When the intern() method is invoked on a String object it looks the string contained by this String object in the pool, if the string is found there then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned.

      Note: Java automatically interns all Strings by default.

      Sunday, February 10, 2019

      Software Testing Life Cycle:
      Below is the summary of STLC along with Entry and Exit Criteria: Following phases are involved in STLC:
      1. Requirement Analysis
      2. Test Planning
      3. Test case development
      4. Test Environment setup
      5. Test Execution
      6. Test Cycle closure
      1. Requirement Analysis:
      • Entry Criteria: 
          • Requirements Document available (both functional and non functional)
          • Application architectural document available
      • Activity:
          • Analyze business functionality to know the business modules and module specific functionalities.
          • Identify types of tests to be performed
          • Prepare Requirement Traceability Matrix (RTM).
          • Identify test environment details where testing is supposed to be carried out.
          • Automation feasibility analysis (if required).
      • Exit Criteria: 
          • Signed off RTM
          • Test automation feasibility report signed off by the client
      • Deliverables: RTM, Automation feasibility report (if applicable)
      2. Test Planning:
      • Entry Criteria: 
          • Requirements Documents
          • Requirement Traceability matrix.
          • Test automation feasibility document.
      • Activity:
          • Preparation of test plan/strategy document for various types of testing
          • Test tool selection
          • Test effort estimation
          • Resource planning and determining roles and responsibilities.
      • Exit Criteria:
          • Approved test plan/strategy document.
          • Effort estimation document signed off.
      • Deleverables:
          • Test plan/strategy document., 
          • Effort estimation document.
      3. Test Case Development:
      • Entry Criteria: 
          • Requirements Documents
          • RTM and test plan
          • Automation analysis report
      • Activity:
          • Create test cases, automation scripts (where applicable)
          • Review and baseline test cases and scripts
          • Create test data
      • Exit Criteria:
          • Reviewed and signed test Cases/scripts
          • Reviewed and signed test data
      • Deleverables: Test cases/scripts, Test data
      4. Test Environment SetUp:
      • Entry Criteria: System design document and Environment set-up plan
      • Activity:
          • Prepare hardware and software requirement list
          • Setup test Environment and test data
          • Perform smoke test on the build
          • Accept/reject the build depending on smoke test result
      • Exit Criteria: 
          • Environment setup is working as per the plan and checklist
          • Test data setup is complete
          • Smoke test is successful
      • Deleverables: Environment ready with test data set up, Smoke Test Results.
      5. Test Execution:
      • Entry Criteria: 
          • Baselined RTM, Test Plan, Test case/scripts are available
          • Test environment is ready
          • Test data set up is done
          • Unit/Integration test report for the build to be tested is available
      • Activity: 
          • Execute tests as per plan
          • Document test results, and log defects for failed cases
          • Update test plans/test cases, if necessary
          • Map defects to test cases in RTM
          • Retest the defect fixes
          • Regression testing of application
          • Track the defects to closure
      • Exit Criteria:
          • All tests planned are executed
          • Defects logged and tracked to closure
      • Deleverables:
          • Completed RTM with execution status
          • Test cases updated with results
          • Defect reports
      6. Test Cycle Closure:
      • Entry Criteria: 
          • Testing has been completed
          • Test results are available
          • Defect logs are available
      • Activity:
          • Evaluate cycle completion criteria based on - Time, Test coverage, Cost, Software Quality, Critical Business Objectives
          • Prepare test metrics based on the above parameters.
          • Prepare Test closure report
      • Exit Criteria: Test Closure report signed off by client
      • Deleverables: Test Closure report, Test metrics

      Sunday, February 3, 2019

      Difference between BufferedReader and Scanner:
      1. It can parse the user input and read an int, short, byte, float, long and double apart from String. On the other hand, BufferedReader can only read String in Java.
      2. BuffredReader has a significantly large buffer (8KB) than Scanner (1KB), which means if you are reading long String from a file, you should use BufferedReader but for short input and input other than String, you can use Scanner class.
      3. BufferedReader is older than Scanner. It's present in Java from JDK 1.1 onward but Scanner is only introduced in JDK 1.5 release
      4. Scanner uses regular expression to read and parse text input. It can accept custom delimiter and parse text into primitive data type. While, BufferedReader  can only read and store String using readLine() method.
      5. Another major difference between BufferedReader and Scanner class is that BufferedReader is synchronized while Scanner is not. This means, you cannot share Scanner between multiple threads but you can share the BufferedReader object.

      Tuesday, January 29, 2019

      Write a Java program to find whether given number is Armstrong or not
      Armstrong numbers are: 153, 370, 371, 407
      Definition: We call a given number as Armstrong if it is equal to the sum of the powers of its own digits.
      Ex: abcd...n => pow(a,n) + pow(b,n) + pow(c,n) + pow(d,n) + .... =abcd...n
      Answer:
      package seleniumrepo;

      import java.util.Scanner;
      class ArmstrongNumber{
                public static void main(String args[]){
                      int n, sum = 0, temp, r;
                      Scanner in = new Scanner(System.in);
                      System.out.println("Enter a number to check if it is an armstrong number");   
                      n = in.nextInt();
                      temp = n;
                      while( n!= 0 ){
                             r = n%10;
                             sum = sum + r*r*r;
                             n= n/10;
                       }
                       if ( temp == sum )
                             System.out.println("Entered number is an armstrong number.");
                        else
                             System.out.println("Entered number is not an armstrong number."); 
         
                       in.close();
               }
      }


      Based on the type of data stored, data types are classifying as 3 types in Java.
      1. Primitive Datatype (Fundamental Datatype):
      2. Derived Datatype
      3. User Defined Datatype
      Primitive Datatype (Fundamental Datatype)
      The datatype which stores only single value is Primitive datatype. Primitive datatypes are also known as fundamental datatypes. In java programming language, there are 8 primitive datatypes classified into 4 categories.
      • Integer type category
      • Floating-point category
      • Character type category
      • Boolean type category
                  Ex: int, float, char etc.,
      Derived Datatypes: 
      Derived datatypes are pre-defined datatypes given by the programming language. These derived datatypes are created by primitive datatypes and they can be used for storing multiple values.
                  Ex: Array
      User Defined Datatypes:
      These datatypes will be created by the programmer according to application requirement, in which we can store any type of values and number of values.
                  Ex: Class

      1. Integer Category Data Types:
      This category can be used for storing numbers which can be either +ve or -ve without decimal points.
      We have 4 types under integer category. The size and range are as below:
       Data Type                               Size                                                 Range
        byte                                       1 Byte (2^8)                               -128 to 127
        short                                      2 Bytes                                       -32768 to 32767
        int                                          4 Bytes                              -2,147,483,648 to 2,147,483,647
        long                                       8 Bytes        -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

      2. Floating-Point Category Data Types:
      This category can be used for storing numbers which can be +ve or -ve with decimal points. We have two types under floating point category:
      Data Type                               Size                                                 Range
        float                                       4 Bytes                                  1.4 e^-45 to 3.4 e^38
        double                                   8 Bytes                                  4.9e^-324 to 1.8 e^308

      3. Character Type Category Data Type:
      This category can be used for storing a single character. A character can be represented by an Alphabet or a digit or a special symbol.
      This category contains only one datatype that is Char.
      Data Type                               Size                                                 Range
        Char                                    2 Bytes                                             0 to 65535

      4. Boolean Type Category Data Type:
      This category can be used for storing either True or False. We have only one datatype under this category that is Boolean.
      Data Type                               Size                                                 Range
        Boolean                          JVM Dependent                                 True or False

      Difference between White Box Testing and Black Box Testing:
      WBT: This is defined as method of testing in which one can perform testing on an application having internal structural knowledge of it. This is also known as Glass Box Testing.
      • This testing focuses on the structural part of an application and hence the Developers are involved in this type of testing.
      BBT: This is defined as the method of testing in which one can perform testing on an application with much focus on functional part of it and ever without having an internal structural knowledge of application.

      • Actually the Test Engineers are involved in the BBT. 

      Monday, January 28, 2019


                         package seleniumrepo;

                                public class ExtractNumerics{
                                    public static void main(String[] args) {
                                            ExtractNumerics e=new ExtractNumerics();
                                            e.getInteger("!@#123HHGasd");
                                    } 
                                    public void getInteger(String str) {
                                           str=str.replaceAll("[^0-9]", "");
                                           System.out.println(str);
                                   }
                               }

      Sunday, January 27, 2019

      we cannot iterate a Map directly using iterators, because Map are not Collection.
      There are different methods to iterate through MAP elements:
      Method 1: Using Iterator and keySet().
      package seleniumrepo;

      import java.util.HashMap;
      import java.util.Iterator;
      import java.util.Map;
      public class TestIterator {
      public static void main(String[] args) {
                    Map<String,String> mp=new HashMap<String,String>();
                    mp.put("1", "avinash");
                    mp.put("2", "venu");
                    mp.put("3", "dharma");
                    mp.put("4", "hari");
                    Iterator<String> it=mp.keySet().iterator();
                    while(it.hasNext()){
                          String temp=it.next();
                          System.out.println(temp + " " +mp.get(temp));
                    }
      }
      }

      Method 2: Using foreach() method. It is defined as default method in the Map interface.

      package seleniumrepo;

      import java.util.HashMap;
      import java.util.Iterator;
      import java.util.Map;
      public class TestIterator {
      public static void main(String[] args) {
                      Map<String,String> map=new HashMap<String,String>();
                      map.put("1", "avinash");
                      map.put("2", "venugopal");
                      map.put("3", "dharma");
                      map.put("4", "hari");
                      map.forEach((k,v)->System.out.println("Key: "+k+" Value: "+v));
      }

      Method 3: Using entrySet() and Map.Entry(K, V).
      package javaprograms;

      import java.util.HashMap;

      import java.util.Map;
      public class TestIterator {
      public static void main(String[] args) {
                          Map<String,String> map=new HashMap<String,String>();
      map.put("1", "avinash");
      map.put("70", "venugopal");
      map.put("30", "dharma");
      map.put("4", "hari");
      System.out.println(map.values());
      for(Map.Entry<String, String> entry: map.entrySet()) {
       System.out.println("Key: "+entry.getKey()+"\t"+ "Value: "+entry.getValue());
      }
      }
      }

      Output:
      [avinash, hari, venugopal, dharma]
      Key: 1 Value: avinash
      Key: 4 Value: hari
      Key: 70 Value: venugopal
      Key: 30 Value: dharma

      selenium-repo by venu

      Blog helps to a student or IT employee to develop or improve skills in Software Testing.
      For Online Classes Email us: gadiparthi122@mail.com

      Followers

      About Me

      My photo
      Hyderabad, Andhra Pradesh, India
      I am Automation Testing Professional. I have completed my graduation in B.Tech (Computers) from JNTU Hyderabad and started my career in Software Testing accidentally since then, I passionate on learning new technologies

      Contact Form

      Name

      Email *

      Message *