Posts

Selenium: BDD Cucumber- Cucumber Options

Image
In last post, we learnt how to write features, scenarios and how to execute BDD cucumber tests. As we are implementing our BDD framework using cucumber, let's explore further about cucumber. We will start with various cucumber options in this post. We run our cucumber tests from Runner class. You can just go through this once to recapitulate things we discussed in last post  Cucumber Demo Test  . In that runner class, we have different cucumber options, it is just like a settings page that how we want to run our tests and different options are also available for that purpose. [Cucumber Options] Dry Run:   dryrun can be true or false. If dryrun is set true, it will check if the steps written in feature file has corresponding code in step definition file or not. It is good option to catch rudimentary errors. The default value of dryrun is false. You can just try with dryrun=true option to see the result. Monochrome: monochrome option also can ta...

Selenium: BDD- The Disruptive Framework

As we learnt about different selenium automation framework in last post, now it is time to focus on one particular framework which will shape the future of selenium automation testing and that is nothing but Behavior Driven Development (BDD) framework !  BDD serves as a bridge between tech and non-tech people which includes but not limited to developers, testers, clients and business analysts. In BDD, we can write our automation tests in general English like language which can be understand by all the stake holders and eventually it paves the way for smoother functioning and more productive environment. With the coming of agile model, concepts such as BDD has found more meaning and usage. The important feature of BDD is that it includes all the stake holders. Features of BDD:  Collaboration between developer team, QA team, client and business analysts. It uses plain English like language 'Gherkin' to describe tests. It augments business value by thinking in term...

Selenium: Frameworks

Image
In previous posts, we learnt about all the selenium basics for automation script writing. Now, let's move forward with some advance selenium topics such as Framework .  Framework is nothing but set of some predefined protocols and guidelines that how the things will work when we are writing automation scripts. Framework is like 'Single Standard' which is every automation tester is obliged to follow. Basically, framework helps to separate our 'code' and 'data' which will help in achieving higher code readability, reusability and portability. With the help of frameworks, we can test our script with multiple set of data which paves way for very efficient functional testing.   The main advantage of using frameworks is project maintenance as we can easily manage all our automation scripts, test data and all other related stuffs. e.g. different testers work on different modules of the AUT(Application Under Test)  and with the help of frameworks, we can e...

Selenium: Waits

Image
In last post, we have seen how Xpath helps us to find dynamic elements which changes every time. Similarly, most of the front ends are developed with Ajax and JavaScript where different elements load at different time. In such cases, our driver need to wait till the element is loaded and visible otherwise it will throw ' elementNotVisibleException ' exception and eventually our automation script will fail. To avoid such situations we have one powerful option in selenium that is nothing but ' Wait '. [ source: www.deshannonspeaks.com ] In general, we have two types of wait in selenium. Implicit wait Explicit wait 1. Implicit Wait :  This idea is borrowed from Watir. Here, we are instructing our driver to wait for certain amount of time for element to get loaded before throwing an exception. Example : Consider our Facebook login scenario. Implicit wait syntax is highlighted in bold. It will wait for 10 seconds and if any element is not loaded i...

Selenium: Capturing the screenshot

Image
As an QA engineer, we all know that taking the screenshots is the main task we do during testing particular application. (It works as a 'Brahmastra' while fighting with developers and clients !!). Similarly, while running automation scripts it is necessary to take screenshots of important events and functionalities as it is imperative for bug analysis.  Selenium offers great advantage of taking automatic screenshots during the execution. We can convert our WebDriver instance to TakesScreenshot . Below we will see one example of taking the screenshots in our selenium automation script. [source: www.qaautomated.com ] Example:  Here, simply we will try to open Google, will take the screenshot of that screen and we will store it to our local machine. // importing the needed jar files import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import com.sun.jna.platform.FileUtils; //creating class ScreenShot @...

Selenium: All about XPath Locator in WebDriver

Image
As we have started writing simple web application login like scripts, its time to move one step ahead. Till now we were finding web elements using general locators like id, name, classname etc. but sometimes it is difficult to find elements using these locators. What if elements don't have these locators, What if some elements are dynamically changing, to answer all these questions, we have Xpath . Xpath is used to find complex and dynamically changing web elements of the web page. It is defined as XML path, it is basically a syntax for finding web element using its XML path expression. It takes advantage of HTML DOM structure while finding web elements.  Syntax: Xpath= //tagname[@attribute='value'] // : current node tagname : name of the tags like input, a, img, label etc. attribute : name of the attributes like id, name, classname etc. value : value of that particular attribute There are mainly two types of Xpath. Absolute Xpath:  Xpath finds...

Selenium: Automate Web Application Login

Image
From last post, we have started writing basic selenium automation scripts. Now, let's take that journey forward and try to automate any web based application.  In this post, we will automate our Facebook login as a demo which can be used for any web based application with little modifications. [Source: www.facebook.com ] Code with Explanation:  We will create one class named FacebookLogin in the package blog in eclipse which we have created during googleSearch automation script. package blog; Here, we will import all the necessary external jars, we can give suppress warnings for jar which we are not using. import static org.junit.Assert.*; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; @SuppressWarnings("unused") public class FacebookLogin {...