Manas Singh

Turning unreasonable anxiety into unlikely ideas

The Dinner

The Dinner

Garett frowned as he tasted the food. He looked at others for reactions. Moira looked at him and knew what he wanted to say.

Ferris kept eating.

“This is terrible!” Garrett said.

“I didn’t expect the food to be so bad, perhaps they should fire the cook. How can anyone eat this shit?”

The manager, after listening to Garrett, apologized profusely, offered a complimentary drink and got all food replaced.

“I think Ferris enjoyed it. Man, are you used to eating stuff like this?”

“No”

“Then why are you eating it?”

Ganges at Varanasi

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.

Test Automation

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.

Sky

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.

Inspiration

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.

Page 5 of 7

Powered by WordPress & Theme by Anders Norén