Recording Selenium Test Execution

After long time, got few min to think about new blog. There are many blog available for each and every solution but I was thinking to have few which is either not available or very limited information available over internet. I have free version of sauce lab and I am always fascinated by this kind of tool and I would love to build such tool sometime in future. There is one feature that is recording the session is always attracted me. I tried to find some resources which can help me to achieve so in my framework.

I found Microsoft expression encoder to do recording your screen. You can use their dlls to add into your C# based framework to execute and record the session. In you framework you can write a method which starts recording since beginning and later during cleanup task, you can have some login to determine if you want to save recording or not. For example, I my framework, I start recording based on my configuration file and in teardown methods, I check if there is an error or not. if yes then I encode into wmv format else I discard recording.




Follow following steps to have code and settings into framework:

Step 1:

Install Microsoft Encoder Expression: Refer CerebrumLabs.com for that (http://www.cerebrumlabs.com/free-screen-recording-software/). Once you install, you may get following folder in installation location. C:\Program Files (x86)Microsoft Expression. If you try to explore few folders inside this folder you will find SDK folder @: C:\Program Files (x86)\Microsoft Expression\Encoder 4\SDK, where you can see Microsoft.Expression.Encoder.dlls which you can use in your framework code.

Step 2:

Include dlls given in SDK folders into your framework. You can write a method and call that. I have a key value pair in my framework config file and I can decide if I want to do recording or not.  In your test’s [setup] method, you can call this method which will start recording at the beginning of the test.

using System;

.

.

using OpenQA.Selenium;

.

.

using Microsoft.Expression.Encoder.ScreenCapture;

using System.Drawing;

using Microsoft.Expression.Encoder.Profiles;

using Microsoft.Expression.Encoder;

namespace FRAMEWORK

{

    //Call this method in setup method.   
    public static void StartRecordingVideo()

    {

        //Provide setting in config file if you want to do recording or not.
        if (testEInfo.isRecording)

        {

            job = new ScreenCaptureJob();

            job.CaptureRectangle = Screen.PrimaryScreen.Bounds;

            job.ShowFlashingBoundary = true;

            //provide the location where you want to save the recording.
            job.OutputPath = AutomationLogging.newLocationInResultFolder;

            job.Start();

        }

    }

}

Step 3:

Now your test started and in the background your screen recording going on. once you reach to the [teardown] method. you can decide if you want to keep the recording or not. In my case I want to keep recording only if there is test failure so my developers can review else there is no point of having recording if tests are passing. To do so I have following method in above code which I call in code at the very end.

public static void StopRecordingVideo()
        {
            if (testEInfo.isRecording)
            {
                string filename = job.ScreenCaptureFileName;
                job.Stop();
                if (AutomationLogging.countOfError > 0)
                {
                    MediaItem src = new MediaItem(filename);
                    Job jb = new Job();
                    jb.MediaItems.Add(src);
                    jb.ApplyPreset(Presets.VC1HD720pVBR);
                    jb.OutputDirectory = AutomationLogging.newLocationInResultFolder;
                    string output = ((Microsoft.Expression.Encoder.JobBase)(jb)).ActualOutputDirectory;
                    jb.Encode();
                }

                File.Delete(filename);
            }
        }

Conclusion:

during encoding, you may notice that encoder is eating little more memory and you system may little slow. Try at your end and let me know if you have any question.

API Testing

API stands for Application Programming Interface. API enables two separate software system to communicate with each other. API contains methods and routines used by the system that other systems call and get the result to consume in the own system.

API testing is totally different from GUI Testing and it focuses on Applications business logic layer.  This testing does not care about the look and feel of the application.

Setup of an API Environment:

Usually, setting up the API Test Environment is not that easy because it doesn’t involve any User Interface.  You need to configure the environment based on the application requirements. You need to study the web-services document provided by developers and then design the setup. Using API code, you should make the specific call to API and consume the output for doing verification or other depended API calls.Output could be status (say OK or Error) or any kind of Data (object id) that to call another API method.

Ideally API should catch and handle the problem instead of just failed. If the input is not correct it will let you know the status with great detail like ‘Incorrect request” etc. In a very easy way, I can say, you send a request message to web services and after processing, web service sends you back a response based on that input. It could be ‘Bad Request’ if the message sent incorrectly and contains response in a specific structure based on the architecture of the web services. This response should contain enough information to understand the output and correct if there is some problem with the request.

To understand the API call, let’s see a basic example;

Consider, API functions, which are for an e-commerce web service cart web services;

AddItemToCart(ItemType item, float price, int count)

Once you look at the method, AddItemToCart, you need to pass an item of type ‘ItemType’, price in ‘float’ and count of items in ‘int’ data type to add items to the cart. The output should capture all output message and you need to parse them and get the desired response.

Approach to API Testing:

For say, if you going to test end to end scenario for a purchasing an item, you would be using few API calls.

  1. AddItemIntoCart()
  2. Checkout(), if Item added to Cart.
  3. MakePayment() if you are able to add the item to checkout step.
Based on output response of each API method you proceed to the Next.

API Test Tools:

There are various free and paid tools available in the market, which are specifically designed to test various API for the database application, mobile apps, desktop apps etc. You can download free tools as an extension or as standalone and access web services via the tool. These tools can emulate all or part of the environment in which the API would typically operate. It is not necessary that the tool can emulate all the API calls you need, but I am sure you will find the tool that can do most as per your need. SOAPUI, POSTMAN, Parasoft soaTest are few tools, which you can try.

Seven Steps For Successful Outsourcing

Outsourcing work to overseas is common practice to save money. Sometimes, you get the most out of your work by sending work to low-cost resources. You can utilize saved money to put into various initiatives like in infrastructure, hiring skilled reviewers for code review etc. Sometimes sending work to overseas can be disastrous for your company too and you can end up either incomplete project or wasting all money with no result. You may have placed all the checks at every level to make sure that project complete successfully, but later you will start noticing some unforeseen events, those you never expected, and you will pay a high price to overcome those situations. While making contracts, outsourcing companies’ salespeople over promise you for your project with the lowest cost and you decided to go for that. Later they start giving some genuine excuses that you cannot ignore and you pay more to fix that. As a result of that, you outsourcing cost increases and it is kind of never-ending process.

For a successful outsourced project, you need to take care many things, beginning from selecting the outsourcing company to getting the project delivery.

Check the background of the company you are outsourcing:

The moment you let your vendors know that you are looking for work to outsource, you will start getting proposals. Sales managers will give you presentations that they have the experience and expertise to handle this kind of project. They can do the work quickly on the lowest budget possible. Do not get into the trap of such promises. You will get what you are paying for. It doesn’t mean that you need to pay a high price to get good quality work. There are many good companies where you can get quality work out of them with lower cost. You can find about them with your reference. Ask vendors to provide their client list where they have done are currently working on same nature of projects. Try to find some link to that company. LinkedIn can be a good tool to find some reference. You can contact reference to understand vendor’s work commitments and their experience with the vendor. Go through their client vendor agreement. See if they have any certification or affiliation needed for the project. There are many more, checkpoint which can help to Choose right vendor. s http://operationstech.about.com/od/costsavingstrategies/u/Outsourcing-Vendor-Selection.html

http://www.tutorial-reports.com/business/outsourcing/criteria.php

http://www.cio.com/article/2432212/outsourcing/how-to-choose-the-right-it-outsourcing-provider.html

Double check with resources for the project:

Along with selecting the right vendor so you need to finalize suitable resources for the team too. Usually, project demo or proposals are prepared by pre-sales engineer or dedicated resources for new clients. They are quite the experts in doing that. Do not judge working resources and vendor based on the demo. I am not trying to be cynical, but you have to accept this truth. Ask vendors to provide the detailed resume of each resource who are going to work on the project. Check their skill set if these are meeting the minimum needed requirement. Make sure they have done similar work in the past. You may not need all resources equally skilled. choose resources considering many aspects like every aspect of technical skill, teamwork, work ethics etc.

Select the bridge between you and sourcing team:

Selecting coordinator between the team is equally important as selecting vendors and resources. You may be sending your work to another country where English is not the first language like India, China or Ukraine etc. where you can find qualified people but not expert in English. There may be some cultural differences too. You need to select someone from either side who has an experience working as a coordinator in the past or have a better understanding of the culture. This will help you in the long run for the project. You should consider having least one trip to the site if budget allows or bring someone to your location to a few weeks. This will help them to understand your companies work culture and expectations from them. The coordinator can help the team based on past experience to explain the problem. Sometimes its difficult to explain some critical project strategy and you need to reiterate a number of times where your coordinator can explain them on your behalf. If the vendor is working in another time zone than you coordinator needs to be involved in handling this time zone difference and keep the flow regardless of any time zone difference.

http://www.greatsampleresume.com/Job-Responsibilities/Onsite-Coordinator-Responsibilities.html

http://auriga.com/blog/blog/2013/08/09/one-of-the-lesser-understood-roles-in-distributed-teams-the-onsite-coordinator/




Cross-Cultural Training for outsourcing team:

If your budget allows then have some money aside to have cross-cultural training. As I said in the previous section if you are outsourcing our work to another country with a cultural difference then this kind of training will help you on a daily basis. They will understand how you want them to respond in any situation. Office culture in India is different as compared to the US. They way of responding to email is also different for the same situation. It is very important to understand the culture of each other and these things increase the chance of success of the work. It’s not necessary if resources have good experience with working similar project.

http://ieeexplore.ieee.org/xpl/articleDetails.jsp?reload=true&arnumber=6276345

http://www.wi-frankfurt.de/publikationenNeu/ManagingCrossCulturalDynamics2721.pdf

Consider outsourcing team as a part of your team:

Treat your new team as your own team. Sometimes we outsource monotonous kind of work, which your employees do not want to do like running regression tests suites on a daily basis. If this work is monotonous for your team then it could be same for them after a month or so. Try to send some interesting work too. Like every other employee, they are also looking for some interesting work and learn new things. Give them a window of learning new and working on interesting things will encourage them. These will help to increase the productivity of the team. Many managers feel that they outsource the project for low cost mean that they can use contractors to get the maximum work out of them. That is really a very bad strategy. Give them the opportunity to learn and welcome any kind of improvement they are offering. Consider their proposal and ask them to implement if they are capable of. Let them feel that they are equally important to another team in your company. Research shows that happy employees are more productive.

Have Contingency Plans Ready:

Attrition is the biggest problem you should be ready to deal with. Most vendors are facing this problem with their employees. Many managers experienced 100% turn around in their team within a year. Some will not give you enough time to do knowledge transfer to replacement member. You need to prepare yourself for any unforeseen situation. Make sure you have work rotations in your team to do various kinds of the task to avoid any boredom. Make sure each one of your team can do all kinds of task in case of any situation. Do not try to make a dependency on one person. Distribute the work. Periodically conduct cross-functional training in the team. In case of a sudden resignation by someone, will not be impacted severely to the team.

http://www.callcentrehelper.com/top-5-ways-to-improve-attrition-in-your-contact-centre-73.htm

http://blog.talkdesk.com/10-steps-to-help-reduce-agent-attrition-in-call-centers

http://smallbusiness.chron.com/tips-prevent-attrition-organization-23517.html

Well defined process:

Make sure you have defined all plans in his place. Have a well-defined project process. Document points of contact that may require any kind of involvement in the project. Defined proper checkpoints for review. Have best practices and lesson learned document ready so you can save time to review? If possible, before the start of project conduct training about the process. Go through all documents and explain the team how to follow the flow and how to define work-completed criteria. Try to conduct various kinds of reviews each delivered work. Have a lessons-learned meeting.

http://www.researchware.com/support/50-resources/hr-studies/159-ngwenyama-sullivan.html

http://books.google.com/books?id=CGB7ov2p16IC&pg=PA96&lpg=PA96&dq=secrets+of+a+successful+outsourcing&source=bl&ots=S6av1X6jk_&sig=SFjeJjHiwuQoxuB4hfWomvpQwKk&hl=en&sa=X&ei=dhfoU8fwBdejyASn9IKICg&ved=0CCMQ6AEwAQource=bl&ots=S6av1X6jk_&sig=SFjeJjHiwuQoxuB4hfWomvpQwKk&hl=en&sa=X&ei=dhfoU8fwBdejyASn9IKICg&ved=0CCMQ6AEwAQ

http://entrepreneurs.about.com/cs/beyondstartup/a/uc041003a.htm

Overall outsourcing work is not that easy as we think. You should consider these points as initially thought before taking the decision of outsourcing. There are many more points you should consider which is actually not given here but exist and that depends upon the process you defined in past.

Please share your experience about outsourcing? Do not forget to share.