writing

The Ganges

The Ganges starts ferociously. Plunging and rushing through the narrow valleys and gorges, it lets nothing come in its way. It slowly and steadily erodes the rocks. Oblivious to what lies ahead, it moves unfazed about the destination. The vigor is fascinating to watch but intimidating to handle. It doesn’t fear obstacles. This is youth.

In its middle course, the river is slow, calm and muddy with the burden that came along with youth. It grows wider and deeper. At certain places, one bank cannot see the other. Growing in capacity, it is slower in changing directions. Through the meanders it continues to set a path. It is predictable and patient for those who rely on it.

Finally, in the lower course, the river loses its jest. It leaves all that it accumulated and dumps it in the delta. Water flows into the sea, carrying no hint of its source, losing identity.

code

Test Automation with Selenium

When learning Selenium, we start with tutorials which use a Login page example. It demonstrates the capabilities and show how to use them. When working on a project, it takes a while to figure out the structure so as to keep it manageable. Complexity increases as timelines get strict. To catch up with changes, teams devise different approaches. Here, I will describe one such approach. The focus is on Separation of Concerns and DRY.

Selenium supports many languages. All examples here use Java and TestNG. I assume you have gone through the basics.

It pays to start with an automation framework that covers common interactions in the application adhering to the DRY principle. Adding new tests becomes easier and faster. This is different from testing frameworks (JUnit/TestNG). Automation framework focuses on the tasks not verification.

If individual tests are hard to refactor then rot creeps in. It is important how we organize the test code. One useful pattern for Selenium is PageObject . It helps to separate automation code from tests.

Tests should be readable. Using the language of the domain helps. I am not talking about DSLs here. For example, the intent of a method called addItemToCart is clearer than clickButton So, it pays to keep the test methods short and clear.

Coming back to the Login page tutorial. At the end of it you have a single class with tests and automation methods. Let us split it and organize the code.

1. First, create a PageObject and move all the interactions in it. Define web elements (buttons, checkboxes etc) and locators (XPaths, CSS) here. Consider a shopping cart. The test should not bother about how to add items to the cart. Its purpose is to verify. So, the test should have access to a method like addItemToCart implemented by the PageObject. Suppose if the location of the button is changed, then tests need not be changed. Only addItemToCart is changed.

2. Suppose, you want to run loginTest with multiple combinations of usernames and passwords. For tests to be parameterized, create Data Providers. You will put data combinations here. Now, you can add test cases without touching the test method. Just append items to this data provider.

3. Create test suites which contain JUnit/TestNG classes. Now is a good time to think about a BaseTest class. Future tests can be derived from it. For example, if each test must login, then instead of repeating the @BeforeClass method, place it in BaseTest.

We have the following project structure:

Code:

  • Page Objects
  • Data Providers

Test:

  • Test Suites

So that should be good for a start. I’ll elaborate on the code with example in another post.

writing

Inquiry and Religion

It will cease to be an inquiry if answers are accepted without a challenge. Learning is to see “what is” against perception. We build analogies to compare the unknown. We get restless upon seeing something new. With haste we put a name to it. A tag that helps us bring it within our realm of knowledge. When a person doesn’t behave as we expected, that behavior is outside that realm. We struggle to accept it without reason.

Then how do we proceed without naming things? We must know what is it that we are looking at. We are scared of the dark, afraid of walking ahead. At home, the most familiar place, we can move around with eyes closed. The same goes for other senses.

When we meet a new person, the same feeling creeps in. Unable to know about him/her, we make assumptions. What holds us back from knowing a person? Lack of interest, opinions, fear of an unpleasant experience. We assume that we can know a person by their appearance or opinions that others hold of them. This gets in our way. We look but do not see. We blur our vision with the prejudices to avoid making mistakes, emotional or otherwise. To avoid attachments that may not be mutual. Yet, all this is not part of the person. It is us.

Continue reading

writing

Perils of Inspiration

Inspiration comes in many forms, the degree of which varies. When a person inspires us, there is a want to become like that. Also, there is a doubt that we may not be as inspirational.

This sets a bar. We constantly compare. Out of those who try, few persist, fewer succeed. The focus is driven by wanting to do something. The result is means everything. People get restless with slow progress and seek instant accomplishment.

Continue reading

writing

Espresso

It is a chilling winter evening. The wedding reception is in an open ground. A small tent covers the stage and a few chairs kept in front of it. Food is being served on tables arranged along the perimeter the ground.

Kids are stuffed with enough woolen that they may roll without getting hurt. Old men are wearing just as much but they put on a jacket. They set themselves apart by sporting a cap, some have a monkey cap. They look prepared to survive if were to stay here for the night.

Women are confused. They sit in the covered area unable to decide whether to let that thin shawl cover their elaborate jewelry or not. They may stand a chance to get a compliment from at least one of their husband’s subordinate or his wife. “Oh, that is a lovely necklace!” the wife will say. It means that she is looking forward to the day when she can afford it. Definitely, she would buy something better just like her taste.

An espresso machine stands in a corner. It makes a swoosh sound as it spews coffee in a cup. The cups are thick and save your hands from the heat. They are designed to look big and have less capacity.

You stand in a queue, get yourself a cup. You take a sip and all you get is the taste of cocoa powder and froth. But you are a born explorer who lives life dangerously. You venture into the unknown. You have let yourself be surrounded by strangers. Strangers who, when they question, make you wish they are struck by lightning. Twice. So, you quickly take another sip of that extremely hot coffee that destroys all taste buds. All the taste that ever was and will be.

You feel angry and embarrassed like a kid who is just old enough to realize that bed-wetting is shameful. You have now acquired the power to taste all the food irrespective of its taste.

The food will be declared terrible eventually by the guests. The worst thing that can happen to coffee is that it will run out. The cold is here to stay while everyone waits for the bride and groom. Till then most of the guests would have finished dinner and declared that only the coffee saved them.