Role of a Tester in Scrum - Agile Process


Role of a tester in Release and Sprint Planning:

•Understand user stories and acceptance criteria
•User stories get clarified from the respective stakeholders where there is insufficient information
•High level test strategy has to be decided for whole release
•All the risk that might occurs at the time of release needs to be noted or documented
•Number of testing types need to be decided and discussed
•Estimate time for each user story test case creation and execution
•Break user stories into different testing tasks
•Decide each story test coverage
•Acceptance criteria for user stories needs to be defined
Understand and plan for user stories automation and support various levels of testing 
•Customer satisfaction through delivery of high-quality software which is earlier and continuous is highest priority •Engagement is early during the project from sprint planning but the QA activities are same •Business people, developers, and testers must work together throughout the project •Discuss and understand each user story with stakeholders and then decide on acceptance criteria for the same •Welcome changing requirements. Tester needs to be adaptable to any changes •Define activities for themselves to estimate time, updating test cases as and when changes appear, complete testing within the sprint time etc. •Story level estimation needs to be done and time needs to be assigned for each story •Test Cases needs to be developed as per the story acceptance criteria and needs to be change whenever there is a change in story •Deliver high quality software iteratively from a couple of weeks to a couple of months •QA needs to track the progress of testing on a daily basis with continuous feedback

Square Series


package exam;

public class Program4 {
 public static void main(String[] args) {
  int n=5;
  for(int i=1;i<=n;i++) {
   System.out.print(" " +(i*i));
  }
 }

}



o/p:-
 1 4 9 16 25




Cube Series


package exam;

public class Program3 {
 public static void main(String[] args) {
  int n=5;
  for(int i=1;i<=n;i++) {
   System.out.print(" " +(i*i*i));
  }
 }

}


o/p:-
 1 8 27 64 125




ODD Number Series



package exam;

public class Program2 {
 public static void main(String[] args) {
  int n=5;
  for(int i=1;i<=n;i++) {
   System.out.print(" " +(2*i-1));
  }
 }

}


o/p:-
 1 3 5 7 9




Sum number series



package exam;

public class Program1 {
 public static void main(String[] args) {
  int n=5;
  for(int i=1;i<=n;i++) {
   System.out.print(" " +(2*i));
  }
 }

}


o/p:-
 2 4 6 8 10




Sum of Digits





package exam;

import java.util.Scanner;

public class SumofDigits {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  int r,temp, s=0;
  System.out.println("Enter the number");
  int n=sc.nextInt();
  temp=n;
  while(n>0) {
   //n=n%10;
   
   s=s+n%10;
   n=n/10;
   
  }
  System.out.println(s);
  
}
}


o/p:-
Enter the number
456
15




Reverse String




package exam;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ReverseString {
 public static void main(String[] args) throws IOException {
  BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
  System.out.println("Enter the string");
  String org=reader.readLine();
  System.out.println("Original String is " +org);
  String rev="";
  
  for(int i=org.length()-1;i>=0;i--) {
   rev=rev+org.charAt(i);
  }
  System.out.println("Reverse string is-"+rev);
  
 }

}


o/p:-
Enter the string
vaibhav
Original String is vaibhav
Reverse string is-vahbiav



Is Prime Number?




//Prime Number  Print 
package exam;

import java.util.Scanner;

public class PrimeNumber {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  int flag = 0;
  System.out.println("Enter the number");
  int n=sc.nextInt();
  int mid=n/2;
  if(n==0||n==1) {
   System.out.println("Not Prime");
  }else {
   
   for(int i=2;i<=mid;i++) {
    if(n%i==0) {
     System.out.println("Not Prime");
     flag= 1;
     break;
    }
   }
   if(flag==0) {
    System.out.println(n +" Number is Prime");
   }
  }
  
}
}


o/p:-
Enter the number
5
5 Number is Prime




Is Number Palindrome?





package exam;

import java.util.Scanner;

public class NumberPalindrome {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  int r,temp, s=0;
  System.out.println("Enter the number");
  int n=sc.nextInt();
  temp=n;
  while(n>0) {
   r=n%10;
   s=(s*10)+r;
   n=n/10;
  }
  System.out.println(s);
  if(temp==s) {
   System.out.println("number is palindrome");
  }else {
   System.out.println("number is not palindrome");
  }
}
}


o/p:-
Enter the number
153
351
number is not palindrome



Fibbonaci Series



package exam;

public class FibbonaciSeries {
 public static void main(String[] args) {
  int n1=0,n2=1;
  int n3,i,count=10;
  System.out.print(n1+"  "+n2);
  for(i=2;i<=count;i++) {
   n3=n1+n2;
   System.out.print(" "+n3);
   n1=n2;
   n2=n3;
  }
 }

}


o/p:-
0  1 1 2 3 5 8 13 21 34 55



Factorial Number





//Factorial  Print 
package exam;

import java.util.Scanner;

public class Factorial {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  int fact=1;
  System.out.println("Enter the number");
  int n=sc.nextInt();
  for(int i=1;i<=n;i++) {
   fact=fact*i;
  }
  System.out.println("Factorial of this number is " +fact);
}
}

