What is Selenium Grid Extras

WHAT IS SELENIUM GRID EXTRAS

Selenium Grid Extras is the enhanced Selenium Grid having more features like auto upgrade of browsers and Video recording enabled for error debugging purposes. Following Additional benefits due to Selenium Grid extras,

  • Explicitly kills browsers after the test
  • Increased stability for the automation
  • Better support for IE on nodes
  • JVM clearing is done by restarting the Java process on the Nodes by Grid Extras, this happens periodically whenever Node is not in use.
  • Extras can restart the OS after 15 – 20 tests which boosts the performance on Nodes.

What is google App Engine

What is Google’s App Engine ?

Google provides platform as service or PaaS via Google’s App Engine.App Engine is a cloud computing platform where development and hosting of applications can be done.Other feature is App engine scales up on demand basis when the requests are more.
App Engine supports almost all development technologies like Go, Java , Python, .NET, ruby.
Python web frameworks like Flask, Django all can run on App Engine.

DevOps vs DevSecOps vs NetOps

What is DevOps vs DevSecOps vs NetOps ?

DevOps is the practice of using set of tools, processes and practices to get good agility in software implementation to customers. It combines Dev (software development ) and Ops (information operations). DevOps shortens the development lifecycles and provides Continous Integration & Delivery. 
DevSecOps is when security features are included in DevOps CI/CD flow.
NetOps is when network services are packaged to DevOps.

Jenkins job vs pipeline

What is Jenkins jobs and Jenkins pipeline ?

Jenkins jobs and Jenkins pipeline are essentially same, however pipeline is more staged flow of jobs. For Jenkins pipeline, Jenkinsfile is used.
What is Jenkinsfile?Jenkinsfile is a text file placed in the root project directory. The Jenkinsfile has multiple stages like build, unit test, sonar test, functional,  regression, integration,  performance testing, deployment etc.

Selenium Tutorial

Selenium and Jenkins

Selenium features as below

 Selenium supports Cross Browser Testing. The Selenium tests can be run on multiple browsers and multiple machines and multiple Operating systems.

Supports several scripting languages like Java, Python, C#, and PHP.

Selenium uses Browser native commands. It locates and actions applied on UI elements,

Reporting are very easy and extensible.

TestNG quick summary:

 TestNG’s is Selenium + reporting features. It is easy to generate reports using Listeners and Reporters in TestNG

 Features of TestNG includes the following,

1)      Annotations – please refer my annotation blog Annotation – TestNG’s test case priority

2)      Supports parameterization/ data driven testing

3)      Test cases can be grouped and parallel testing is allowed.

Automaton testing using Cucumber – Behavior driven development (BDD)

Application behavior is the main focus on BDD. The requirements are written in English which gives more readability and understandability of the requirement.

So any roles in the company (Tester, developer, end user, and techno functional person) can read it and understand it. Also this will reduce the complication in terms of missing requirement or misrepresenting or misunderstanding requirements between different roles (Developer /tester / end user)

Gherkin is a business readable language – refer below for an example. Below feature file is integrated with Selenium and are having user stories as below.

Please refer below – “feature, Scenario, Given, When, And, Then “are the Keywords below to understand on how to write a feature file.

Selenium jenkins integration steps are as below:

