MainMenu

Home Java Overview Maven Tutorials

Thursday, 30 March 2017

Test Strategy in Software testing

What is Test Strategy?


Plan to use the available resources to achieve objective effectively.
Note :- Test Strategy is a part of test plan.

Determing the test strategy


1). Test Levels
2). Test intensity
>...(thorough testing)
>.. (Medium testing)
>. (light testing)
>I (Implicit testing)
>S (Static testing)
Below is sample image of test-strategy document :-


Advantages of Test Strategy?


1).Mitigate Risk
2).Focus on Specific System Aspects
3).Provide Clarity
4).Communicate test approach

How to create a Powerful Test Strategy?

1- Research
2- Satisfy just the objectives
3- Create Two Versions
4- Minimize test phases
5- Customize Fully
6- Use Production Environment Replica
7- Use Known Tools
8- Define Process Or communication Mechanism
9- Identify Data needed
10- Challenge Assumption and
11- Revise Test Strategy as Needed.
Tags :-What is test strategy in software testing?How to create test strategy?

Sunday, 26 March 2017

How to Download and Install Appium on Windows



For Video : CLICK HERE


Click Here to download all appium software for windows except Andriod SDK



What is Appium?
Appium is an open-source tool for automating native, mobile web and hybrid applications on iOS and Android platforms.

List out the appium abilities ?
1). Supports most of the programming languages like java, ruby.
2). Use can test booth iOS and Android platform.
3). Supports automation of hybrid, native and web apps.
4). cross-platform
5). Backend is Selenium so you will get all selenium functionality
6). Doesn’t require an APK for use


Tools required for Appium with Eclipse on windows OS :


1). install the JDK(java development kit) in your machine
Download Jdk:- Click Here

1.1). Set java path in your machine
Navigate :- Control panel > System and Security > System > Advanced System Setting (click on it)
A popup window "System Properties" will get open
Navigate :- Advanced tab and click on Environment Variables.. button
Under System variables click on New button
Give the Variable name as ‘JAVA_HOME‘
Variable value as C:\Program Files\Java\jdk1.7.0_75
Click on Image


For path, select the path variable & click on Edit button
Now copy the java path up to bin folder & add it with ";"
append ;C:\Program Files\Java\jdk1.7.0_75\bin in the last
now click "OK" buttons.
Click on Image


1.2) Verify that java is installed properly or not
Open your commond prompt (ctrl+r, enter cmd, hit enter key)
type java -version & hit enter key
if below screen appears then Congratulation java is running in your machine.
Click on Image


2).Download and install microsoft .net framework Download .net framework :- CLICK HERE
If it is not present in your machine then Appium will not open you will get error "0xc000007b"

3). Download and Install the Andriod SDK Tools Download Andriod sdk : CLICK HERE

4). Setup Environment variable for Andriod Navigate :- Control panel > System and Security > System > Advanced System Setting (click on it)
A popup window "System Properties" will get open
Navigate :- Advanced tab and click on Environment Variables.. button
Under User variables click on New button
Give the Variable name as ‘ANDROID_HOME‘
Variable value as D:\study material\Selenium Final complete\Appium software\android-sdk-windows in your machine it will be different
Click on Image


4.1).Set the path variable for other 2 things, first is tools & second is platform-tools
Navigate :- Control panel > System and Security > System > Advanced System Setting (click on it)
A popup window "System Properties" will get open
Navigate :- Advanced tab and click on Environment Variables.. button
Under System variables find path variable select it and click on Edit button
Give the add path upto tools with ";" as D:\study material\Selenium Final complete\Appium software\android-sdk-windows\tools
again
Give the add path upto -plateformtools with ";" as D:\study material\Selenium Final complete\Appium software\android-sdk-windows\platform-tools
Click on Image


Now click "OK" buttons.

4.2).Verify that Andriod SDK is configured properly :- Open your commond prompt (ctrl+r, enter cmd, hit enter key)
type adb & hit enter key
if below screen appears then Congratulation Andriod ask is configured in your machine.
Click on Image


OR
Open your commond prompt (ctrl+r, enter cmd, hit enter key)
type android & hit enter key
if below screen appears (OR Android SKD manager will get open) then Congratulation Andriod ask is configured in your machine.
Click on Image


