Skip to main content

Posts

Showing posts from August, 2016

SELENIUM: Test Structure - Use of Different Attributes

As I mentioned in my previous post that in this post we will be discussing about test structure that we will are writing. Here I will be explaining in brief different types of attributes that can be used while writing our tests. Till now we have just used one attribute i.e. [TestMethod] which contains the test to be executed. There are other important attributes that can be used during tests to make tests well organized. Few of the attributes are as given below: [ClassInitialize] [ClassCleanup] [TestInitialize] [TestCleanup] [AssemblyInitialize] [TestMethod] [TestClass] [ClassInitialize] attribute can be used with a method that you want to execute before intialization of a class. So, let's suppose there are five tests in a test class then the method having [ClassInitialize] attribute will run only once for this class before running all the tests. [ClassCleanup] attribute can be used with a method that you want to execute after all the tests in the class ar...

SELENIUM: Next Test to Framework

Now, let's add one more test to our framework and see how it grows. In my previous post we created one basic test which tests that user can successfully login to the application. Let's add next test to same login tests category which will test that user cannot login to application with incorrect credentials and then develop corresponding needed framework. Second test to Framework For this we will create test and corresponding framework for below steps: User tries to login with incorrect credentials Verify that the login error message is visible  As we have already created a LoginTests class under UITests project so, we don't need to add another class as category of this test is same. Just add below test method to this class. Here, we have created one test method as " User_Cannot_Login_With_Invalid_Credentials ". In this method again we have added required steps to test our scenario. First and second steps are similar to previous test. Here,...

SELENIUM: Creating a Basic Test

By now you must be pretty confident of what actually selenium is, how we can set up an environment to build an automation framework and what kind of things we should have in our mind before we start building a framework. Also, you know few of the basic concepts too. I think now it's a good time to start building our framework. The approach I will be using to build the framework is that I will be just creating a basic test first. After that by the course of time I will be adding more tests in it and in this way our framework will start growing in size with each test added. I will be doing lots of refactoring as and when required so that the framework remains well structured and easy to use. As to build a framework we need an application, I will be using WordPress for this purpose. You can use any application but if you need to get a start on WordPress too you can download and setup from this link . Instead of adding all the required things in the framework what I will ...

SELENIUM: Some Useful Facts

Before we start designing a framework, there are few facts that we should always remember. It is not important what you have designed, it is more important that how good your product is. Also, this kind of analysis should always be done in the beginning so that you don't have to devote extra time and efforts for it later. It is always good to fix something in beginning than worrying about it later when it has become a big issue and become difficult to locate the issue. It's not like that we won't be able to fix it, we will definitely fix it but with more cost and efforts. Let's go through few of these facts. Layers in Framework You should always keep in mind the layers that should be there in the framework you are designing. Layers to be created generally varies application to application that you are creating but most of the frameworks contains below layers often. In above picture, there is workflow layer at the top. Workflows can be think of as somet...

SELENIUM: Page Object Model

As now we have created our first hello selen ium test successfully , I think it is the good time to know something about architec ture of fr amework that we are going to design. It is always good to know what actually hap pens when you do something as it gives you a better understanding of it and you can easily know what you need to do, how you need to do and where could be the f ault if something wrong happens. So, let's go th rough it in brief. Page Object Model  The basic idea of this page object model is that we have a class for each page or a logical part in our application and it contains methods in it which represents the functionality of th is page. Further, tests interacts with the corresponding page class and access its methods as required.  In above picture there is a login page that is there in our application and corresponding to this login page there is a LoginPage class having all the method s defined i n it which corresponds to the va...