o/p:-
Enter the number
5
Factorial of this number is 120



Is Armstrong Number?




package exam;

import java.util.Scanner;

public class ArmstrongNumber {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  int r,temp, s=0;
  System.out.println("Enter the number");
  int n=sc.nextInt();
  temp=n;
  while(n>0) {
   r=n%10;
   n=n/10;
   s=s+(r*r*r);
   
  }
 
  if(temp==s) {
   System.out.println("number is Armstrong");
  }else {
   System.out.println("number is not Armstrong");
  }
}
}

o/p:-
Enter the number
5
number is not Armstrong


Pattern 8


We can print the following Pattern 
1) 
    1             //print (char)(j+64) and i
   A B 
  3 3 3 
 A B C D 

2)
    1            //print (char)(j+64) and j
   A B 
  1 2 3 
 A B C D 

3)
    1            //print (char)(i+64) and i
   B B 
  3 3 3 
 D D D D 

4)
    1          //print (char)(i+64) and j
   B B 
  1 2 3 
 D D D D 




package demo;

import java.util.Scanner;

public class Pattern9 {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  
  System.out.println("Enter the number");
  int n=sc.nextInt();

  for(int i=1;i=i;k--) {
    System.out.print(" ");
   }
   for(int j=1;j<=i;j++) {
    //System.out.print("* ");
    if(i%2 == 0) {
     System.out.print((char)(i+64)+ " ");
    }
    else
    {
     System.out.print(j+ " ");
    }
   }
   System.out.println();
  }
 }
}
O/P:-
Enter the number
5
    1 
   A B 
  3 3 3 
 A B C D 




Pattern 7


We can print the following Pattern 
1) 
    A      //print (char)(j+64)  and i
   2 2 
  A B C 
 4 4 4 4 

2) 
    A       //print (char)(j+64)  and j
   1 2 
  A B C 
 1 2 3 4 

3) 
    A         //print (char)(i+64)  and i
   2 2 
  C C C 
 4 4 4 4 

4)
    A           //print (char)(i+64)  and j       
   1 2 
  C C C 
 1 2 3 4


package demo;

import java.util.Scanner;

public class Pattern8 {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  
  System.out.println("Enter the number");
  int n=sc.nextInt();
  for(int i=1;i=i;k--) {
    System.out.print(" ");
   }
   for(int j=1;j<=i;j++) {
    //System.out.print("* ");
    if(i%2 != 0) {
     System.out.print((char)(j+64)+ " ");
    }
    else
    {
     System.out.print(i+ " ");
    }
   }
   System.out.println();
  }
 }
}
O/P:-
Enter the number
5
    A 
   2 2 
  A B C 
 4 4 4 4 



pattern 6


We can print the following Pattern 
1) 
5 5 5 5 5         //print i
4 4 4 4 
3 3 3 
2 2 
1

2)
5 4 3 2 1          //print j
4 3 2 1 
3 2 1 
2 1 
1  

package demo;

import java.util.Scanner;

public class Pattern7 {
 public static void main(String[] args) 
    {
        Scanner sc = new Scanner(System.in);
         
        //Taking rows value from the user
         
        System.out.println("How many rows you want in this pattern?");
         
        int rows = sc.nextInt();
         
        System.out.println("Here is your pattern....!!!");
         
        for (int i = rows; i >= 1; i--) 
        {
            for (int j = i; j >= 1; j--)
            {
               // System.out.print(j+" ");
                System.out.print(i+" ");
            }
             
            System.out.println();
        }
         
        //Closing the resources
         
        sc.close();
    }
}

O/P:-
5
Here is your pattern....!!!
5 4 3 2 1 
4 3 2 1 
3 2 1 
2 1 
1 
 


Pattern 5


We can print the following Pattern 
1)
* * * * *       //print *
* * * * * 
* * * * * 
* * * * * 
* * * * * 

2)
1 1 1 1 1        //print i
2 2 2 2 2 
3 3 3 3 3 
4 4 4 4 4 
5 5 5 5 5 

3)
1 2 3 4 5        //print j
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 

4)
A A A A A         //(char)(i+64)
B B B B B 
C C C C C 
D D D D D 
E E E E E 


5)
A B C D E       //(char)(j+64)
A B C D E 
A B C D E 
A B C D E 
A B C D E 


package demo;

import java.util.Scanner;

public class Pattern5 {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  
  System.out.println("Enter the number");
  int n=sc.nextInt();
  for(int i=1;i<=n;i++) {
   for(int j=1;j<=n;j++ ) {
    //System.out.print("* ");
    //System.out.print(i+ "5 ");
    //System.out.print(j+ " ");
    //System.out.print((char)(i+64)+ " ");
    System.out.print((char)(j+64)+ " ");
   }
   System.out.println();
    
   }
 } 
 }
O/P:-
Enter the number
5
A B C D E 
A B C D E 
A B C D E 
A B C D E 
A B C D E 

 


Pattern 4


