Summary of Web services and API testing using UFT
Summary of Web services and API testing using UFT
Web services
WSDL
WSDL (Web services description language) helps client to initiate the correct web service
UDDI
UDDI is the online directory which has all the WDSL available and all web services client gets that from UDDI.
2. REST
SOAP
SOAP uses HTTP as media for transferring data. Format used in XML.
REST
API testing using UFT
Web service
REST
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>maven–surefire–plugin</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
Cucumber Scenario data table and Scenario Outline data table
1.Cucumber Scenario data table
Sample feature file contents as below:
Feature: Login and Logout Action
Scenario: Successful Login with Valid Credentials
Given User is on Application Home Page
When User Navigates to Application LogIn Page
And User enters UserName and Password and click submit button
|UserName|Pwd |
|abc | 123 |
Then Message displayed as Login Successfully
Corresponding Selenium script contents as below:
@When(“^User enters UserName and Password and click submit button$”)
public void user_enters_UserName_and_Password_and_click_submit_button(DataTable table) throws Throwable {
// Write code here that turns the phrase above into concrete actions
List<List<String>> data = table.raw();
driver.findElement(By.id(“IDTokenA1”)).sendKeys(data.get(1).get(0));
driver.findElement(By.id(“IDTokenB1”)).sendKeys(data.get(1).get(1));
driver.findElement(By.name(“Login.Submit”)).click();
// throw new PendingException();
}
2.Cucumber Scenario Outline data table
Sample feature file contents as below:
Scenario Outline: Login functionality for a website.
Given User navigates to Login page
When user enters Username as “<username>” and Password as “<password>”
Then login should be unsuccessful
Examples:
| username | password |
| ABC | 123 |
Corresponding Selenium script contents as below:
@When(“^user enters Username as \“([^\”]*)\” and Password as \”([^\”]*)\”$”)
public void user_enters_Username_as_and_Password_as(String arg1, String arg2) {
driver.findElement(By.id(“IDTokenA1“)).sendKeys(arg1);
driver.findElement(By.id(“IDTokenB1“)).sendKeys(arg2);
driver.findElement(By.id(“Login.Submit“)).click();
}
3.TestRunner sample code
package cucumberTestRunnerTest;
/*
* cucumberTestRunner sample code below
*
*/
import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;
import cucumber.api.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(format={“pretty”}
,features = “Feature” // refer the above feature file sample
,glue={“stepDefinition”} // note: need to create a package stepDefinition and create a regression scriptclass
,dryRun = false)
public class TestRunnerTest {
}
Note: JUnit runner uses the JUnitframework to run Cucumber using annotation – you could see in the above code that single empty class with annotation.
4.Maven pom.xml file sample needs the following dependencies if you want to use Maven for build automation.
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.0.14</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.0.14</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.1.5</version>
</dependency>
</dependencies>
5.If you do not want to use Maven for build automation, you can attach the following jars to your project Java Build path.
cucumber-java
cucumber-core
cucumber-junit
cucumber-jvm-deps
cucumber-reporting
gherkin
junit
mockito-all
cobertura
6.Regression test case script will be like this (refer the Test runner sample code point #3 above)
package stepDefinition;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
importorg.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.WebDriver;
import cucumber.api.DataTable;
import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class RegressionTest { // refer the Test runner sample code point #3 to see how the this code is mapped
WebDriver driver;
// run TestRunner.java file and get the out put from Console and copy/paste below:
@Given(“^User is on Application Login Page$”)
public void user_is_on_Application_Home_Page() throws Throwable {
// Write code here that turns the phrase above into concrete actions
driver = new InternetExplorerDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//throw new PendingException();
}
7. If you do not want to use the DataTable from feature file, always you can pull the data from XLS file using the logic below.
package yourpagename;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import java.io.File;
import java.io.FileInputStream;
importjava.util.List;
importjava.util.concurrent.TimeUnit;
importorg.openqa.selenium.By;
importorg.openqa.selenium.WebElement;
importorg.openqa.selenium.ie.InternetExplorerDriver;
importorg.openqa.selenium.support.ui.Select;
importorg.openqa.selenium.WebDriver;
importorg.testng.annotations.AfterClass;
importorg.testng.annotations.AfterTest;
importorg.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import Package.AnyotherClass; // if needed
public class AnyotherClassPage extends InitialClass
{
//WebDriver driver;
AnyotherClass ObjectName;
@Test(priority = 1)
public void Excel() throws Exception
{
ObjectName = new AnyotherClass (driver);
ObjectName.objectclick();
System.out.println(“Started executing Test Cases”);
// load excel file
File filePath = new File(“C:\\xxxxx\\ExcelFileName.xls”);
FileInputStream FS = new FileInputStream(filePath);
HSSFWorkbook WB = new HSSFWorkbook(FS);
HSSFSheet sheet = WB.getSheetAt(0);
int rowcount = sheet.getLastRowNum() – sheet.getFirstRowNum();
int colcount = sheet.getRow(0).getLastCellNum();
int a =0 ;
System.out.println(“Number of rows” + rowcount);
System.out.println(“Number of columns” +colcount);
for(int b=1;b<rowcount;b++)
{
HSSFRow row = sheet.getRow(b);
//for(int j=0;j<colcount;j++)
//{
//HSSFCell cell = row.getCell(j);
String excelCell1 = row.getCell(a).getStringCellValue();
String excelCell2 = row.getCell(a+1).getStringCellValue();
System.out.println(“XLS Values are — “ + excelCell1 + “—“ + excelCell2);
//}
ObjectName.NewMethod1(excelCell1);
ObjectName.NewMethod2(excelCell2); // code continues … …
What is TestRunner in Cucumber
TestRunner is a program used in Cucumber to access Feature file as copied in the picture below.
Feature file is something that has user requirement scenarios written in English which gives more readability and understandability of the requirement which is called Gherkin language.
So any roles in the company like 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 like Developer , tester, and end user,
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
Sample Test runner code:
4 Dimensional Arrays in Java
4 Dimensional Arrays in Java
Sample code for 4 Dimensional Arrays in Java
package javaArrays;
import java.util.Scanner;
public class FourDimArray {
public static void main(String[] args) {
int a[][][][] = new int[5][4][3][2];
int i,j,k,l, num = 1;
for (i=0; i<5; i++)
{
for(j=0; j<4; j++)
{
for(k=0; k<3; k++)
{
for(l=0; l<2; l++)
{
a[i][j][k][l] = num;
num++;
}
}
}
}
for(i=0; i<5; i++)
{
for(j=0; j<4; j++)
{
for(k=0; k<3; k++)
{
for(l=0; l<2; l++)
{
System.out.print(“a[“ +i+ “][“ +j+ “][“ +k+ “][“ +l+ “] = “ +a[i][j][k][l]+ “\t”);
}
System.out.println();
}
System.out.println();
}
System.out.println();
}
}
}
Summary on Cloud, Machine learning, Artificial intelligence and other emerging technologies
Summary on Cloud, Machine learning, Artificial intelligence and other emerging technologies
Salesforce
Salesforce.com is an American cloud computing company.
Salesforce offers Software as a Service (SaaS) platform which helps in Customer Relationship Management.
It has a multi-tenant architecture and subscriptions.
The following are the application clouds in Salesforce CRM.
- Sales Cloud
2. Service Cloud
3. Marketing Cloud
4. Data cloud
5. App Cloud
6. Analytics Cloud
7. Community Cloud
Salesforce also offers Platform as a Service (PaaS) using Force.com sites.
People involved in Salesforce Implementation
1. End User ( Customer)
2. Administrator
3. Developer
4. Consultant
The following are the list of Salesforce Certifications.
- Certified Administrator
2. Certified Advanced Administrator
3. Certified Sales Cloud Consultant
4. Certified Service Cloud Consultant
5. Certified Force.com Platform App Builder
6. Certified Force.com Platform Developer I
7. Certified Force.com Platform Developer II
8. Certified Technical Architect
What is Apex?
- Apex is a programming language for salesforce (only).
- Object Oriented Program, in which the data types have to defined.
- Allows developers for flow execution in force.com platforms.
- Enables developers to add business logic to most system events including button clicks, related record updates and visualforce pages.
Datatypes in Apex
- Primitives
Apex primitives include the following datatypes.
- Integer
- Boolean
- Decimal
- Double
- Date
- Date Time
- Time
- String
- Long
- ID- Any valid salesforce.com Id.
- sObjects
- Any object that can be stored in force.com platform database.
- sObject variable unlike primitive variable refers to row of data in salesforce. That is a complete record as a variable.
Hadoop MapReduce
Hadoop MapReduce is the main core components of Hadoop and is a programming model Hadoop MapReduce helps implementation for processing and generating large data sets, it uses parallel and distributed algorithms on a cluster. Hadoop MapReduce can handle large scale data: petabytes, exabytes.
Mapreduce framework converts each record of input into a key/value pair.
What is Blockchain and cryptocurrency
To understand more about Blockchain and crypto currency, lets explain about current Banking system works.
Current Banking systems : when a user does an online or ATM transaction , the centralized banking ledger verifies and confirm the authenticity of accounts. For that work, every bank or third party sites charges to user.
Blockchain is not like banking centralized ledger but this software uses a decentralized ledger across the thousands of computers and every transactions are updated in each and every ledger. That means everyone is aware of the transactions rather than a centralized bank stores all information and charges for that. There are volunteering systems who does this effort of maintaining all ledgers for block chain.
Block chain uses cryptography mythology to protect the ledger information so that no one can modify or destroy this.
Block chain concept is utilized by Crypto currency , online voting system, signature system, agreement systems etc.
Top 20 cryptocurrency 2017
bitcoin BTC
ethereum ETH
bitcoincash BCH
ethereumclassic ETC
litecoin LTC
einsteinium EMC2
dash DASH
ripple XRP
bitcoingold BTG
zcash ZEC
eos EOS
qtum QTUM
syscoin SYS
neo NEO
monero XMR
vertcoin VTC
iota IOT
powerledger POWR
omisego OMG
santiment SAN
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/
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/
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.
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.
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.
Summary about Jenkins, Selenium and QTP automation frameworks
Summary about Jenkins, Selenium and QTP automation frameworks
How to run Jenkins locally
1) go to https://jenkins.io and download Jenkins.war file
2) place the war file in a folder (e.g. C:\Jenkins\Jenkins.war )
3) then open command prompt (windows start menu > run > cmd will open command prompt )
4) in command prompt, go to folder C:\Jenkins\ ( command : “CD C:\Jenkins\” ) and then run command ” java -jar Jenkins.war ”
5) this will exract a folder name “.jenkins” into your user folder ( the path is usually “C:\users\”your login”\.jenkins”
6) copy “.jenkins” folder and paste to folder C:\Jenkins\, so that you have “C:\Jenkins\.jenkins” as the folder path.
7) Now you setup a Enviroment variable (to set up that go to Control panel > system > Advanced System settings )
8) then add Enviroment variable as “JENKINS_HOME” and value as “C:\Jenkins\.jenkins”
You all set to run Jenkins on your machine!
Open a browser and type “localhost:8080” to see Jenkins session.
Selenium features
Selenium supports Cross Browser Testing and parallel testing. The Selenium tests can be run on multiple browsers and multiple machines and multiple Operating systems. Selenium offers open source tools and supports test automation for web applications
Supports several scripting languages like Java, Python, C#, and PHP
Reporting are very easy and extensible, Selenium uses Browser native commands. It locates and actions applied on UI elements
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.
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
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.
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
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
How to run selenium tests in Jenkins
Jenkins configuration:
To run selenium scripts in Jenkins, Jenkins needs to started.
To make Jenkins server start, please use the following command in the Jenkins folder of your machine when Jenkins.warfile is downloaded from internet…
- “java -jar jenkins.war” in DOS / command prompt mode.
- Then you need to bring the browser up and type “localhost:8080” to see jenkins web UI ready.
- Then navigate to Jenkins >> Manage Jenkins and click on “Configure system”
- Then scroll down to see the “JDK installations” section in the pag
- There you enter “JAVA_HOME” for “JDK name” field.
- Provide the Java-JDK file folder path for “JAVA_HOME” field.
Note: Java-JDK file folder path is usually “C:\Program files\Java\JDK….”
Note: Disable “Install Automatically” check box else it will update with new Java versions and your selenium program might get conflicts
Selenium script development:
- create a package and class in Eclipse
- and then create a small test script – like print some message based on UI or Browser title name etc
- you could create a TestNG project
- Then TestNG.xml file will be created in Eclipse
Note: to get the XML folder path in project home directory, you could go to Eclipse project and right click to see properties.
Note: you also need to put all the jar files required for selenium testing under the lib folder(you may need to create”lib” folder)
Just to test your TestNG scripts are working, you can navigate to Project home directly (XML located) through DOS/Command prompt and then type as below:
Note: before that you need to set class path as bin directory of Project home folder. Command : “set classpath=C:\Selenium\project\bin;” as an example for binary file
Note1: similarly lib files, Command : “set classpath=C:\Selenium\project\lib\*” as an example
or command: set classpath=C:\Selenium\project\bin;C:\Selenium\project\lib\*;
Then execute testng.xml file through command prompt
command : java org.testng.TestNG testng.xml
Batch file creation for Jenkin execution
Create a batch file using notepad – steps
- Type the below contents in Notepad without quotes.
‘ java -cp bi;lib/* org.testng.TestNG testng.xml ‘
2) save the notepad as “runSelenium.bat” which will create a bat file. Place it in project home directory.
Jenkins job creation:
- Open Jenkins, then click on “New item”
- Enter item name as “JenkinSeleniumTest”
- Select “Freestyle project” , click Ok
- Then click on “Advance” button under the “Advance projects options”
- Then select “Use custom workspace”, then give the project home directory path in “Directory” field.
- Then “Add build setup” under “Build” and select “Execute Windows batch Command”
- Then type “runSelenium.bat” in the command field, click apply and save it.
- Then in the “JenkinSeleniumTest”, then click on “Build Now” which will call the batch file and then Selenium script internally.
- Verify the “Console output” in “JenkinSeleniumTest” which will show the Selenium execution results.
How to send email at every build with Jenkins
Jenkins default configuration setting allows to send email notification for build failure, someone breaks the build etc.
- To send email for every build Install Email-ext plugin.
- Once it is installed, click on Configure System
- Then in “Jenkins Location” section & “Extended E-mail Notification” – enter your email ids
- In “E-mail Notification” section, enter the SMTP server name to “SMTP server”
- Click “Advanced”, Click “Use SMTP Authentication” to enter required information
- verify “Test configuration by sending test e-mail”
- Configure a project to send email at every build
- Click “Add post-build action” and then Click “Editable Email Notification”
- Go to “Advanced Settings” to “Add Trigger”
- then Click “Always” , Save
Qtp script to close all open browsers ..
Call CloseAllBrowsers_ExcludingALM()
Function CloseAllBrowsers_ExcludingALM()
‘To ceclare Variables
Dim objDes, objList, objIndex
‘To Create Object Description for all opened browsers opened.
Set objDes=Description.Create
objDes.Add “micClass”,”Browser”
‘To get all the opened browsers objects from Desktop
Set ObjList=Desktop.ChildObjects(objDes)
‘Indexing always starts from “0”
For objIndex=0 to objList.count-1
‘To cverify the name of the browser is “HP Application Lifecycle Management”
If lcase(objList(objIndex).GetROproperty(“name”))<>”HP Application Lifecycle Management” then
‘Close the Browser
objList(objIndex).close
Exit For
End If
Next
Jenkins reset user password :
First stop the Jenkins service if you are already running jenkins
Go to the folder where jenkin’s config.xml file is stored (generally C:\jenkins\.jenkins\config.xml)
Open config.xml file using notepad++ or any text editor
Search for <useSecurity>true</useSecurity> and change that to <useSecurity>false</useSecurity>, Save the file.
re-start Jenkins service (using Java -jar jenkins.war in commandline)
You should not be seeing login prompt but directly accessing Jenkins home page when you type localhost:8080 in browser.
QTP integration with Jenkins
Create a “.vbs” file as below and save the file as “AOM.vbs” in C:\QTP\VBS folder.
In Jenkins create Job, Select ‘Execute Windows Batch Command’ in Build Step. Enter below command.
and then use that in Jenkins.
Note: To learn how to create a Jenkins job or how to start Jenkins – please refer create a Jenkins job and Run Jenkins locally in my site.
Below code is the “AOM.vbs” which is called by Jenkins Job.
Call QTP()
Public function QTP()
‘Create Quick test pro(QTP/UFT) object
Set objQTP = CreateObject(“QuickTest.Application”)
objQTP.Launch
objQTP.Visible = True
‘to open QTP Test
objQTP.Open “Test file path “, True
Set objResults= CreateObject(“QuickTest.RunResultsOptions”)
objResults.ResultsLocation = “Result path of qtp” ‘Set the results location
‘to run qtp script results
objQTP.Test.Run objResults
‘to close QTP
objQTP.Test.Close
objQTP.Quit
End function
Summary on Web testing and mobile apps
Summary on Web testing and mobile apps
What is the difference between Web Layer (Presentation Tier) vs Application Layer (Logic Tier) vs Database Layer (Data Tier)
- Presentation Layer is the interface to outside world e.g. web site.
- Application Layer is a framework to create the interface to the Web site or Presentation Tier
- Database Layer is the database and associated logic needed to query details.
Web Layer (Presentation Tier)
Contains Virtual Machines and Physical Machines with OS can be Windows, UNIX or Linux
Contains Apache web Server, Apache tomcat, Sun Java Web Server or MS Internet Information Services (IIS)
Application Layer (Logic Tier)
Contains Virtual Machines and Physical Machines with OS can be Windows, UNIX or Linux
Contains Apache tomcat, Red Hat JBoss, BEA Web Logic or IBM WebSphere app server
Database Layer (Data Tier)
Contains Virtual Machines and Physical Machines with OS can be Windows, UNIX or Linux
Contains SQL or Oracle
How to Use WhatsApp in a Web Browser?
1) Go to web.whatsapp.com in a web browser on a computer.
2) Then, on your iOS/Android/Windows mobile phone, open WhatsApp and press the Options on top right corner side
3) then press WhatsApp Web from the options.
4) use iOS/Android/Windows mobile phone to scan the QR code shown on the browser on your computer.
Headless web browsers
headless web browsers or programs are used to stimulate the browsers where there is no GUI is used for browser actions,
If you want to do browser operations or collect data from UI, there programming concepts will be used.
headless web browsers are listed as below,
HtmlUnit – No GUI browser for Java programmers and its pure java implementation, Open source programs. JavaScript support/DOM emulated. mainly used for used for testing purposes or to retrieve information from web sites.
Spynner – Programmatic web browsing module having AJAX support for Python
Ghost – it is a webkit web client written in python. it is WebKit-based. JavaScript supported and Open source.
Watir-webdriver- it an open source Ruby library for automating tests. Complete JAva script Support via Browsers
Twill – Allows users to browse the Web using command-line interface . Supports automated testing on web applications and Open source.
Awesomium – is Chromium-based. and supports JavaScript and provides HTML-powered interfaces.
ZombieJS – Open source headless testing using Node.js. JavaScript support/emulated DOM.
SimpleBrowser – Open source web browser engine designed for automation tasks. It is built for .Net framework and No JavaScript support.
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.
- 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.
- 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
- User collaboration
- Due to user collaboration, we can make sure all the critical application are automated
- Due to user collaboration, we can make sure all the critical features in every important applications are automated
- 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.