Skip to main content

Posts

Showing posts from October, 2016

Are your selenium element locators static ?

I usually declare element locator static as well as the helper method using them, since element locators is a class variable or constant and is not dependent on a specific instance of class. For example in the following code snippet, element locators - imageElement and teamDeletionSucessMessage are static. Also, method - isTeamDeletionSucessMessageDisplayed is static - From one of the SO answer, following can be the requirement to make method static - If you are writing utility classes and they are not supposed to be changed. If the method is not using any instance variable(s) or instance method(s). {some thing I consider most important when declaring a variable static} If any operation is not dependent on instance creation. If there is some code that can easily be shared by all the instance methods, extract that code into a static method. If you are sure that the definition of the method will never be changed or overridden. As static methods can not be overr

Processing JMeter Results using awk

awk is Pattern scanning and processing language. Its name is derived from its authors “ A ho, W einberger, and K ernighan”. Some of its features are: Awk views a text file as records and fields Awk has variables, conditionals and loops Awk has arithmetic and string operators Awk can generate formatted reports Syntax: awk '/search pattern1/ {Actions}      /search pattern2/ {Actions}' file Herein : search pattern is a regular expression. Actions – statement (s) to be performed. several patterns and actions can be used in Awk. file is the Input file. Single quotes around program avoids shell interpreting any special characters. Let’s Consider following jmeter summary file - summary +    41 in  15.4s =    2.7/s Avg:  2234 Min:   383 Max:  6974 Err: 0 (0.00%) summary +    57 in  21.5s =    2.6/s Avg:  2548 Min:   618 Max:  4528 Err: 0 (0.00%) summary =    98 in  32.5s =    3.0/s Avg:  2416 Min:   383 Max:  6974 Err: 0 (0.00%)

When Test Automation Fails and exploratory Testing rocks

This post describes how I discovered a defect which allowed me to gain higher privilege than I was supposed to as a normal user. When testing an application I came across a use case when a privileged user would be allowed to delete a team and non privileged user would not be. Delete operation is controlled by displaying of a link. This is how it looks like for a privileged user - And this is how it look for a non privileged user - Here “Delete team” link is missing for non privileged user. Having a look at html source code, I found following for the privileged user - <a class="delete right" data-bind="if: teamProfile().type() != 'official', click: deleteTeam" href="https://test.com/" title="Delete this team">Delete team...</a> And following for the non privileged user -           <a class="delete right" data-bind="if: teamProfile().type() != 'official', click: deleteTea

JMeter and Patch Request

I was using PATCH request with JMeter and I get following error - ######################################################## j ava.net.ProtocolException: Invalid HTTP method: PATCH at java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:428) at sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestMethod(HttpsURLConnectionImpl.java:374) ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### The problem lies with HTTP Request implementation being used here. Java implementation of HTTP request does not support PATH request and you should be using HTTPClient 4 implementation to get rid of this error

Is page object returning another page object a bad practice?

I have come across few articles which talk of page object returning another page object being bad practice. The reason cited are following - Tight coupling between page objects and less flexibility Duplication of code as two variant of a method need to be created returning two different page object depending on if operation was valid or not, i.e. - ‘ loginAs ‘ and ‘ loginAsExpectingError ‘ Let’s see following example of page objects wherein a page object class does not return another page object. For the sake of simplicity, I have consider three page object classes - LoginPage class which lets user login LoggedInUserHomePage class which provides services when user is logged in InvoiceDetailPage class using which user invoice details A simplified version of classes would be - public class LoginPage {    public LoginPage() {        if (!WebUIDriver. getWebDriver ().getTitle().equalsIgnoreCase( "login page" )) {            throw new