We can print the following Pattern 
1)
* * * * *              //print *
* * * * 
* * * 
* * 
* 

2)
1 1 1 1 1       //print i
2 2 2 2 
3 3 3 
4 4 
5

3)
5 4 3 2 1        //print j
5 4 3 2 
5 4 3 
5 4 
5  

4)
A A A A A     //(char)(i+64)
B B B B 
C C C 
D D 
E 

5)
E D C B A      //(char)(j+64)
E D C B 
E D C 
E D 
E 

package demo;

import java.util.Scanner;

public class Pattern4 {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  
  System.out.println("Enter the number");
  int n=sc.nextInt();
  for(int i=1;i<=n;i++) {
   for(int j=5;j>=i;j-- ) {
    //System.out.print("* ");
    //System.out.print(i+ "5 ");
    //System.out.print(j+ " ");
    //System.out.print((char)(i+64)+ " ");
    System.out.print((char)(j+64)+ " ");
   }
   System.out.println();
    
   }
 } 
 }
O/P:-
Enter the number
5
E D C B A 
E D C B 
E D C 
E D 
E 
 


Pattern 3


We can print the following Pattern 
1)
A                    //print (char)(j+64)
A B 
A B C 
A B C D 
A B C D E

2)
A                  //print (char)(i+64)
B B 
C C C 
D D D D 
E E E E E 

3)
*                 //print *
* * 
* * * 
* * * * 
* * * * * 

4)
1                     //Print i
2 2 
3 3 3 
4 4 4 4 
5 5 5 5 5 

5)
1                  //print j
1 2 
1 2 3 
1 2 3 4 
1 2 3 4 5 


package demo;

import java.util.Scanner;

public class Pattern3 {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  
  System.out.println("Enter the number");
  int n=sc.nextInt();
  for(int i=1;i<=n;i++) {
   for(int j=1;j<=i;j++ ) {
    //System.out.print("* ");
    //System.out.print(i+ "5 ");
    //System.out.print(j+ " ");
    //System.out.print((char)(i+64)+ " ");
    System.out.print((char)(j+64)+ " ");
   }
   System.out.println();
    
   }
 } 
 }

O/P:-
Enter the number
5
A 
A B 
A B C 
A B C D 
A B C D E  


Pattern 2


We can print the following Pattern 
1)
* * * * *           //print *
 * * * * 
  * * * 
   * * 
    * 

2)
5 4 3 2 1    //Print j
 4 3 2 1 
  3 2 1 
   2 1 
    1 

3)
5 5 5 5 5  //Print i
 4 4 4 4 
  3 3 3 
   2 2 
    1 



package demo;

import java.util.Scanner;

public class Pattern2 {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  
  System.out.println("Enter the number");
  int n=sc.nextInt();
  for(int i=n;i>=1;i--) {
   for(int k=n-1;k>=i;k--) {
    System.out.print(" ");
   }
   for(int j=i;j>=1;j--) {
    System.out.print("* ");
    //System.out.print(j+ " ");
    //System.out.print(i+ " ");
   }
   System.out.println();
  }
 }
}


O/P:-
Enter the number
5
5 4 3 2 1 
 4 3 2 1 
  3 2 1 
   2 1 
    1 


Pattern 1


We can print the following Pattern 
1)
    *               //Print *        
   * * 
  * * * 
 * * * * 

2) 
    1              //Print J
   1 2 
  1 2 3 
 1 2 3 4 

3)   
    1               //print i
   2 2 
  3 3 3 
 4 4 4 4 

package demo;

import java.util.Scanner;

public class Pattern1 {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  
  System.out.println("Enter the number");
  int n=sc.nextInt();
  for(int i=1;i=i;k--) {
    System.out.print(" ");
   }
   for(int j=1;j<=i;j++) {
    System.out.print("* ");  
    //System.out.print(j+ " "); 
    //System.out.print(i+ " ")
   }
   System.out.println();
  }
 }
}


O/P:-
Enter the number
5
    1 
   1 2 
  1 2 3 
 1 2 3 4 


How Much Java you need to learn for a good Selenium Scripting ?

1)OOP’s concept – Class, Objects Polymorphism, Inheritance and Encapsulation
2)Java Programming essentials- Object Instances, method overloading/overriding concepts and packages
3)Control Statements – While, do-While, Switch, If statements – This will help us in writing the scripts 
  for a multiple scenario statements and decision making scenarios.
4)Looping statements – This will help us in scenarios like, iterating through a large table to find
  a record that you want and Running the same test for multiple number of times.
5)Arrays Concepts – This will help us in having some set of datas of same type in a static way.
6)Threads and MultiThreading Concepts – This will help us in making run our scripts in different
  threads that will help us in achieving better performance.
7)Java Collections Framework – ArrayLists and HashMaps – This will help us in maintaining a 
collection of data’s. Particularly useful for scenarios where you need to compare the data from Web app
  UI with the DB. [OR] From UI to another UI
8)File Streams – This will be helpful in externalization of data through CSV, Excel or Java Properties file.

iOS and Android Project Code Compare Steps

iOS Code Compare process

