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

Summary of Web services and API testing using UFT

Summary of Web services and API testing using UFT

 

Web services

 
Demand of Web services is already high in the new internet era since applications are built in different technology / databases and connected through internet. So communication between is only possible through a commonly accepted media which are Web services
 
Web services are XML format based services which use media as HTTP to communicate and it is loosely coupled where there no hard binding with client.
 

WSDL

 
WSDL is a document in XML format which describes a web service and defines which transactions are available and data should be structured to send to those transactions.

WSDL (Web services description language) helps client to initiate the correct web service

Webserver client needs WSDL to initiate Web services and Web server providers generates WSDL.
 

UDDI

UDDI is the online directory which has all the WDSL available and all web services client gets that from UDDI.

Web services has two implementations.
1. SOAP

2. REST

SOAP

 
SOAP is the XML based implementation for web service and it has 3 main components which are
a. Envelope – represents root elements
b. Header – stores authentication, routing id for web service transaction.
c. Body – stores all data which are intended to transfer to webservice client.

SOAP uses HTTP as media for transferring data. Format used in XML.

REST

 
REST is more flexible implementation as it uses text format and media other than HTTP as well.
 

API testing using UFT

 
UFT is a software automation tool. Apart from automation test scenarios it supports API testing. Following AP testing are supported.
 

Web service

REST

 
In UFT user can create a new API project by clicking File > New > Test..
Select the  API Test type
Then navigate to tool box in the left
Click on Network once it’s exploded,
Drag HTTP Request to Test flow
Right click and select the properties
Fill the URL, select HTTP method as GET
Also you can configure the checkpoints.

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

Summary about Jmeter and performance testing

Summary about Jmeter and performance testing

Jmeter recording

How to create Jmeter scripts?

Recording Jmeter scripts using Jmeter’s HTTP(S) Test Script recorder. There are two ways

1)      Manually adding scripts ( Test plan >> Tread Group >> Add>> Sampler >> HTTP Request )

2)      Recording using Jmeter’s HTTP(S) Test Script recorder

How to record Jmeter scripts using HTTP(S) Test Script recorder

Prior doing that we need to configure browser and learn about the Proxy setup

Jmeter to Application server communication need to be routed through a browser Proxy for this recording purpose. For that you may need to select the Browser (here we can use Firefox browser”

1)      Navigate to Firefox >> Tools >> options >> Advanced >> Network >> Settings

2)      Select Manual Proxy configuration >> HTTP Proxy = localhost & Port = 8080

How to run Jmeter in Jenkins

steps:

Jenkins setup and performance plugin setup:
1) copy performance plugin into Jenkin’s home directry before you start the test.
2) to do that – you can download the performance plugin “performance.hpi” from the site https://wiki.jenkins-ci.org/display/JENKINS/Performance+Plugin
3) how to find the home directry of jenkins – to do that you can navigate to jenkins home page (localhost:8080) and then
4) click on “Manage Jenkins” and then click on “Configure system” the you will notice “Home directy” path in there.

Configure Jmeter and create a basic script in Jmeter:
5) download Jmeter Binary zip file from Jmeter site http://jmeter.apache.org/download_jmeter.cgi
6) unzip it and go to the “bin” directory of the Jmeter folder, wherre you will notice “user.properties” file.
7) open the file in notepad or notepad++ or any other text editor
8) add a line “jmeter.save.saveservice.output_format=xml” to that. Save and close the “user.properties” file
9) create a Jmeter script and make sure you can run it in non GUI mode i.e either in DOS mode or using shell scripts in MAC (note down the commands used in respective OS and it could be used in Jenkins job setup)
Note: for windows command line run, you can use the following commands

C:\[JMETER BIN directory]\jmeter.bat -Jjmeter.save.saveservice.output_format=xml -n -t C:\[JMETER script “.jmx” file] -l Jmeter_test_results.jtl

Note 1: For detailed topics on Jmeter scripts creation , please visit Jmeter , Jmeter recording 

setup Jenkin’s job to run Jmeter scripts
9) go to Jenkins home page (localhost:8080) and then click on “New Item” on “Freestyle project”
10) in the “New item” page, give some name in the item name field and go to below to section “Build” and add build step
11) add build step can be either a) “execute windows batch command” for windows or b) “Execute shell” for MAC
12) provide your command in there and save.
13) Click on “Build now” which would call the Jmeter (jmx) file and run the program
14) after the run, you can verify the Jenkins console to review the results.