div.menu4 { /*width:500px;margin:0 auto;*//*Uncomment this line to make the menu center-aligned.*/ text-align:center; font-size:0; height: 25px; *position:relative;*top:1px;/*Hacks for IE6 & IE7 */ } div.menu4 a { display: inline-block; margin-right:6px; /* It specifies the distance between each tab */ background:#FFF url(bg.gif) repeat-x 0 0; padding-left:4px; vertical-align:top;/*ChangeSet#1*/ text-decoration:none; } div.menu4 a span { display: inline-block; background:#FFF url(bg.gif) repeat-x 100% 0; padding: 0 20px; text-decoration:none; font: normal 12px Arial; line-height: 25px; color:#7087A9; vertical-align:top; } div.menu4 a:hover, div.menu4 a.current { background:#FFF url(bg.gif) repeat-x 0 -25px; line-height: 26px; } div.menu4 a:hover span, div.menu4 a.current span { background:#FFF url(bg.gif) repeat-x 100% -25px; line-height: 26px; color:#244D8A; } div.menu4sub { height:8px; border:1px solid #C2D5EF; background:#eee url(bg.gif) repeat-x 0 -50px; }

Wednesday, 24 February 2016

Selenium Automation

Selenium WebDriver - Arhitecture


I Try And Simplify as much as really possible to understand the way the architecture of Selenium formed.
Selenium WebDriver Divided into 3 major sections

1. Level Bindings that are language
2. Selenium WebDriver API
3. Drivers

Language Degree Bindings:

We've got a common API which has a common set of instructions and we've different bindings for the languages that are different. So we could see there's Java, Python, Ruby, etc..There Is also some other bindings and new bindings can be added quite easily.

Selenium WebDriver API:

Now these bindings communicate with Selenium WebDriver API and this API deliver the commands taken from language level bindings inter-Pret it and sent it to Specific driver. In short-term API contains set of common library which allow sending command to respective drivers.

Drivers:

Internet Browser Special Drivers such as IE, FF, Chrome etc..It functions in headless mode which makes, text execution quicker. Additionally, it contains mobile Drivers that are specific.

 The basic notion is each one among these drivers understands the way to drive the browser that it corresponds to.

For E.g. Chrome Driver understands how to handle the low-level details of chrome driver and drive it to do things like clicking the target element, browsing the target page etc...

How it's operating:

You might be writing your test in Java utilizing typical that instructions are being sent by Java binding across this API that is typical and selenium API. Now on another end is listening a driver, it interpret those commands and executing them on the actual browser and return result copy using the API.

Selenium Webdriver - Page Object Model:

  • Developing an automation code that is maintainable is just one of the keys to some successful test automation Task. Test-automation code has to be treated as creation code and standards that are similar And patterns should to be applied while developing this code.

  • While building Selenium Web Driver evaluations, we can use the Page Object model pattern. This Pattern assists in improving the tests, making them exceptionally maintainable, cutting back the code duplication, concealing the internal execution from tests, and creating a layer of abstraction.Utilizing the Webpage Object Model

  • By applying object oriented advancement principles, we can develop a category that serves as an Interface to some web site in the program, modeling its qualities and conduct. This helps In making a layer of separation involving the test code and code specific to the page, by hiding the technical execution including locators used to recognize components on the page, layout, etc. 

  • The Page Object design pattern provides tests for an interface in which an evaluation can work on that page in a way much like the consumer accessing the page, but by concealing its internals. 

  • As an example, if we build a Page Object evaluation for a log-in page, then it'll provide A method to login, that will accept the user name and password and simply take the user to the Welcome page of the program. 

  • The evaluation need not worry about input controls are employed for the login page, their locator details, etc.Evaluations should use objects of a page in a high degree, where any change in lay out or characteristics used for the fields in the inherent page must not break the evaluation.

  • This chapter covers recipes to create tests using relevant design and Page Item model. For exposing, using the PageFactory type elements from a page

  • For executing the Page Object model in tests, we must chart and produce a Page Item Type for every page being analyzed. For example, to test a BMI, the BMI Calculator program. Calculator page category is going to be defined. 

  • That will show the internals of the BMI Calculator Page to the evaluation, as shown in following diagram. This can be performed through the use of the PageFactory class of Selenium WebDriver API. Sample Codes will soon be posted soon......


WebDriver - Catching Screen shot:

This may help when test run and exceptional malfunctions during execution, by Utilizing the web page will be Captured by the TakeScreenhot Interface WebDriver.
Sample Code:

@Test

public void testScreenshot()
{
try {
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\Screeshots\\Loginpage.png"));
} catch (Exception e) {
e.printStackTrace();
}
}


How It Works....

The TakesScreenshot interface supplies the getScreenshotAs() method to catch
a screen capture of the page shown in the driver example. In the below code , we
Defined OutputType.FILE as an argument to the getScreenshotAs() approach.

So that it will return the captured screen shot in a file:
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

We can save the file object returned by the getScreenshotAs() approach using the
copyFile() procedure of the FileUtils class

WebDriver - Automating Dropdowns Using Select Class:

WebDriver supports Automating Drop Down and List controls using a unique "Select" category in the place of the WebElement category.

Let's produce a test for a Drop-Down management. This test will perform some basic tests and after that call various methods to choose alternatives in dropdown.

Sample Code:


@Test

public void testDropdown() {
//Get the Dropdown as a Select using its name attribute
Select make = new Select(driver.findElement(By.name("make")));
//Verify Dropdown does not support multiple selection
assertFalse(make.isMultiple());
//Verify Dropdown has four options for selection
assertEquals(4, make.getOptions().size());
//With Select class we can select an option in Dropdown using visible Text
make.selectByVisibleText("Admin");
assertEquals("Admin", make.getFirstSelectedOption().getText());
//or we can select an option in Dropdown using value attribute
make.selectByValue("Manager");
assertEquals("Manager", make.getFirstSelectedOption().getText());
//or we can select an option in Dropdown using index
 make.selectByIndex(0);
assertEquals("Contributor", make.getFirstSelectedOption().getText());
 }


Selenium Automation Framework Layout:

To design a framework we need to focus on the following factors.
1. We must create UI Map
2. Libraries for UI objects.
3. Layout groups depending on use under test.
4. Plan for evaluation execution approach to minimize the time.
5. Design report generation.
6. Prepare step suite and a Step table.
7. Prepare a Data established whereever needed
8. Design Key Word Driven activity fixtures
9. Design and develop the code that is psudo.

Frame function has several varieties and most well-known are the below
a.Keyword driven frame work
b.Data driven driven frame work
c.Hybrid framework

Key word Driven Frame work:

Keyword driven framework is an action based test approach used in planing and implementation of automation.

Data Driven Framework:

Data driven is the layout of possible inputs what may distributed by by the end-user. This may cover maximum probabilities of an input information. It may be Spread sql or sheet. We need to link and move the values to component or the specific field.

The experienced person on the project should designs the data. It could be even or a client non specialized person but should be more familiar with consumer would-be.
We need to chart the file path properly.

Hybrid Frame Work:

Hybrid Framework is only the mixture or the group of some frame work according to the frame work programmer it can be called by us as framework.

  1. Sample Template - Frame work Psudo Code
  2. Sample Template - Step Table
  3. Sample Template - Data Set
  4. Sample Template - UI Map


Simple Startup in Web Driver:

Web driver is a java interface which is having bunch of executing types and capabilities which we can send from javadocs in selenium official site.

Download newest java consumer variation from http://seleniumhq.org/download/. Its a zip pack, Unzip and go to eclipse Generate new java project and right-click on java project and select Build Path ---">> Configure assemble path Click "Add External Jars" and pick all the jar under the unzipped folder. Click OK.


Now Create New class and try the following sample code:

import org.openqa.selenium.firefox. FirefoxDriver;


Public class test {

Public static void main (String[] args) {
Webdriver v1 = new firefoxDriver();

// This will initiate firefox brower
v1.get("http://facebook.com");

It will open a firefox browser window and launch facebook site. Type
v1.quit - to quit the browser.


Check it out!!!

Selenium IDE - parametrization:

Parametrization is one of the key area in Test automation. Create and we have to design the most mix of test info to give as input signal. This is among the main reason we're going to RC. But it might be possible in Selenium IDE also.

Steps to invoke the data file in to Selenium IDE

1.Create (Copy and Paste) Following data in a notepad.
Keyword = "Selenium Automation Framework Design"

2. Save the file in Java Script format (datapool.js)

3. Open Selenium IDE and Choose --">>Options--">>Alternatives.

4. Under Selenium IDE Extensions See The Saved .js file

5. Click OK and Restart Selenium IDE.

Tuesday, 23 February 2016

Phantom JS VS Selenium

Which is a superior screening framework?

Program testing is an indispensable part of the whole app development endeavor. Regardless of what type of functionality and attribute you have incorporated into the app, ignoring to analyze it for bugs is a huge 'No'. Due to the option of high-end Java Script testing frameworks like Selenium and Phantom JS.

we can conveniently analyze the web programs in headless browsers that are diverse along with actual browsers. Continue reading the post as I Will be taking you through the crucial points of distinction between Phantom JS and Selenium - two best-executing testing frameworks that are JavaScript. Thus, let's get to learn the differences immediately!

Before continue towards researching the 2 equally well known screening frameworks viz: Phantom JS and Selenium, it is vital for you to be aware of the key difference between headless and browsers that are actual. Well, a headless browser is simply a web browser that lacks a graphical user interface.

That means, this is a browser which accesses unique web pages but doesn't reveal an internet person them. Browsers are only useful for providing particular web site content to other software applications. On the flip side, we have the real browsers wherein the program/website testing is already defined as per a particular set of actions that could be taken by a person in the preferred desktop/mobile browser.

It is also vital that you understand that performance of a real browser test-case will expect one to start a real browser, adopted by managing it utilizing automation APIs for performing the actions that are specified.

And now, I would like to take you on a journey where I Will be investigating two leading JavaScript testing frameworks viz: Selenium and Phantom JS

Primarily, let us get to know about Phantom JS
Phantom is an invisible, programmable browser which doesn't behave like a browser window that is real. Using the flexibility to run commands considerably faster, Phantom can easily work in synchronization with testing framework and an appropriate test runner.

Capybara etc., with Mocha, Phantom JS can operate for instance Acceptable for first level Phantom JS, of JavaScript app testing has its API centered on JavaScript. Backed by command-line based usage, Phantom JS assures that the Java Script code of the web site is sandboxed and doesn't leave anything on the screen , refraining it from interacting with the principal tool.



Phantom JS- The Pros:

Now, let's have a look at some of the pros related to Phantom JS:

  • Requires lesser amount of resources
  • Doesn't require any external/third party services
  • Acts as a self contained command-line application
  • Runs several test cases quicker
  • Best satisfied for smoke testing of web apps; either as section of the program development work flow or within the consistent integration server
  • Phantom JS- The Disadvantages

Now, arriving at the cons connected with Phantom JS:
  • Serves as one variant of Web Kit
  • Is not suitable for extensive screening of web apps
  • There's a visible insufficient Ecosystem
  • Then let us take a nearer look at Selenium
Selenium is essentially a package of tools that are required for automating browsers across several platforms. Packaged together with the support of browser sellers that are top, Selenium is being regarded as the core technology that's utilized in an endless amount of automation tools APIs and frameworks. Selenium can be found in two variants as described below:

Selenium WebDriver:

You can choose this if you're inclined on making browser-based tests and automation packages. Additionally, this Selenium tool also operates as the most effective fit for distributing and scaling scripts across browser surroundings that are varied. Selenium WebDriver uses the Selenium Server which contains built-in grid abilities.

Selenium IDE:

Selenium IDE is the top option for programmers who want to generate scripts to be able to help with the automation-assisted testing procedure. Plus, you may take advantage of this section of Selenium for creating immediate bug replica scripts as well. Functioning as a Firefox addon, Selenium IDE will perform a record-and-playback of numerous interactions help using the browser that is chosen.

Selenium- The Pros:

  • Let you walk through some pros related to Selenium:
  • Can be controlled by multiple programming languages and testing frameworks
  • Runs in operating systems and multiple browsers
  • Selenium enables an automatic control of browsers that are real on operating systems that are real, thereby ensuring the evaluations are excessively close to reality
  • Selenium bindings can be used for controlling Phantom JS, thus covering more than 90 90% of the screening requirements.
  • For powerful testing that is added, Selenium permits added browser connections to be set up by you for changing even one line of code without the need
  • Selenium- The Minuses
Finally, a closer look at the disadvantages associated with Selenium:

Selenium does not let you to run more than only a few browsers on a single machine
Selenium setup would require centralization under a situation wherein distinct browsers are tested on different operating systems
Running multiple tests can turn to be a really drawn-out procedure

A look at the edges connected with Phantom JS

A number of the observable pros of Phantom JS comprise:
  • Doesn't require to be incorporated with a third-party service
  • Is not incapable of executing multiple test cases within a document time period
  • Functions as a self contained command-line application
  • Uses up resources that are fewer
  • Useful in case of smoke testing the internet apps. That signifies, you need to use Phantom JS for screening app within program development work flow or in the uninterrupted integration server
  • Now, let us get to understand concerning the disadvantages connected with Phantom JS
  • Working UI Testing for web apps that require to run on multiple browsers doesn't afford maximum test coverage.
  • Does not contain an entire ecosystem.
  • Phantom JS functions as one model of Net Package- maybe not a wise decision for internet app testers
  • Coming to Selenium Testing framework now

As an amazing source automation tool that is open, Selenium supports all leading operating systems and browsers like Mozilla, Firefox, IE and Safari. Capable of operating multiple tests, Selenium is a JavaScript automatic testing framework which supports all popular programming languages like Python, Java, Ruby and C #.

Distributed in the type of one jar file, Selenium Server must be downloaded. It can be used by you as a Java Script engine, together with the significance of running Selenium Server every time you want to run the internet app evaluations.

Next, we'll consider observable pros with utilizing the Selenium Testing framework associated

Backed by a sizable community of programmers who are always working on development of plug-ins which are necessitated for ensuring 100% compatibility of Selenium with all latest JavaScript front end frameworks
Accompanied by extensive documentation that is straightforward, clear and Easy To -comprehend
Selenium is really capable of utilizing bindings for permitting you to use common programming languages like JavaScript, Python and C#, Ruby
Enables characteristic test to be executed by you instantly, over the Planet Wide Web
Saves you a lot of debugging effort simply since you might be able to view see the tasks of the browser in real time
Finally, let's take a look at the disadvantages associated with using the Selenium framework
  • If you're considering testing your internet app on various browsers and operating systems, then you'll have to possess centralization to your Selenium setup
  • From working more than few browsers on one machine at a time you are refrained by the Selenium framework
  • Functioning multiple test instances with Selenium turns to be a time-consuming regime
  • Wrap it all up
When it comes to maintaining the general performance of your app, neglecting the unit testing for your web programs would land you in plenty of problem. Therefore, it's better to pick a JavaScript testing framework that's not only simple -to-use but even works as an excellent choice for executing evaluations for the log-out performance of the program.

What precisely are Headless browsers?

Well, before continuing forward, it's essential for you to understand as to which are the browsers. Browsers are the ones which provide an automatic control of a certain web page within an environment that is just similar to the one accessible within the contemporary web browsers.
The primary point of these type of browsers is the fact that they're being ran using specific network connections or command line interfaces that are certain.

Final Ideas:

It'd become rather convenient to choose the one which will fit your testing needs, together with the distinctions between Selenium and Phantom JS obvious to you by now. So the good luck and do choose just after a great deal of preparation.

Selenium Tutorials For Beginers

Selenium Training Tutorials:

In this Selenium training series we are going to cover all Selenium screening notions and its particular packages in detail with simple to understand practical examples. These Selenium tutorials are helpful for beginner to advanced degree Selenium users. Starting from your very fundamental Selenium concepts tutorial, we'll gradually move on to the advanced subjects like Cucumber BDD, Selenium Grid and Framework creation.How to start Learning Selenium?

This really is the most effective time to start learning Selenium screening by your own using the help of this free Selenium Training series. Read tutorials, training examples at your property, and place your queries in opinion section of various tutorials. We'll address all of the queries.

Seasoned Selenium experts - by providing answers to reader's queries in remarks, you too can take part in this chain.

That is our serious effort to assist you master one of the very most popular software testing tools and grasp!

Selenium Introduction:

We're delighted to launch our yet another string of software testing training tutorials. The belief behind introducing this tutorial will be to make you an expert in a widely used software test automation alternative, Selenium.

In this series we shall consider the various facets of Selenium. Selenium is not just a tool; it's a bunch of independent tools. We are going to look into several of the tools at length, providing examples that are practical wherever appropriate.

Before you leap in to reading this fascinating and useful chain, let's take a look at what it has got in store for you personally.


Why Selenium?

As the existing industry trends have shown that there's mass movement towards automation testing. The clustering of repetitive manual screening scenarios has raised a demand to make the practice of automating these situations that were manual.

Of executing automation evaluation, the advantages are several; let us have a look at them:

  • Supports performance of test cases that are repeated
  • In testing a big evaluation matrix, guides
  • Empowers parallel execution
  • Supports unattended execution
  • Enhances precision thus reducing human created errors
  • Saves time and money

This results into the following:
  • High ROI
  • Faster GoTo market
  • Automation testing benefits well understood and are many and largely discussed in the program evaluation business.


One of the most often asked question comes with this is -
  1. What is the very best tool for me personally to get my tests automated?
  2. Is there a cost involved?
  3. Might it be easy to accommodate?
  4. One of the greatest replies to each of the aforementioned questions for automating web based applications is Selenium.

Because:
  • It is open source
  • Have assisting communities and a big user base
  • Have platform compatibility and multi-browser
  • Has repository developments that are energetic
  • Supports multiple language implementations



First glance at Selenium:

Selenium is among the most famous automated testing packages. Inspire and selenium is designed in a way to to guide automation testing of practical areas of internet based an extensive range of browsers and platforms and applications. As a result of its being in the open source community, it's become among the very applications that are recognized amongst the testing experts.

Selenium Parts:

Selenium is not only a single program or a utility, instead a package of several testing tools as well as for the same reason it is known as a Suite. Each of these tools is designed to cater distinct testing and test environment requirements.

The suite program constitutes of the following sets of tools:
  • Selenium Integrated Development Environment (IDE) Selenium intro 2
  • Selenium Remote-Control (RC) Selenium intro 3
  • Selenium WebDriver
  • Selenium Grid Selenium intro 4

Selenium RC and WebDriver, in a mixture are popularly called Selenium 2. Selenium RC alone is also referred as Selenium 1.



Brief Introduction to Selenium software

Selenium is due to constant efforts by an engineer at Thought Works, named as Jason Huggins. Being responsible for the testing of Expenditures program and an internal Time, he realized the significance of an automation testing tool in order to get rid of repetitive manual tasks without compromising together with the standard and accuracy.

As a result, he constructed a JavaScript program, named as "JavaScriptTestRunner" in early 2004 that could automatically control the browser's actions which looked very much similar to that of a person communicating with the browser.

Henceforth, Jason started demoing the device to the vast audience. Eventually the discussions were presented to categorize this program in the open source class along with its possibility to grow as a re-usable testing frame work for other internet based applications.

The program was later on acclaimed using the name "Selenium Core".

Selenium IDE (Selenium Integrated Development Environment)

Selenium IDE was created by Shinya Kasatani. While analyzing Selenium Core, he realized this JavaScript code may be expanded to produce an integrated development environment (IDE) which can be plugged in to Mozilla Firefox. This IDE was capable of recording and playing back the consumer activities on a Firefox example to which it had been plugged-in. Later on Selenium IDE became a part of Selenium Program in the yr 2006. The tool turned a fantastic worth and potential out to the city.

Selenium IDE is easiest and the most straightforward of all of the applications within the Selenium Program. Its record and play back feature makes it extraordinarily simple to understand to any programming language with minimum acquaintances. With several advantages, a few disadvantages accompanied Selenium IDE, hence rendering it inappropriate to be utilized in instances of test scripts that were more advanced.

Advantages and disadvantages of Selenium IDE:


The minuses of IDE are in reality not minuses of selenium, rather merely constraints to what IDE could realize. These restrictions can be overcome by using Selenium RC or WebDriver.

Selenium RC (Selenium Remote Control)

Selenium RC is a program that is written in java that enables a user to construct test scripts for a web based application in which ever programming language he or she chooses. Selenium RC came as result to conquer various disadvantages incurred Heart or by Selenium IDE.

While utilizing Selenium Core restrictions and loopholes that were imposed caused it to be hard for the user to leverage the advantages of the tool to its totality. Hence it made an endeavor that was far reaching as well as the screening process a cumbersome.

One of the limitations that are crucial was same origin policy.


Difficulty of origin policy:

The problem of origin policy disallows to get the DOM of a file from an origin that is different from your source we are attempting to gain access to the file.

Hence the Selenium Core (JavaScript Program) cannot obtain the elements from an origin that is different from where it had been found.

For Instance, if I have found the JavaScript Program, then I 'd not be unable to get into the pages within exactly the same domain. The other domains like google.com, yahoo.com would no more be accessible.

Consequently, to analyze the application using Selenium Core, one must install web server along with the complete program on the Selenium Core to beat the issue of same origin policy.

So, In order to regulate the same origin coverage with no need of creating a separate copy of Program under evaluation on the Selenium Core, Selenium Remote-Control was introduced. Still another fellow associate at ThoughtWorks identified Paul Hammant suggested a workaround of origin policy as well as a tool that can be wired up with a programming language of our choice while Jason Huggins was demo-ing Selenium. So Selenium RC came into existence.