1) Search  "File Merge" into MacBook
2) Create a folder and add both projects which we want to compare ex Old Project and New Project
3)After launching File Merge Tool -> We are getting a window which has two options Left and Right
4)Then Fetch Old Project into Left and New Project into Right. Wait for the complete process
5)We will get Folder->File structure into File Merge
6)Select particular file which we want to compare 

In That we will get number chnages count
Changes getting in gray and light blue color


Android Code Compare process

1)Start Android Studio and open New Project
2)Right Click on Project->Compare to then select Old Project
3)The we will get comparism window which have both projects files 
4)Differences highlighed by gray color

Pattern Printing in Java

                                                                             
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
 
package programs;

public class PatternProgram1 {

 public static void main(String[] args) {
  for(int i =1;i<=7;i++){
   for(int j =1; j<=i;j++){
    System.out.print(j+" ");
   }
   System.out.println();
  }
 }
}

***************************************************************************************************************


1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
7 7 7 7 7 7 7
 
package programs;

public class PatternProgram2 {

 public static void main(String[] args) {
  for(int i =1;i<=7;i++){
   for(int j =1; j<=i;j++){
    System.out.print(i+" ");
   }
   System.out.println();
  }
 }
}



***************************************************************************************************************
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
 
package programs;

public class PatternProgram3 {


 public static void main(String[] args) {
  for(int i =1; i<=7;i++){
   for(int j =1; j<=i;j++){
    System.out.print(j+" ");
   }
   System.out.println();
  }
  for(int i=6;i>=1;i--){
   for(int j =1; j<=i;j++){
    System.out.print(j+" ");
   }
   System.out.println();
  }
 }
}


*****************************************************************************************************

1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
 
package programs;

import java.util.Scanner;

public class PatternProgram5 {


 public static void main(String[] args) {
 
  Scanner scanner = new Scanner(System.in);
  System.out.println("enter input data");
  int number = scanner.nextInt();
  for(int i=number;i>=1; i--){
   for(int j = 1; j<=i;j++){
    System.out.print("j"+" ");
   }
   System.out.println();
  }
 }
}

***********************************************************************************************************


7 6 5 4 3 2 1
7 6 5 4 3 2
7 6 5 4 3
7 6 5 4
7 6 5
7 6
7
 
package programs;

import java.util.Scanner;

public class PatternProgram6{


 public static void main(String[] args) {
  Scanner scanner = new Scanner(System.in);
  System.out.println("enter input data");
  int number = scanner.nextInt();
  for(int i =1; i<=number;i++){
   for(int j = number; j>=i;j--){
    System.out.print(j+" ");
   }
   System.out.println();
  }
 }
}



*******************************************************************************************************
 
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
  

package programs;

public class PatternProgram7 {


 
 public static void main(String[] args) {
  for(int i =7; i>=1; i--){
   for(int j =1 ; j<=i; j++){
    System.out.print(j+" ");
   }
   System.out.println();
  }
  
  for(int k = 2; k<=7; k++){
   for(int j =1 ; j<=k; j++){
    System.out.print(j+" ");
   }
   System.out.println();
  }
 }
}


**********************************************************************************************
 
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 6 5 4 3 2 1
1 2 3 4 5 6 7 6 5 4 3 2 1
 

package programs;

public class PatternProgram8 {


 public static void main(String[] args) {
  for(int i = 1; i<=7; i++){
   
   for(int j = 1; j<=i; j++){
    System.out.print(j+" ");
   }
   
   for(int j = i-1; j>=1; j--){
    System.out.print(j+" ");
   }
   System.out.println();
  }

 }
}




Github Tutorial and Basic Commands

GitHub Tutorial
1)Introduction to GitHub
GitHub is a highly used software which is typically used for version control. It is helpful when more than just one person 
is working on a project. Say for example, a software developer team wants to build a website and everyone has to update their
 codes simultaneously while working on the project. In this case, Github helps them to build a centralized repository where 
everyone can upload, edit and manage the code files.

Step 2: Creating a GitHub Repository
  a)Go to the link: https://github.com/ . Fill the sign up form and click on “Sign up for Github”.
  b)Click on “Start a new project”.
c)Enter any repository name and click on “Create Repository”. You can also give a description to your repository (optional).

Step 3: Create Branches and Perform Operations
Branching: Branches help you to work on different versions of a repository at one time. Let’s say you want to add a new feature 
(which is in the development phase), and you are afraid at the same time whether to make changes to your main project or not.
 This is where git branching comes to rescue. Branches allow you to move back and forth between the different states/versions
 of a project. In the above scenario, you can create a new branch and test the new feature without affecting the main branch.
 Once you are done with it, you can merge the changes from new branch to the main branch.

To create a branch in GitHub, follow the below steps:

a)Click on the dropdown “Branch: master”
 b)As soon as you click on the branch, you can find an existing branch or you can create a new one. In my case, I am creating 
a new branch with a name “readme- changes”. Refer to the below screenshot for better understanding.

CreateBranches - how to use GitHub - Edureka


