How to Make Performance Testing More Efficient
Flexible Data Model Design
How to grow your project without failing at architecture, scalability and system integration
Fast creation of performance tests based on SoapUI project
How to Improve Performance of AWS Java Cloud App? Try ElastiCache
How You Can Use Cassandra in the Big Data World
Harnessing the chaos in software project management
Working in a Virtual Team
Database: How To Make a Bad Thing Work Well
Smart Version Control for Project Managers and Decision Makers

A way to speed up your Selenium tests

Selenium is an awesome and one of the most popular tools for automation of
Web Front End testing. The idea is that you write an application which opens your browser and simulates user actions.
After each action you check if application reacts as you expect it to. Selenium provides all the neccessary API to
make the process easier for you.

In the beginning of each test case, you must cleanup the testing environment to make sure that the other tests don’t
have any impact to the current one. So, you usually restart the browser, clean the cache/cookies and push the
fixed data set to the database for that. As result, you must login to your application over and over again to continue
testing. If you have hundreds of tests, it takes quite a lot of time (10 seconds per test), and it is obvious that this
duplicating work should be nullified if possible – you don’t need to test the same thing multiple times.

We’ve come up with a simple and efficient solution. Using DbUnit,
we create several “immortal” (till 2040 year) sessions, one for each user:

<sessions sessionid="084e317cecea464f96b9fbc1f8b8db5c" 
          expiretime="2040-07-24 04:27:46" 
          createtime="2013-07-01 07:55:15" />
<sessions sessionid="3fbe87b707ea48c496c739d743c31aba" 
          expiretime="2040-07-24 04:27:46" 
          createtime="2013-07-01 07:55:15" />

Then, in the “setUp” method, we initialize a cookie containing identifier of such an immortal session for a desired

public class AuthorizedTest extends WebTest {

    public void setUp() throws Exception {
        // WebDriver can create cookies in a current domain only

    protected WebAccount getAuthorizedAccount() {
        return WebData.ACCOUNT_LARRY; // account with ID = 1

    public void applyImmortalCookie(WebDriver driver) {
        driver.manage().addCookie(new Cookie(
            "PHPSESSID", getImmortalCookie(),
            SeleniumConfig.DOMAIN, "/", null));

Now authorization doesn’t take any time at all. We managed to decrease testing time by 30% thanks to this improvement.

About the author

Egor Nepomnyaschih

Egor is an experienced software developer working with JavaScript, PHP, Java, Unity technilogies. He is happy to share his expertise with all the industry peers.