Testing express

Testing express

Friday, May 5, 2017

Automation Perspectives & Misunderstandings



This observation is from the Indian IT companies point of view(I don't say all, but what I have worked with and those that I heard from my colleagues & friends):

There are 2 types of testers, Manual testers and Automation testers

Automation tester can switch to manual testing role anytime but vice versa is not that easy!

Automation is not same as development

All automation tools are same, If you know Selenium then by default you will definitely also know 
the UFT's, the Cucumber's, the Carrot's  :P ? why? because client needs it.  

Automation is nothing but few automated data entries, clicks, verification..etc

If you know automation, you are bound to be in any interview panel that has the word "Automation" in the job requirements document.

Automation tests are like the high precision tests that should never fail, I don't care if it's a licensed tool or a free tool.

What? you have completed the automation runs? I don't believe you ! where are the numbers? After giving numbers. how many defects you found using your automation scripts? none/one? what is the value you are providing?

We are facing issues with existing framework and tool, which other tool should be consider? let's start evaluation.


Friday, May 22, 2015

Selenium tips: Locate elements that have same attributes for all elements


Some times a group of elements have same attributes for all elements, in that case if I want to click or select any specific element from that group, it will be hard using any location strategies. Here is one solution that I came up with

WebDriver driver = new FirefoxDriver();
driver.get("file:///D:/SameName.html");
driver.manage().window().maximize();
List<WebElement> cbox = driver.findElements(By.name("chk"));
cbox.get(cbox.size()-1).click();

In the above code we are getting all elements using locator name and value "chk" into a List
Then we are calling the get method on the list object by passing the index value and the performing the action.


Tuesday, May 19, 2015

Selenium : Mistakes and Learnings

I had a long pending issue in a selenium script. Problem was, after succesfully completing a flight booking transaction, I wanted to verify the confirmation message and get the pass result.This is the way I had implemented

public void isFlightConfirmationSuccessful(){
System.out.println(flightConfirmation.getText());
if(flightConfirmation.getText()==("Your itinerary has been booked!")){
System.out.println("Flight Booked Successfully");
if("more data" != null){
backToFlights.click();
}else
{
logOut.click();
}
}else{
System.out.println("Flight Not Booked");
}

}

Even though this method flightConfirmation.getText() would return the same string as expected "Your itinerary has been booked!" ,

still I would get the result false.

I was missing a java concept here "==" is not same as ".equals"

".equals" checks the equality of content
"==" checks the equality of references

This is the code that passes the test

public void isFlightConfirmationSuccessful(){
System.out.println(flightConfirmation.getText());
if(flightConfirmation.getText().equals("Your itinerary has been booked!")){
System.out.println("Flight Booked Successfully");
if("more data" != null){
backToFlights.click();
}else
{
logOut.click();
}
}else{
System.out.println("Flight Not Booked");
}
}


Sunday, May 17, 2015

Java Concepts - Strings literals

what is string literal?
it is a sequence of characters between quotations
Eg; "apple"

what is string literal/constant pool?
Its a collection of references to string objects
String objects that have references from string constant pool live on heap memory
String s = "apple";
s is a variable in string constant pool referencing to string object "apple" that lives on heap

if I write
String s1 = "apple";
s1 is another variable in string constant pool that is referencing to same object "apple"

s.equals(s1) // will return true because equals checks contents of objects
s==s1//will also return true because equality operator checks for referential equality

String s = "mango";
Here, reference of variable s is changing from "apple" to "mango", but "apple" object is still present in heap memory. Hence, strings objects are Immutable(cannot be changed)

s.equals(s1);//will return false because now s is referencing to object "mango" and s1 is referencing to object "apple", which are 2 different objects

String object referenced from the string literal pool is created when the class is loaded

String literals are not eligible for garbage collection, the object is always reachable through the intern() method.

source: http://www.javaranch.com/journal/200409/Journal200409.jsp#a1

Monday, May 4, 2015

Assertions in TestNG - HardAssert & SoftAssert

TestNG is a unit testing framework used by developers, but it has also gained popularity among testers.

It makes life easy of a tester while writing tests.
This post will be focused on one of the important features of TestNG called Assertions.

what is assertion?
A statement that asserts that a certain premise is true

In Testers language, Assertion is a check/validation to compare the expected and actual outcome.

All the assertions are part of the Assert class

Example of a assertion

Assert.assertEquals(boolean actual, boolean expected) 
Asserts that two booleans are equal.

More assertions can be found here : http://testng.org/javadoc/org/testng/Assert.html

There are 2 types of assertions

Hard assertions & Soft assertions

Hard Assertion : Throws an AssertException once Assert fails and continues with execution of next test in the suite. For example if you have a bunch of assertions in a @Test, If one assertion fails, the whole test fails.All assertions after the failed assertion are skipped once a assertion fails.

Soft Assertion;  soft assert allows to continue with next @Test without throwing any exception

Hard assert:
  @Test(priority = 2)
  public void ffPageElementsTestHardAssert() {
     Assert.assertTrue(ffPage.ff_Type_oneway.isDisplayed());
     Assert.assertTrue(ffPage.ff_Type_roundtrip.isDisplayed());
     Assert.assertTrue(ffPage.ff_PassengerCount.isDisplayed());
     Assert.assertTrue(ffPage.ff_DepartingFrom.isDisplayed());
     Assert.assertTrue(ffPage.ff_DepartingMonth.isDisplayed());
     Assert.assertTrue(ffPage.ff_DepartingDay.isDisplayed());
     Assert.assertTrue(ffPage.ff_ArrivingIn.isDisplayed());
     Assert.assertTrue(ffPage.ff_ReturningMonth.isDisplayed());
     Assert.assertTrue(ffPage.ff_ReturningDay.isDisplayed());
     Assert.assertTrue(ffPage.ff_ServiceClass_EC.isDisplayed());
     Assert.assertTrue(ffPage.ff_ServiceClass_BC.isDisplayed());
     Assert.assertTrue(ffPage.ff_ServiceClass_FC.isDisplayed());
     Assert.assertTrue(ffPage.ff_Airline.isDisplayed());
     Assert.assertTrue(ffPage.ff_Continue.isDisplayed());   
  }
Soft assert:
  SoftAssert sa = new SoftAssert();
@Test(priority = 2)
  public void ffPageElementsTestHardAssert() {
     sa.assertTrue(ffPage.ff_Type_oneway.isDisplayed());
     sa.assertTrue(ffPage.ff_Type_roundtrip.isDisplayed());
     sa.assertTrue(ffPage.ff_PassengerCount.isDisplayed());
     sa.assertTrue(ffPage.ff_DepartingFrom.isDisplayed());
     sa.assertTrue(ffPage.ff_DepartingMonth.isDisplayed());
     sa.assertTrue(ffPage.ff_DepartingDay.isDisplayed());   
  }
Soft assertions can be helpful when we are validation forms.

Sunday, March 30, 2014

Back after a long gap

It's been exactly 1 year since my last post. I have moved to my home town for a new job. It took some time to settle down. My work place is far away from my home, I was not able to spend much time to blog, But I have promised my self to continue from where I had left in whatever possible time I get.

The domain of my new job is completely different from my previous jobs and the work culture is also different. The application which I am working on is vast and there is a big team that takes care of quality & development. Tight schedules as usual and ever changing requirememts.

We also have a automation team that struggles to run automation scripts on each build because they have a list of problems that never end.

It's been a long time since I have kept my self updated with selenium, With my new laptop, I need to set up the environment from scratch.While I am writing this post, softwares are already getting installed in the background.

Hope to keep up my blogging pace.By the way this is my first post this year and happy about it, I believe anything first is always exciting & helps us to motivate ourselves.

 

Saturday, March 30, 2013

Automated build deployment

As a tester, the time we spend on each task is important, we need to keep identifying solutions that can save our time and effort. I will discuss one such solution we implemented during automated build deployment.

There are many tasks that we repeat several times, this will be exciting first few times when this task is new but once you get used to it, it becomes repeatative.

As part of my work I am responsible for deploying the client side builds to web server. There is a fixed process that needs to be followed always, this situation is appropriate for automation and the good thing is, it does not need much time and effort. First, I will highlight the manual process that is followed to achieve this task.

1.Checkout the code from svn with a specific revision number to folder in local machine
2.Run a shell script to minify the buid
3.Rename the minified build as per the naming convention
4.Deploy build to server using any of the ftp clients, we used winscp.

This process takes 15-20 mins for each build
If there is a mistake in build like
Incorrect revision no
Missing file
Incorrect svn url
This process needs to be repeated

The solution was simple, we used a shell script to automate this whole process. the only things we needed was svn commands, winscp commands & dos commands

This helped us reduce total deployment time from 15-20 mins to 5 mins

With the help of systems team we made this solution more optimized and brought down the deployment time from 5 mins to 1-2 mins

The systems guy introduced us to TeamCity which is a continous integration server, it has a lot of features that can help us achieve automated build deployment.
Here are the general steps for setting up the deployment taken from teamcity site, This can vary based on your requirement.
  1. Write a build script that will perform the deployment task for the binary files available on the disk. (e.g. use Ant or MSBuild for this)
  2. Create a build configuration in TeamCity that will execute the build script.
  3. In this build configuration configure artifact dependency on a build configuration that produces binaries that need to be deployed
  4. Configure one of the available triggers if you need the deployment to be triggered automatically (e.g. to deploy last successful of last pinned build), or use "Promote" action in the build that produced the binaries that need to be deployed. Consider using snapshot dependencies in addition to artifact ones and check Build Chains tab to get the overview of the builds.
  5. If you need to parametrize the deployment (e.g. specify different target machines in different runs), pass parameters to the build script using custom build run dialog. Consider usingTyped Parameters to make the custom run dialog easier to use.
  6. If the deploying build is triggered manually consider also adding commands in the build script to pin and tag the build being deployed (via sending a REST API request).
    You can also use a build number from the build that generated the artifact.
Build Script could be shell script or ant This build script will have the above manual process in form of commands, once the configuration is completed you can just click a "run" button from the dashboard, deployment is done automatically and the results displayed on dashboard. There is also facility to check the log file to debug if deployment fails.
You can also add auto sending of emails if a build is deployed successfully to the relevant user group. This can be added in script. 

There is also facility to pass parameters to build script