Commit Command:
This operation helps you to save the changes in your file. When you commit a file, you should always provide the message, 
just to keep in the mind the changes done by you. Though this message is not compulsory but it is always recommended so 
that it can differentiate the various versions or commits you have done so far to your repository.


Pull Command

Pull command is the most important command in GitHub. It tell the changes done in the file and request other contributors 
to view it as well as merge it with the master branch. Once the commit is done, anyone can pull the file and can start a
 discussion over it. Once its all done, you can merge the file. Pull command compares the changes which are done in the 
file and if there are any conflicts, you can manually resolve it



Git task Notes Git commands
Tell Git who you are Configure the author name and email address to be used with your commits.

Note that Git strips some characters (for example trailing periods) from user.name.

git config --global user.name "Sam Smith"

git config --global user.email sam@example.com

Create a new local repository  
git init
Check out a repository Create a working copy of a local repository:
git clone /path/to/repository
For a remote server, use:
git clone username@host:/path/to/repository
Add files Add one or more files to staging (index):
git add <filename>

git add *
Commit Commit changes to head (but not yet to the remote repository):
git commit -m "Commit message"
Commit any files you've added with git add, and also commit any files you've changed since then:
git commit -a
Push Send changes to the master branch of your remote repository:
git push origin master
Status List the files you've changed and those you still need to add or commit:
git status
Connect to a remote repository If you haven't connected your local repository to a remote server, add the server to be able to push to it: git remote add origin <server>
List all currently configured remote repositories: git remote -v
Branches Create a new branch and switch to it:
git checkout -b <branchname>
Switch from one branch to another:
git checkout <branchname>
List all the branches in your repo, and also tell you what branch you're currently in:
git branch
Delete the feature branch:
git branch -d <branchname>
Push the branch to your remote repository, so others can use it:
git push origin <branchname>
Push all branches to your remote repository:
git push --all origin
Delete a branch on your remote repository:
git push origin :<branchname>
Update from the remote repository Fetch and merge changes on the remote server to your working directory: git pull
To merge a different branch into your active branch:
git merge <branchname>
View all the merge conflicts:

View the conflicts against the base file:

Preview changes, before merging:

git diff

git diff --base <filename>

git diff <sourcebranch> <targetbranch>
After you have manually resolved any conflicts, you mark the changed file:
git add <filename>
Tags You can use tagging to mark a significant changeset, such as a release:
git tag 1.0.0 <commitID>
CommitId is the leading characters of the changeset ID, up to 10, but must be unique. Get the ID using:
git log
Push all tags to remote repository:
git push --tags origin
Undo local changes If you mess up, you can replace the changes in your working tree with the last content in head:

Changes already added to the index, as well as new files, will be kept.

git checkout -- <filename>
Instead, to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it, do this:
git fetch origin

git reset --hard origin/master
Search Search the working directory for foo(): git grep "foo()"
GITHub Project Push Commands
0) git config --global user.email "Your-Email"
1) git init
2) git status
3) git add .  // add all current directory files
4) git commit -m "First Commit"
5) git remote add origin "repository URL"
6) git push origin master

Pull Single file from GITHub
   git checkout -b Branch_name

Delete Single file from GITHub
   git branch -d Branch_name

To update local repository to the newest commit
   git pull
   
  To create new branch please follow below steps

Note : while creating new branch, switch to develop or Your latest code branch and create your branch by referring that specific branch.

1. Switch to develop branch (git checkout develop)
2. Update your local develop branch by taking a pull request (git pull origin develop)
3. Created new branch eg. NotificationTest (git checkout -b NotificationTest)
4. Write a code in that branch
5. Perform git add . and git commit 
6. Push the code to remote repo (git push origin branch_name )
7. Raised Pull request for “NotificationTest”

Refer this https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html

How to review PR:-

1. Open the PR
2. Go to Files changed tab ( This is where you will see what changes were made in this PR. What files were deleted/added etc )
3. Click on green Review Changes  button ( This is after you finished reviewing everything )
4. Write a comment ( Generally “LGTM” which means Looks Good To Me ) in Leave a comment box.
5. Select Approve option ( To approve )
6. Click Submit review



Basic Git commands | Bitbucket Data Center and Server 8.1 | Atlassian Documentation
https://confluence.atlassian.com

Git CheatSheet.

Selenium: Different Wait Examples


ExplicitWait
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[type='submit']")));

ImplicitWait
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

Selenium:- Find Broken Links


FindBrokenLink.java

import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import com.utility.GetReponseCode;

public class FindBrokenLink {

 WebDriver driver;

 // It will open the browser & Application before Test
 @BeforeTest
 public void openBrowser() {
  System.setProperty("webdriver.chrome.driver", "D://Drivers//chromedriver.exe");
  driver = new ChromeDriver();
  
  //To maximize the Window
  driver.manage().window().maximize();
  //To Open the Application
  driver.get("http://www.oyepages.com");
 }
 
 @AfterTest
 public void tearDown() {
  if (driver != null)
   driver.close();
 }
 