5). Install Andriod SDK packages as per your need in Andriod sdk manager.
Select the Android version & other stuffs as per your need & install them.


6). Download & install the nodeJs in your machine
Download node.js : CLICK HERE
Note : No need to set the NodeJs path, it will automatically set the path variable.

7). Download and install Appium client for desktop
Download Appium : CLICK HERE

Click here to download appium fron windows 32 bit from drive

8). Download pdanet+ for Andriod and install in your desktop
Download pdanet+ : CLICK HERE

9). Download pdanet+ for andriod in your andriod mobile from playstore & install it
It will appear as shown below


10). Activate developer option in your android mobile
In Android >go to > setting > About phone and click 7 times on Build Number
after that developer option will be available with in setting
as shown in below



click on developer options & check the USB Debugging option.


11).Download Gson jar file for eclipse

Download link : CLICK HERE

12). Download java client for appium & add in your project
Download javaclient : CLICK HERE
:) :) Tags :

How to download & configure appium in windows ?

Monday, 20 March 2017

How to Get LCM, HCF and average

what is LCM?



The Least Common multiple of two or more given numbers is the least or lowest number which is exactly divisible by each of them.
Example : Find the LCM of 36, 56, 105 & 108.
Solution: 36 = 2*2*3*3
56 = 2*2*2*7
105 = 3*5*7
108 = 2*2*3*3*3
Now take all the number with heighest power :
LCM : 2^3*3^3*5*7 = 7560

what is HCF?



HCF of two or more numbers is the greatest number which divides each of them exactly.
HCF is also known as Highest Common Divisor(HCD) and Greatest Common Measure(GCM).

Example : Find the HCF of 36, 42 & 126.
Solution:36 = 2*2*3*3
42 = 2*3*7
126 = 2*3*3*7
Now take the common number with lowest power :
HCF : 2*3

Important Formulas
1). Relation between the two numbers and their HCF and LCM is :
HCF * LCM = first Number * Second Number
2). HCF of fraction = HCF of Numerators/ LCM of Denominators
3). LCM of Fraction = LCM of Numerators/HCF of Denominators
Example : The LCM of 4/45, 6/15 and 12/21 is ?
Solution : LCM = LCM of Numerators/HCF of Denominators
= LCM of 4,6 and 12/HCF of 45, 15 and 21
= 12/3
= 4

Average


What is Average?
The average of a give observation or data is a number which is found on dividing the sum of observations or data by the number of observation or data given.
Average = Sum of observations/Number of observations Example : Find average of 3,7,9 & 13. Solution : 3+7+9+13/4
= 32/4
= 8.

Important Formulas
)1. Average of first 'n' natral numbers = (n+1)/2

2). Average of first 'n' even numbers = (n+1)

3). Average of first 'n' odd numbers = n

4). Average of consecutive numbers = (First Number + Last Number)/2

5). Average of '1 to n' odd numbers = (Last odd number +1)/2

6). Average of '1 to n' even numbers = (Last even number +2)/2

Saturday, 11 March 2017

Maven Tutorials For Beginners

For Video Tutorial : Move on Youtube Channel


Note : Select the playlist as per your need & move with number sequence


>


For Video :-

Part:-1


Part:-2

What is a Build Tool?

If you want to run your java code independently, then it is good to integrate your project with build tool.
This build tool will setup every thing which is requied to run your java code independently.
It makes programmer's life easy while handling the huge project by providing a common platform.
It generates source code, compiling code, packaging code to a jar etc.

What is Maven ?

Maven is a build tool and it performs very simillar to Ant which is a different build tool.
Basically Maven is a Software Project management tool which provides new concept of project object model (POM).
It allows the user to automate the process of creation of the initial folder structure, performing and compilation and testing and the packaging and deployment of the final project and makes it one step process to do a build. IT Makes build consistent with another project.
Maven is also used to manage the dependencies.

What problems does maven solves ?
For project development/Testing we need a lot of JAR files like Selenium, TestNG, Spring etc..
first we need to download them and then import these JAR files in build path in project.
but with Maven we just need to add the dependencies...

