Skip to main content

Posts

Showing posts from July, 2018

Page Object Model && Page Factory

Page Object Model Design Pattern (POM): Page Object Model is a Design Pattern which has become popular in Selenium Test Automation. It is widely used design pattern in Selenium for enhancing test maintenance and reducing code duplication. In Selenium all we are doing is finding elements and filling values for those elements. For small script it’s easy to maintain . But with time test suite will grow. As we add more and more lines to our code, things become tough.The chief problem with script maintenance is that if 10 different scripts are using the same page element, with any change in that element, we need to change all 10 scripts. This is time consuming and error prone. A better approach to script maintenance is to create a separate class file which would find web elements, fill them or verify them. This class can be reused in all the scripts using that element. In future, if there is a change in the web element, we need to make the change in just 1 class file and not 1

Demo Project (Selenium Setup)

Setting up WebDriver 1.Create a new project from Console App 2.Install Selenium NuGet packages 3.Download the driver for particular browser.For Firefox browser we don’t need to install the driver.Here we installed Chrome driver using below link.It actually runs directly. https://chromedriver.storage.googleapis.com/index.html?path=2.40/ 4.Add OpenQA namespace under Selenium and we need to import namespace for browser also. 5.Now we write a small code which open up our browser and go to google.com. 6.Output of the code 7. Finding Elements For finding elements we have to right click on the element we want and click on inspect option. 8.Then we will see that element must has an Id or class or we can also use Xpath to select the element. 9.Now we extends the previous code which will search for “Selenium” 10.Then it will select the image option and will click the first image of selenium. 11.Exten

Getting Started Selenium

Selenium is a web Automation tool which can be used to automate web browsers across many browsers and operating systems. It has four components. 1. Selenium Integrated Development Environment (IDE) 2. Selenium Remote Control (RC) 3. WebDriver 4. Selenium Grid Here we will   discuss about Selenium Webdriver which is the current version of Selenium. Web driver is basically that API which we can use programmatically to control a browser.Using Webdriver we can make powerful tests because WebDriver allows us to use a programming language of our choice in designing our tests .Following programming languages are supported by WebDriver. # Java # .Net #PHP #Python #Ruby Selenium WebDriver can process multilingual commands (sent via Selenese or the Client API) and forwards them directly to the web browser. Webdriver has a built-in implementation of the Firefox driver. For other browsers, you need to plug-in their browser specific drivers to communicate and run the

Demo Project (Specflow Setup)

Installation and Setup Steps-->     1.Install SpecFlow for Visual Studio (Open Extensions and Updates) 2. Install SpecFlow NuGet Packages     3. Add Feature File    My Demo Project    Here, I have worked on following story    Story: Discounts on online shopping cart price for loyalty card customers    In order to increase the reward for loyal customers    I want to add 5-10% discounts on the final shopping cart price.    Scenario 1: 5% discount for loyalty card customer    Given a loyalty card customer in online checkout page    When the shopping card total is less than $100    Then 5% discount should be applied to the final shopping cart price.     Create Scenarios    In the feature file, I described what the feature needs to do Every scenario represents a different           test or use case of the feature.    Generate Bindings   When the steps are displayed in purple, this means that we are not ready.   T

Getting started Specflow

Specflow is a BDD framework. Specflow integrates with Visual Studio. What is BDD à BDD or Behavior-driven development allows a developer to focus on testing the code based on the expected behaviour of the software which is easier for non technical stakeholders to understand.In BDD process the product owner or customer representatives species the behaviour they want to see in the system.BDD helps the developer collaborate with other stakeholders,including testers to define accurate unit tests focused on business needs. BDD frameworks define acceptance criteria based on the given/when/then format.And it is usually done in very English like language ,which helps the domain experts to understand the implementation. Given some initial context, When an event occurs, Then ensure some outcomes. As the statement structure and syntax are formally documented, software tools like specflow can generate the code for developers to create test cases. An example: Given my