 @Test
  public void getBrokenLinks() {
  
   // Find all Elements on the page with 'a' tag
   List allLinks = driver.findElements(By.tagName("a"));
   
   System.out.println("Total Number of Links : " +allLinks.size());
   
   //Iterate over all available Links on webpage
   for (WebElement link : allLinks) {
   String linkURL = link.getAttribute("href");
   
   //Call VerifyURL form GetResponse Code Class
   GetReponseCode.verifyUrl(linkURL);
  }
   
   System.out.println("Total Number of Links : " +allLinks.size());
   GetReponseCode.getInvalidLinkCount(); 
 }
}

GetReponseCode.java

import java.net.URL;

import javax.net.ssl.HttpsURLConnection;

public class GetReponseCode {

 static int inValidLink;

 public static void verifyUrl(String linkURL) {

  try {
   URL url = new URL(linkURL);
   HttpsURLConnection urlConnect = (HttpsURLConnection) url.openConnection();

   // Set Connection TimeOut
   urlConnect.setConnectTimeout(5000);

   // Open Communication link to resource URL
   urlConnect.connect();

   // To verify the Response Code
   if (urlConnect.getResponseCode() == 200) {
    System.out.println(
      linkURL + " : " + urlConnect.getResponseCode() + " : " + urlConnect.getResponseMessage());
   } else if (urlConnect.getResponseCode() == urlConnect.HTTP_NOT_FOUND) {
    System.out
      .println(linkURL + " : " + urlConnect.getResponseMessage() + " : " + urlConnect.HTTP_NOT_FOUND);
    inValidLink++;
   }

  } catch (Exception e) {
  }
 }

 public static void getInvalidLinkCount() {
  System.out.println("Total Invalid Links : " + inValidLink);
 }

}



Selenium:- Handle Web Tables

import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class WebTableExample {
 
 WebDriver driver;

 // It will open the browser & Application before Test
 @BeforeMethod
 public void openBrowser() {
  System.setProperty("webdriver.chrome.driver", "D://Drivers//chromedriver.exe");
  driver = new ChromeDriver();

  driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  driver.manage().window().maximize();
  driver.get("http://money.rediff.com/gainers/bse/daily/groupa?src=gain_lose");
 }

 // It will close the Browser after Test
 @AfterMethod
 public void tearDown() {
  if (driver != null)
   driver.close();
 }
 
 @Test
 public void countTotalRowsTest(){
  List allRows = driver.findElements(By.xpath("//*[@id='leftcontainer']/table/tbody/tr"));
  System.out.println("Total No of Rows : " +allRows.size());
 }
 
 @Test
 public void printAllRowsTest(){
  List allRows = driver.findElements(By.xpath("//*[@id='leftcontainer']/table/tbody/tr"));
  
  System.out.println("********** Starting Table ************");
  for (int row = 0; row < allRows.size(); row++) {
   System.out.println(allRows.get(row).getText());
  }
  System.out.println("********** Ending Table ************");
 }
 
 
 @Test
 public void countAllColsTest(){
  List allCols = driver.findElements(By.xpath("//*[@id='leftcontainer']/table/tbody/tr[1]/td"));
  System.out.println("Total No of Cols : " +allCols.size());
 }
 
 
 @Test
 public void printCompleteColumnTest(){
  List firstColumn = driver.findElements(By.xpath("//*[@id='leftcontainer']/table/tbody/tr/td[4]"));
  for (int i = 0; i < firstColumn .size(); i++) {
   System.out.println(firstColumn.get(i).getText());
  }
 }
 
 
 @Test
 public void printSpecificRowTest(){
  WebElement row = driver.findElement(By.xpath("//*[@id='leftcontainer']/table/tbody/tr[5]"));
  System.out.println(row.getText());
 }

}


Selenium:- Different Mouse and Keyboard Events Handling

 
DoubleClick
@Test
 public void performDoubleClick() throws InterruptedException{
  WebElement ele = driver.findElement(By.xpath("//button[contains(.,'Double-Click Me To See Alert')]"));

  Actions act = new Actions(driver);
  act.moveToElement(ele).perform();
  act.doubleClick().perform();
  Thread.sleep(5000);

  Alert alert = driver.switchTo().alert();
  alert.accept();
  Thread.sleep(5000);
 }

Switch Alert

Alert alert = driver.switchTo().alert();
  alert.accept();
  Thread.sleep(5000);
 }

DragAndDrop
@Test
 public void performDragAndDrop() throws InterruptedException{
   WebElement iFrame = driver.findElement(By.className("demo-frame"));
   driver.switchTo().frame(iFrame);
  
  // Store the web elements
   WebElement src = driver.findElement(By.id("draggable"));
   WebElement dest = driver.findElement(By.id("droppable"));
   Thread.sleep(2000);
   
   Actions act = new Actions(driver);
   act.dragAndDrop(src, dest).build().perform();
   Thread.sleep(5000);
 }
 
 @Test
 public void performDragAndDrop2() throws InterruptedException{
  WebElement iFrame = driver.findElement(By.className("demo-frame"));
  driver.switchTo().frame(iFrame);
  
  // Store the web elements
   WebElement src = driver.findElement(By.id("draggable"));
   WebElement dest = driver.findElement(By.id("droppable"));
   Thread.sleep(2000);
   
   Actions act = new Actions(driver);
   act.clickAndHold(src).moveToElement(dest).release().perform();
   Thread.sleep(5000);
 }