Maven will go out and download the JAR files for those projects for you.
and maven will make those jar files available during compile/run.

Maven Repository
This is the place where Maven stores all the projects jars files or libraries or dependencies. By default the folder name is `.m2` and by default the location in window 7 is ‘Libraries\Documents\.m2‘.

Maven Central Repository
Mavel central repository is the default location ‘http://mvnrepository.com/‘ for Maven to download all the project dependency libraries.


Maven Local Repository : Local machine repository with in folder .m2

maven Central Repository : https://repo1.maven.org/maven2

maven remote repository : https://mvnrepository.com



Features of Maven :-
1.You can view the output of Maven commands inside the Eclipse, using its own console.
2.It does the dependency management for Eclipse build path based on Maven's pom.xml.
3.It automatic downloads the required dependencies and sources from the remote Maven repositories.
4. It resolves Maven dependencies from the Eclipse workspace without installing to local Maven repository (requires dependency project be in same workspace).


Maven is a Software Management and comprehension tool and it is based on the concept
of Project Object Model(POM) which can manage project build, reporting and documentation
from a central peice of information.
All build syystems are essentially the same :
> Compile Source code
> Copy Resource
> Compile and Run Tests
> Package Project
> Deploy Project
> Cleanup
Developers of maven wanted :
> A standard way to build the projects
> A clear definition of what the project consisted of
> An easy way to publish project information and a way to share JARs across several projects.
> The result is a tool that can now be used for building and managing any java-based project.
> Intended to make the day-to-day work of java developers easier and generally help with the comprehension of any java-based project.


What is POM ?


"As a fundamental unit of work in maven, POM is an XML file that contains information about project and configuration details used by Maven to build the project".
POM Stands for Project Object Model :-
> Describe a project
> Name and version, Artifact Type, Source Code Locations, Dependencies.
> Plugins
> Profile(Alternate build configuration)
> Uses XML by default
> Not the way Ant uses XML


POM File Structure :

pom.xml :
Project meta data : Project name, version etc. Output file type : JAR, WAR...
Meta data Example :
<groupId> </groupId>
<artifactId><</artifactId>
<version>&/ltversion>
<packaging></packaging>
<name></name>
dependencies : List of projects we depend on Spring, Hibernate etc.
<dependencies></dependency></dependency>
</dependencies>
plug ins : Additional custom tasks to run : generate JUnit test reports etc.

Maven's Objectives


> Making the build process easy
> Providing a uniform build system
> Providing quality project information
> Providing guuidelines for best practices development
> Allowing transparent migration to new features.

Maven Build life cycle :
a). validate
b). compile
c). test
d). package
e). verify
f). Install


Example :
mvn compile : make available target folder
mvn test : surefire reports
mvn verify : verify jar file
mvn intall : put jar file under local repository

Maven Basic Commonds
maven clean : cleans the maven project by deleting the target directory

Example :
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ NewFramework ---
[INFO] Deleting D:\Software\Selenium\Validate_Samples\Eclipse_Workspace\NewFramework\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.783 s
[INFO] Finished at: 2024-01-21T19:04:57+05:30
[INFO] ------------------------------------------------------------------------





maven install : builds the maven project and install the project files(jar, war, pom.xml)

Example :
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ NewFramework ---
[INFO] Building jar: D:\Software\Selenium\Validate_Samples\Eclipse_Workspace\NewFramework\target\NewFramework-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ NewFramework ---
[INFO] Installing D:\Software\Selenium\Validate_Samples\Eclipse_Workspace\NewFramework\target\NewFramework-0.0.1-SNAPSHOT.jar to
C:\Users\cchauhan\.m2\repository\NewFramework\NewFramework\0.0.1-SNAPSHOT\NewFramework-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\Software\Selenium\Validate_Samples\Eclipse_Workspace\NewFramework\pom.xml to C:\Users\cchauhan\.m2\repository\NewFramework\NewFramework\0.0.1-SNAPSHOT\NewFramework-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.621 s
[INFO] Finished at: 2024-01-21T19:06:07+05:30
[INFO] ------------------------------------------------------------------------





maven test : run the test cases of projects

Example :
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
www.way2testing.com