Jenkin related steps:
1) start jenkins by running command in DOS prompt (detailed steps in here )
2) then make sure you are able to access url : localhost:8080
3) then you need to configure jenkins to run the selenium scripts – for that click on “Manage Jenkins”
4) then click on Configure systems
5) Find out the jdk files are installed (usually in C:\ program files … folder path) and copy paste the path in JDK section “JDK Installations” in ” Configure systems” which you are already in.
6) Give JDK name “JAVA_HOME” and provide Java path below in the next field.Selenium related steps:
3) Open eclipse IDE and start new Java project
4) make sure you added selenium jars (Selenium server standalone jar file which you can download add to new project) to support selenium framework for your automation testing.
5) then create a simple selenium script – make sure it is running and completing successfully in Eclipse.
6) Also create a xml file give a name “Xml1.xml”  Make sure Run “Xml1.xml” as “TestNG Suite” is working fine in Eclipse. Also notedown the xml file path in selenium project. create a lib folder in that and add all jar files which are required.Commmand prompt:
7) navigate to that project folder in command prompt and set all required classpath like bin and lib etc which are already in xml file folder in selenium project which you got from selenium project in eclipse.
8) then type command “Java org.testng.testNG Xml1.xml” which will display results in command prompt/DOS screen
9) now create a batch file “Batch1.bat” which contains the above command and also a command for compiling as e.g “java -cp bin;lib/* org.testng.testNG Xml1.xml”Jenkins setup to build and run the file:
10) in Jenkins, create a “new item” with selection of “Freestyle project”
11) then select “Advance options” and put the Selenium project home directory path in there.
12) the build trigger section, select Batch file execution option in there, then put the batch file name “Batch1.bat”
13) click and save the new item
14) click on “Build Now” and verify the “Console output”

How to configure Hub & Node machines for selenium parallel test execution
Configuring Hub machine

1) Start the command prompt/DOS prompt

2) Navigate to the folder location where the Selenium server jar file is kept.

3) Type java –jar selenium-server-standalone-[VERSION].jar –role hub

Note: [VERSION] is the one your downloaded version of selenium-server-standalone Jar file.

Your will see the below screen

Selenium Hub
Selenium Hub

4) Now type: http://localhost:4444 in browser

Your will see the below screen

5) Now type: http://localhost:4444/console in browser

You will see the below screen

Console

Configuring Node machines

Follow the same steps 1 to 2 in node machines

Then type,

Java –jar selenium-server-standalone-[VERSION].jar –role node –hub http://yourHUBmachineIP:4444/grid/register

Selenium Node

What is TestRunner in Cucumber

In order to link Cucumber with Selenium WebDriver, you need to start a Java project in eclipse IDE.

Then, add both Cucumber and Selenium jar files

Write test runner code and execute the same . Please refer BDD testing details on Selenium Cucumber

QA Automation Interview questions

QA Automation Interview questions

  1. Differentiate final , finally, finalize (Short Ans: final method can’t be overridden, final variable can’t be changed, finally goes with try/catch, finalize is garbage collector)
  2. how to handle exceptions in java (Ans: try catch, throws, etc)
  3. how to use parameters in cucumber/testNG (Ans: scenario outline,tidy gherkin plugin, vs testng.xml-suite,test,class,method;)
  4. compare TestNG and Cucumber BDD (Ans: testng.xml, POM,vs feature file,Junit testrunner,stepDefention, POM)
  5. how to validate flatfiles , db using Java (Ans: input filestream, driver class connection, server name, instance , authentication, sql statement)
  6. how to skip method/test in TestNG, Cucumber BDD (Ans: testng.xml, annotation, cucumber tags on testrunner)
  7. differentiate encapsulation , abstraction
  8. what are interface and explain the methods – webdriver interface, driver object reference, FF/IEdriver class (Since interface can not be instantiated)
  9. write programs – sort array, print number in reverse, print string reverse, etc
  10. how does SSL works , public key-private key, session encryption etc
  11. method overridden vs method overloading (super class methods are overridden by child class when both has same methods, overload – one class has multiple methods with same method name but different parameters)
  12. Selenium automation challenges (ajax – webdriver wait methods, frames switch, alert.accept, multiple windows handlers, pdf in webpage, alert vs modal confuse, dynamic id,name-use xpath contains, etc)
  13. handle dropdown – select class
  14. feature file extension
  15. bufferbuilder usage
  16. what is background, scenarios outline, before/afterhooks vs tags, 
  17. usage of autoit, robotclass, javascript executor, 
  18. Jenkins schedule batch, report generation, 
  19. grid setup, hub and node, run on dos prompt, or use JSON file to configure nodes and run JSON on commandline..then connect in Jenkins 
  20. how to manage Git versions between two teams
  21. What is data structure and use of it test automation

Maven TestNG framework with reporting features and switching pages

Maven TestNG framework with reporting features and switching pages

 

1.  Setup a Maven project in Eclipse with POM file as below

Refer the Post-Man plugin highlighted below in yellow

Refer the reporting directory path highlighted below in yellow

 

POM file sample as below – you can copy paste this contents for any Maven TestNG project.

 

<project xmlns=“http://maven.apache.org/POM/4.0.0” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>

  <modelVersion>4.0.0</modelVersion>

  <groupId>MavenProject</groupId>

  <artifactId>MavenProject1</artifactId>

  <version>0.0.1-SNAPSHOT</version>

  <dependencies>

       <dependency>

              <groupId>junit</groupId>

              <artifactId>junit</artifactId>

              <version>3.8.1</version>

       </dependency>

       <dependency>

              <groupId>org.testng</groupId>

              <artifactId>testng</artifactId>

              <version>6.8</version>

       </dependency>

         <dependency>

                  <groupId>com.relevantcodes</groupId>

                  <artifactId>extentreports</artifactId>

                  <version>2.41.1</version>

         </dependency>

       <dependency>

              <groupId>org.seleniumhq.selenium</groupId>

              <artifactId>selenium-java</artifactId>

              <version>2.45.0</version>

       </dependency>

 

       <dependency>

              <groupId>net.sourceforge.jexcelapi</groupId>

              <artifactId>jxl</artifactId>

              <version>2.6.12</version>

       </dependency>

       <dependency>

              <groupId>org.apache.poi</groupId>

              <artifactId>poi</artifactId>

              <version>3.17</version>

       </dependency>

  </dependencies>

  <dependencyManagement>

       <dependencies>

              <dependency>

                     <groupId>org.jxl</groupId>

                     <artifactId>jxl</artifactId>

                     <version>2.6</version>

              </dependency>

       </dependencies>

  </dependencyManagement>

 

   <build>

        <plugins>

              <!– Suirefire plugin to run xml files –>

               <plugin>

                     <groupId>org.apache.maven.plugins</groupId>

                     <artifactId>mavensurefireplugin</artifactId>

                     <version>2.18.1</version>

                     <configuration>

                           <suiteXmlFiles>

                                  <!– TestNG suite XML files –>

                                  <suiteXmlFile>testng.xml</suiteXmlFile>

                           </suiteXmlFiles>

                     </configuration>

              </plugin>

       <!– Post-Man plugin –>

              <plugin>

                     <groupId>ch.fortysix</groupId>

                     <artifactId>maven-postman-plugin</artifactId>

                     <executions>

                           <execution>

                          

                           <id>send an email</id>

                           <phase>testEmail</phase>

                           <goals>

                           <goal>send-an-email</goal>

                           </goals>

                           <inherited>true</inherited>

                          

                           <configuration>

                                  <!– From Email address –>

                                  <from>[email protected]</from>

                                 

                                  <!–  Email subject –>

                                  <subject>Test Report</subject>

                                 

                                  <!– Fail the build if the mail doesnt reach –>

                                  <failonerror>true</failonerror>

                                 

                                  <!– host –>

                                  <mailhost>smtp.gmail.com</mailhost>

                                  <!– port of the host –>

                                  <mailport>465</mailport>

                                  <mailssl>true</mailssl>

                                  <mailAltConfig>true</mailAltConfig>

                                 

                                  <!– Email Authentication(USername and Password) –>

                                  <mailuser>[email protected]</mailuser>

                                  <mailpassword>pwd</mailpassword>

                                 

                                  <receivers>

                                         <!– To Email address –>

                                         <receiver>[email protected]</receiver>

                                  </receivers>

                                 

                                  <fileSets>

                                  <fileSet>

                                         <!– Report directory Path –>

                                         <directory>C://Projects//Eclipse//workspace//Mavenproject//Reports</directory>

                                         <includes>

                                                <!– Report file name –>

                                                <include>**/*.html</include>

                                         </includes>

                                         <!—as mentioned above Regular Expression **/*.html to send all the html files reports–>

                                         </fileSet>

                                  </fileSets>                      

                          

                           </configuration>

                           </execution>

                     </executions>

              </plugin>

      

       </plugins>          

  </build>

    

</project>

 

2.      Setup a Page factory package where all the object locators are stored. E.g. code like this below.

 

package ProjectPageFactory;

 

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.FileReader;

import java.util.Iterator;

import java.util.List;

import java.util.NoSuchElementException;

import static org.testng.AssertJUnit.assertEquals;

import java.io.FileInputStream;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.ie.InternetExplorerDriver;

import org.openqa.selenium.support.CacheLookup;

import org.openqa.selenium.support.FindBy;

import org.openqa.selenium.support.PageFactory;

import org.openqa.selenium.support.ui.Select;

import org.testng.annotations.BeforeSuite;

import org.testng.annotations.BeforeTest;

import org.testng.annotations.Test;

import org.openqa.selenium.support.ui.WebDriverWait;

import org.testng.annotations.Test;

 

 

public class yourFirstpageofApplication {  // this is were you can build the locators repository.

               

                WebDriver driver;

                               

                @FindBy(linkText=”LocatorHyperlinkTextName”)  // type the Locator Hyperlink Text Name

                @CacheLookup  // use CacheLookup for any non dynamic objects , this will improve exection performance.

                WebElement Hyperlink1;

               

                @FindBy(xpath=”html/body/form/divXXXXXXX/xxxx”)

                // @CacheLookup – do not use CacheLookup for any dynamic objects

                WebElement objectName1;

 

2.   Setup a test script code that communicates to Pageobject repository

 

public class applicationPageName extends initialiseDriver  // refer step 3 for initialiseDriver example.

{

      

       //WebDriver driver;

       yourFirstpageofApplication AppObj;

 

       @Test(priority = 1)

       public void Excel() throws Exception

       {

                    

              AppObj = new yourFirstpageofApplication(driver);

              AppObj.ordinqclick();  // this will navigate to PageObject repository code and do action on application.

 

          Note: Basically both classes (Test scripts and Pageobject repository script) will communicate.

 

3.   Reporting code

 

package TestscriptProject;

 

import java.io.File;

import java.io.FileInputStream;

import java.util.List;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.ie.InternetExplorerDriver;

import org.openqa.selenium.support.ui.Select;

import org.openqa.selenium.WebDriver;

import org.testng.annotations.AfterClass;

import org.testng.annotations.AfterTest;

import org.testng.annotations.BeforeTest;

import org.testng.annotations.Test;

import org.testng.asserts.SoftAssert;

 

import com.relevantcodes.extentreports.ExtentReports;

import com.relevantcodes.extentreports.ExtentTest;

import com.relevantcodes.extentreports.LogStatus;

 

import org.apache.poi.hssf.usermodel.HSSFRow;

import org.apache.poi.hssf.usermodel.HSSFSheet;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

 

 

import PageFactoryProject.ApplicatonPageScriptClass;  // make sure you import that to this class

 

public class orderInquiryPage extends driverInitialise

{

      

       //WebDriver driver;

       yourFirstpageofApplication AppObj;

                     ExtentReports report;

              ExtentTest logger;

 

       @Test(priority = 1)

       public void Excel() throws Exception

       {

                     report = new ExtentReports(“./Reports/OrderInquiryReport.html”);

                     logger = report.startTest(“csvFile”);

              logger.log(LogStatus.INFO, ” test case started”);

      

             

                     //Pass the test in to report

                     logger.log(LogStatus.PASS,”Test verified Pass for particular functionality”);

                          

                     //End of the test

                     report.endTest(logger);

                                        

                     //clear the data in report

              report.flush();

 

4.   Switching between child window/page and parent window/page

 

To switch to a child window or page

public void childWindowHandle()

{

       childHandle = driver.getWindowHandles().toArray()[y].toString();   // y = 1

       driver.switchTo().window(childHandle);

}

 

To switch to a parent window or page

 

public void parentWindowHandle()

{     

       parentHandle = driver.getWindowHandles().toArray()[x].toString(); // x = 0

       driver.switchTo().window(parentHandle);

}

Cucumber Scenario data table and Scenario Outline data table

Successful test automation

Successful test automation approach – simplest way to build cost effective automation frameworks which can give better ROI.

To maximize automation benefits in terms of best output and cost effectiveness is by implementing best matching framework based on your product line.

When an organization plans for cost effective automation frameworks, they can always consider 2 types of frameworks to start having maximized results with less effort and cost. Basically optimizing your efforts and get better ROI relatively in less time. 

  1. User acceptance testing – Find out a Behavioral driven development (BDD) framework – either cucumber selenium or Robot Framework. I will explain about Cucumber Selenium framework in this article and will explain the reason for including one BDD Framework for your automation. With the help of Business team, identify the most critical applications and most critical functionalities. Once you have BDD framework is ready, you can make sure it is running every day and sending our reports using Jenkins integration. Which will make your automation is ready to Join the DevOps culture. As most of the companies like google, amazon etc have already adopted DevOps while ago.
  1. Regression testing – You can follow any regular automation approach and adopting DevOps, continuous testing, monitoring and reporting. You can opt data driven or keyword or hybrid based on your expertise and application type. 

Let me give an example when you consider the type 1 which is BDD for acceptance testing. 

The very reason for BDD is that it can utilize business user’s collaboration in automation. This is the easiest way to get business team’s association on your automation efforts.

In my opinion, when you compare within different BDDs, cucumber has upper edge as opposed to Robot Framework as simplicity in it that will help business user involve easily.

As an e.g. cucumber frameworks need feature file and typical feature file example will have user scenarios as below,

Feature: Login Action

Scenario: User successfully Login to application with valid user id and password

            Given User is on application login prompt page

            When User enters User name and password

            Then Message displayed as Login is successful

Scenario Outline: data parameter test

            When User navigates to application search screen

            Then user input “<InputInfo>” as “InputVal”

Examples:

            | InputInfo |

            | ABC1  |

            | ABC2 |

In the above example you can see that a business user can simply follow the format for above 2 test cases which is written in feature file.

1)    Scenario

2)    Scenario Outline:

Later automation architect or engineer can develop test runner file and convert this as automation test scripts. Please refer link for more details about cucumber framework.

Benefits

  1. User collaboration
  2. Due to user collaboration, we can make sure all the critical application are automated
  3. Due to user collaboration, we can make sure all the critical features in every important applications are automated
  4. Due to Jenkins integration, you can make sure test can be scheduled for every day run, to make application as robust in terms of quality.

How to Implement Maven TestNG Selenium Grid project

How to Implement Maven TestNG Selenium Grid project

High level Steps:
note: I will be adding detailed description for each steps below,

1. Install Eclipse Editior
2. In Eclipse, navigate to “Help >> Install New Software” then install Maven plugin.
3. Create a Maven project, which will have a pom.xml having the option to add all dependencies jars.
     like TestNG, XLS API jars, Reporting jars etc.
4. Once that is made, convert the project into TestNG project that process will generate another xml file. (name it as testng.xml)
5. Now in Eclipse project, create a package and class. Write your programs in it.
6. In the testng.xml, mention the class names which will be included while run.
7. Now right click on pom.xml file and run as “Maven test” which will download dependency jars and store to project and then run the program.