Keyboard Events
@Test
 public void performDragAndDrop() throws InterruptedException{
   WebElement text = driver.findElement(By.name("firstname"));
   
  Actions builder  = new Actions(driver);
  builder.keyDown(Keys.SHIFT)
    .sendKeys(text, "anshul")
    .keyUp(Keys.SHIFT)
    .build().perform();
  Thread.sleep(5000);
 }

Mouse Hovor
@Test
 public void performMouseHover() throws InterruptedException{
  WebElement seleniumLink = driver.findElement(By.xpath("//*[@id='menu-item-10548']/a"));
  Actions act = new Actions(driver);
  act.moveToElement(seleniumLink).perform();
  Thread.sleep(5000);
  
  WebElement webdriverLink = driver.findElement(By.xpath("//*[@id='menu-item-9383']/a"));
  webdriverLink.click();
  Thread.sleep(5000);
 }

Right CLick
@Test
 public void performRightClick() throws InterruptedException{
  WebElement rightClick = driver.findElement(By.cssSelector(".context-menu-one.btn.btn-neutral"));
  
  Actions act = new Actions(driver);
  act.moveToElement(rightClick).perform();
  act.contextClick().perform();
  Thread.sleep(5000);
 }


Selenium :- Select

 

import java.util.List;

import org.apache.commons.exec.OS;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class DropDownOperations {

 WebDriver driver;

 // It will open the browser & Application before Test
 @BeforeMethod
 public void openBrowser() {
  System.setProperty("webdriver.chrome.driver", "D://Drivers//chromedriver.exe");
  driver = new ChromeDriver();

  // To maximize the Window
  driver.manage().window().maximize();
  // To Open the Application
  driver.get("http://www.facebook.com");
 }

 // It will close the Browser after Test
 @AfterMethod
 public void tearDown() {
  if (driver != null)
   driver.close();
 }

 @Test
 public void selectbyIndexTest() throws InterruptedException {

  // Store the dropdwon webelement
  WebElement element = driver.findElement(By.id("month"));

  Select oSelect = new Select(element);
  oSelect.selectByIndex(1);
  Thread.sleep(4000);
 }
 
 @Test
 public void selectbyValueTest() throws InterruptedException {

  // Store the dropdwon webelement
  WebElement element = driver.findElement(By.id("year"));

  Select oSelect = new Select(element);
  Thread.sleep(3000);
  oSelect.selectByValue("2007");
  
  Thread.sleep(3000);
 }
 
 
 @Test
 public void selectbyTextTest() throws InterruptedException {

  // Store the dropdwon webelement
  WebElement element = driver.findElement(By.id("month"));

  Select oSelect = new Select(element);
  oSelect.selectByVisibleText("Sept");
  Thread.sleep(3000);
 }
 
 @Test
 public void printAllValuesTest() throws InterruptedException {

  // Store the dropdwon webelement
  WebElement element = driver.findElement(By.id("month"));

  Select oSelect = new Select(element);
  List months = oSelect.getOptions();
  System.out.println("Total Options are : " + months.size());
  
  for (WebElement monthValue : months) {
   String value = monthValue.getText();
   System.out.println(value);
  }
 }
}


Selenium:-Extend Reporting with Screenshot

 

Download Latest Extents Reports Jar Files and add to the project


package com.objectrepository.demo;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;

public class ExtentDemo 
{
 
 static ExtentTest test;
 static ExtentReports report;
 static WebDriver driver;
 
 @BeforeClass
 public static void startTest()
 {
  report = new ExtentReports(System.getProperty("user.dir") + "\\ExtentReportResultsOutput.html");
  test = report.startTest("ExtentDemo");
 }

 public void extentReportsDemo() throws IOException 
 {
  System.setProperty("webdriver.chrome.driver","C:\\New Mobile Automation\\ExtendReport\\chromedriver.exe");
  
  WebDriver driver = new ChromeDriver();
  
  driver.get("https://www.google.co.in");
  
  if (driver.getTitle().equals("Google")) {
   test.log(LogStatus.PASS, "Navigated to the specified URL");
  } else {
   test.log(LogStatus.FAIL, "Test Failed");
  }
  
  test.log(LogStatus.FAIL,test.addScreenCapture(capture(driver))+ "Test Failed");
  
 }
 public static String capture(WebDriver driver) throws IOException 
 {
  File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
  File Dest = new File("src/../ErrImages/" + System.currentTimeMillis() + ".png");
  String errflpath = Dest.getAbsolutePath();
  FileUtils.copyFile(scrFile, Dest);
  return errflpath;
 }

 @AfterClass
 public static void endTest() {
  report.endTest(test);
  report.flush();
  
 }
}