[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.74 s - in TestSuite
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.766 s
[INFO] Finished at: 2024-01-21T19:08:09+05:30
[INFO] ------------------------------------------------------------------------







Install Maven in summarize form


> Install the JDK in your windows machine
> Add jdk path as "JAVA_HOME" variable in environment variable > User variable
> Add jdk bin path in path under environmental variable > system variable
> Set the Maven_Home, user variable & system variable under the Environment variable.
> verify that maven intalled(cmd >> mvn -version)

Method 1 :- Steps to install Maven in Eclipse

Step : 0. Open eclipse click on help then select the eclipse market place and in search box enter the Maven and hit enter


Alternatively you can also install the maven from Install new Software window.

Step : 1. Click on the help from the top menu in Eclipse and select Install New Software


Step : 2. Click on the Add button on the newly opened window.
Step : 3. In the Name box type your favorite name, i will type Maven and in location enter this link ‘http://download.eclipse.org/technology/m2e/releases/‘ and click on OK button


Step : 4.A check-box will appear in the pop window, Check the check-box and click on Next & Next button.
Step : 5. Accept the ‘Terms and Conditions‘ and move forward by clicking on Finish button.





Method 2 :- Step : 1. Download and Install java in your machine

Click Here for complete tutorial of Java Download & install

Step : 2.Setup java Environment Variable
Go to My Computer and select Properties
Now click on Change setting



In pop up window , click on Advanced tab and then click on Environment Variable


Step : 3. Click on New button under ‘System Variables..‘


Step : 4.Write ‘JAVA_HOME‘ in the Variable name box and enter ‘C:\Program Files\Java\jdk1.8.0_20‘ JDK path in the Variable value box and click OK. copy the path upto JDK, bin folder & edit the path variable & add it in the end.


Step : 5.Download Maven Click here to Download maven

Step : 6.Extract this zip file & copy he location in my case it is 'C:/apache-maven-3.2.3′
Step : 7.Set up the Maven Environment Variable the same way we set up the Java Environment Variable above.
Write ‘MAVEN_HOME‘ in the Variable name box then enter ‘C:\apache-maven-3.2.3‘ Maven path in the Variable value box and click OK.


Step : 8.Write ‘PATH‘ in the Variable name box then enter ‘C:\apache-maven-3.2.3\bin’ Maven path in the Variable value box and click OK.
Step : 9. Verify that Maven is installed properly or not
Open the commond prompt & type mvn -version as below :

If you see the result as above, then congratulation you have installed Maven in your machine
When you will create maven project, there will be two folders :

src/main/java
All the source code that you put, will display under the main/java package.

src/test/java
The code that you want to test, will display under test/java package.

Also :-
src/main/java : Your Java source code
src/main/resource : Properties/config files used by your app
src/main/webapp : JSP files and web config files other web assets(images, css , js etc)
src/test : Unit testing code and properties
target : Destination directory for compiled code. Automatically created by Maven.

what are the plugins in Maven?



Maven is based on plugin execution framework, you can also call plugin as feature of Maven where plugin use to do every task.

Plugins in Maven generally use to do :-

Create Jar/War file
Compile code files
Perform Unit testing on Test code (code which is present in src/test)
Create project documentation
Create Project reports.

Get Dependency

Selenium Dependency : Click here for selenium dependecies
Select the version that you want for your project.

Apache POI Dependency : Apache POI Dependency
Select the version that you want for your project.

TestNG Dependency : TestNG Dependency

PhantomJs dependency : Click here for PhantomJS Dependency
Select the version that you want for your project.

Get Maven Plugins



Maven Plugins :
Click here for Complier Plugin
Click here for Surefire plugin
Click here for TestNG plugin

Build Failure Error :

If you are getting some error, like JDK not found, src not available etc. then just copy the below code & paste it just above to </project> and update your Maven project

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile> </properties>
<dependencies>
<dependency> <groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> <dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.6.0</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>



If you are facing below issue
then here is the solution :-

Unable to locate the Javac Compiler in:
C:\Program Files (x86)\Java\jre6\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).



Open the eclipse --> Navigate to Window --> Preferences --> As shown in below image



Now in the popup window go to Java --> Installed JREs as shown in below image



Now select the JRE & click on Edit button as shown in below image



Now click on Directory button in JRE installer window as shown in below image



Now go to your directory "C" or where you have installed your JDK file, select it as shown below



After that click on OK, Apply, OK ans so on.....
Now refresh & update your project
Congratulation Your issue has been resolved. :)

Create Maven Project in eclipse



First i will create a Maven project in my eclipse as below :


In maven project, inside the main/test folder i will write my code , which will be tested.


Now open the POM.xml file and add the dependency & plugin as you want in your project & save it.


Now run your project as Maven test


Tags :

Maven Tutorials for Beginner

How to setup maven with eclipse

How to Install Maven in eclipse

Latest Maven Tutorial 2017

Maven Tutorial 2017

How to setup path variable for Maven

How to setup Environment variable for Maven

Wednesday, 8 March 2017

How to create xPath & Css path Manually

For Video Tutorial : Move on Youtube Channel


Note : Select the playlist as per your need & move with number sequence


There are Two types of xpath :-

Absolute Xpath :- It is the most straight forward way of locating a web element but the demerit for the absolute Xpath is that it gets failed when there are any changes made in the Xpath of the web element on the HTML document. It has a characteristic that it begins with a single forward slash character (‘/’) i.e. selecting an element starting from the root node. Following is the syntax cum example for an absolute XPath expression of the element
//*[@id="post-body-188624046246053988"]/h3[1]/a

Relative Xpath :- For this type of Xpath, the path begins from the middle of the HTML DOM (Document Object model) structure. It has a characteristic that it begins with a double forward slash character (‘//’) i.e. selecting a web element from anywhere of the web page. It has a benefit to begin from the middle of the HTML DOM structure and abstain from writing long XPath starting from the root node. Following is the syntax cum example for a relative XPath expression of the element.
Relative xpath: //*[@class=’class-test-box’]//*[text () =’SoftwareTesting’]


How to Create Dynamic Xpath & CSS Path :



Xpath with single attribute :
xpath Sysntax :
//tagname[@attributename = 'value of attribute']

For example :
//input[@id = 'uname']

xpath with multiple attribute :
xpath Sysntax :
//tagname[@attributename = 'value of attribute'][@attributename = 'value of attribute']
For example :
//input[@id = 'uname'][@class = 'input']

xpath with and :
//input[@id = 'uname' and @class = 'input']

xpath with or:
//input[@id = 'uname' OR @class = 'input']

xpath with contains :
//tagname[contains(@attributename = 'value of attribute')]

//input[contains(@id = 'pass')]

xpath with starts with :
//*[starts-with(@attributename , 'attribute value')]

//*[starts-with(@id, 'uname')]

xpath with following :
//*[text() = 'Discussion']//following::a[contains(@href, 'edit.php')]
-----------------------------------------------------------------------------

How to Create Dynamic CSS Path manually:


Sr No.AttributeSymbol
1.For Class NameUse . Symbol
2.For idUse # Symbol
3.For attributetagname[attribute = 'value']
4.For Multiple Attributetagname[attribute1 = 'value'][attribute2 = 'value']
5.Starts withUse ^ Symbol
6.Ends WithUse $ symbol
7.Containsuse * Symbol


------------------------------------------------------------------------------------------------

Difference between Xpath & CSS in Selenium


1).Xpath engines are different in each browser, hence make them inconsistent Css path works in each browser whereas xpath is limited with browsers for Example IE browser.
2).CSS was initially released in 1996 & xpath was initially released in the 1999.
3).CSS is easy as compaired to Xpath.

------------------------------------------------------------------------------------------------

Function to create run time xpath



public static String createXpath(String xpath, Object ...args){
for(int i=0; i<args.length; i++){
xpath = xpath.replace("{"+i+"}", (CharSequence)args[i]);
}
return xpath;
}

------------------------------------------------------------------------------------------------
// Assume getDynamicId() is the function that returns the dynamic ID
String dynamicId = getDynamicId();
String xpath = "//input[@id='" + dynamicId + "']";
WebElement element = driver.findElement(By.xpath(xpath));

------------------------------------------------------------------------------------------------