APPIUM Server Start and Stop through Java Programming

 
package demo;
import org.testng.annotations.Test;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.openqa.selenium.*;
public class HannaTestScript 
{
  AndroidDriver driver;
  static String Appium_Node_Path="C:\\Appium\\node.exe";
  static String Appium_JS_Path="C:\\Program Files\\Appium\\node_modules\\appium\\bin\\appium.js";
  static AppiumDriverLocalService service;
  static String service_url;
    
  @BeforeTest(enabled = true)
  public void appiumStart() throws InterruptedException, MalformedURLException 
  {
   
    service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().
                usingPort(4723).usingDriverExecutable(new File(Appium_Node_Path)).
                withAppiumJS(new File(Appium_JS_Path)));
    service.start();
    Thread.sleep(25000);
    service_url = service.getUrl().toString();
    
    
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("deviceName", "ZX1B32FFXF");
    capabilities.setCapability("appPackage", "com.hannainst.hannalab");
    capabilities.setCapability("appActivity","com.hannainst.hannalab.ManagerActivity");
    
    
    driver= new AndroidDriver(new URL(service_url),capabilities);
    
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
   }
   @Test
   public void Test_AppLaunch() throws Exception 
   {
     try{
      
      WebDriverWait wait = new WebDriverWait(driver, 300);
      wait.until(ExpectedConditions.elementToBeClickable(By.className("android.widget.RelativeLayout")));
      System.out.println("TC0 :-App Launched Successfully");
      }catch(Throwable e)
      {
       System.out.println("TC0:-Test Case Failed");
      }
  }
  @AfterTest
  public void appiumStop() throws IOException 
  {
    driver.quit();  
    service.stop();
  }
}



Java Project, Jenkins and GIT Intergration

 
Jenkins and GIT Integration

Java Project Creation with ythe help of Eclipse
1)Create  Java Project
2)Create "demo"  package
3)Create Java File "HelloWorld.java"

package demo;
public class ReverseNumber 
{

    public static void main(String[] args)
  {

        System.out.println("Hello World");
         }
}

4)Run Above code from Windows Command Prompt
a)Go to the project folder ex. cd C:\ABC\JenkinandGitJavaProgram\src\demo
b)Enter following command ex javac HelloWorld.java 
c)If we enter " java  HelloWorld.java" then it give us error due to java constraint 
  Enter "java demo.ReverseNumber"     Package should be required before ClassName

5)We will get output "Hello World"

Jenkins and Java Project Integration


Jenkins->Manage Jenkins->Global Tool Configuration
Need to installed following plugins 
HTML Publisher plugin
TestNG Result Plugin
Selenium HTML report

1)Install Jenkins 
2)Start Jenkins server 
a)First go to the jenkins folder ex "C:\Program Files (x86)\Jenkins>
b)Run Jenkins.war ex. "C:\Program Files (x86)\Jenkins>java -jar jenkins.war"
3)Login Jenkins Server by using username and password
4)Click on "New Item" to create new jenkin project
5)Then Enter Project Name ex ""HelloWorld" and select Free Style Project
6)Ok and Save
7)Go to the  Configure->Build-> select "Execute Windows Batch Envirnoment"
and enter folloing commands

cd C:\ABC\JenkinandGitJavaProgram\src\demo
javac HelloWorld.java
cd..
java demo.HelloWorld

8)Apply and Save
9)Click on  "Build Now" and see ouput on "console window"


Jenkins and Java Project and GIT Integration

1)Firstly Jenkins and Java Project Integration required, Install GIT Plugin into Jenkins via Manage Jenkins
2)Create a Github Account
3)Create a repository on GitHub ex "HelloWorldJava"
4)Then make the following changes into "Source Code Management" of Jenkins->HelloWorld
a)Select git instead of None to access code from a git repository
b)Then Enter git repository URL ex. "https://github.com/vpkhachane/HelloWorldJava.git"
c)Then In "Build Triggers"  Tick  "Poll SCM" Option and enter "* * * * *", this star execute script per minute
d)Then Apply and save it

Procedure to upload our project on GIT Repository
Login to Git and create a new repository and copy path for future reference "https://github.com/vpkhachane/HelloWorldJava.git"
Go to git bash command Prompt-> 
set project working directory ex. cd C://NewMobileAutomation//VaibhavTestingPractice//
git init                           //to initialize empty git repository on GitHub
git status    //to check the git update status
git add .  //add files 
git commit -m "Hello Java Program" 
git remote add origin https://github.com/vpkhachane/HelloWorldJava.git 
git push -u origin master   
To download Project
git clone https://github.com/vpkhachane/FirstGitPractice.git

to download changes made by others
git pull 

Jenkins execute the HelloWorld Project after every change 

For Jenkin Scheduler. We can follow the following steps
1)Start Jenkins
2)Open Project
3)Configure->Build Triggers->
4)Tick Build periodically option
5)Add Scheduler criteria ex. use "* * * * *"for every 1 minutes , "*/2 * * * *" for every two minutes,
 "*/15 * * * *" for every 15 minutes
Rerer link for timer