How to Learn Selenium WebDriver in 3 Days

or How to Learn Selenium WebDriver like a JEDI


I like Star Wars movies.

I still remember seeing the first episode, A New Hope, at the cinema, back in the 1980s.

Since then, I watched it and the following 5 episodes, produced by LucasFilm, many, many times.

The new ones, produced by Disney, are still good (much simpler though) especially Rogue One and The Last Jedi.





There is an interesting difference between the old Star Wars movies and the recent ones.

In The Last Jedi, Luke Skywalker agrees to teach Rey just 3 lessons about the force. She needs to learn how to be a JEDI to be able to fight the imperial army and yes, Kylo Ren.

The lessons happen fast and only bits of knowledge and wisdom go from the teacher to the student. Not much skills as Luke is now a wise old man instead of a JEDI knight as before.

Just 3 lessons are enough for Rey to discover her potential and the mighty force. Having the force, she lifts a huge pile of rocks that stops her friends from running from the imperial army.

Unfortunately, as the episode title explains, the last JEDI disappears so in the future, there are no more JEDIs to teach about the force.

No more lessons about the force but probably the lessons are not needed any longer.

If Rey can learn the force in 3 lessons, maybe she can explain it to others in 1 lesson or maybe in just a few sentences.

The force is no longer accessible to a few but to all.
You just need to put your mind to it and there it is.


Now, why shouldnt we be able to do the same with Selenium WebDriver?

3 lessons.

It is not that hard.

The secret of the force is in how the study material is broken down per day.

Day 1
learn about html, xpath, css, browser dom, eclipse, java basics, unit testing.

Day 2
learn about object oriented notions like classes, objects, inheritance, composition, interfaces, polymorphism, generics, predicates, reflection, streams.

Day 3
learn the page object model, page factory, loadable component, slow loadable component and a few other design patterns.


And that's it, we are there, we can lift our own automation rocks.

This is totally doable if you are a Star Wars believer.

Everyone can do whatever they put their mind to.
Everything is easy to do and learn.
Everything is accessible to all of us, even the force.
The JEDI knights go away and who need them anyways?


Now, the old Star Wars episodes are a little different from the new ones.

In The Phantom Menace and Attack Of The Clones, the process of becoming a JEDI knight is explained in detail. You had to start your training at the JEDI Academy at a young age and complete it.



Then, a mentor would guide you through real life experiences until you are ready to pass the JEDI trials for becoming a knight.

No one became a JEDI in 3 lessons or 6 or 15.
No matter how skilled, talented or gifted.

Instead, the trainee would go through a long, difficult and intensive education with both teachers, peers and mentors.

This would totally work for Selenium WebDriver as well.

Selenium WebDriver learning is basically learning how to code which is best done with teachers, peers and mentors.

So Star Wars is a viable source of inspiration.

You just have to watch the proper episodes.

Watch The Last Jedi and believe that 3 lessons are sufficient.

Watch The Phantom Menace and understand that 6 months is a better time range.



What are the risks of taking selenium

This question took me by surprise.
Risks of taking selenium?
Are there any risks?
Am I in danger?
Am I sick from too much Selenium?


Read along.

Of course, there are risks.
But first, a few words about benefits.
Selenium is a mineral.
It is taken into the body in water and foods. People use it for medicine.
Selenium is used for diseases of the heart and blood vessels, including stroke and “hardening of the arteries” (atherosclerosis). It is also used for preventing various cancers including cancer of the prostate, stomach, lung, and skin.
Some people use selenium for under-active thyroid, osteoarthritis, rheumatoid arthritis(RA), an eye disease called macular degeneration, hay fever, infertility, cataracts, gray hair, abnormal pap smears, chronic fatigue syndrome (CFS), mood disorders, arsenic poisoning, and preventing miscarriage.
Selenium is also used for preventing serious complications and death from critical illnesses such as head injury and burns. It is also used for preventing bird flu, treating HIV/AIDS, and reducing side effects from cancerchemotherapy.
And the risks?
Selenium deficiency is very rare in the United States and Canada.
Selenium deficiency can cause Keshan disease (a type of heart disease) and male infertility.
It might also cause Kashin-Beck disease, a type of arthritis that produces pain, swelling, and loss of motion in your joints.



Now, joking aside, what are the risks of taking, sorry, learning Selenium WebDriver?
You are a manual tester.
You want to learn test automation, meaning programming and Selenium WebDriver.
Some of the risks that you are exposing to are
  1. you may find that you don’t have enough motivation; most people have high enthusiasm initially which, when confronted with the challenges of learning programming, goes away bit by bit until it is over ; so one of the risks is that you start learning, then stop it and feel like you failed
  2. you may realize while learning Selenium that you like it so much that you dont want to do manual testing any longer; i know people who after learning some automation did not want to go back; so another risk may be that your manual testing days are over but your automation days are started
  3. you may get to a point where you will be willing on learning Selenium and programming not only during your work hours but also at home; so you will be risking some of your free time (and your family’s)
  4. you may be risking some of your friendships if you make progress with your automation learning; some of your tester friends who cannot do it may not be positively impressed by you doing what they cannot
  5. finally, you may be risking your career and your job; when you learn enough programming and automation, you may stop being a tester and become a developer; you lose your tester job but gain a developer one

How do I identify fake Selenium testers?




There are things that can be done before the hiring interview, during the interview and after.


BEFORE THE INTERVIEW

The tester gets a Java coding project from Codility.com to be done in 30 minutes.

It does not have to be very difficult, even an easy one is good enough.

Such as finding all characters from an array that are duplicated.

Or checking if a sequence of ( and ) is well formed (each ( has a corresponding )).

The solution for this project should show if the tester understands the basics of Java and can write “easy to understand” code for a simple task.

If the solution is good, I ask for a GitHub repository (or a blog link) where the tester has sample Selenium automation code.

Looking at code that the tester wrote in the past shows you what code he may write in the future.

Good Selenium testers have sample code available for interviewing purposes so that they can prove before the interview how good they are.

When looking at sample code, I pay attention to
  • how the locators are designed
  • where are the locators stored (in the page classes, separate locator classes, property files)
  • if page object model is implemented
  • how page object model is implemented (to interact with the site’s features or to interact with HTML elements)
  • how short/long the page classes are
  • how many methods are in each page class
  • how easy to understand the test methods are
  • how long are the test methods
  • the automation framework’s layers
  • if utility classes are used as parent classes of the page classes (since utility classes are not following OOP principles)
  • if lots of static methods and variables are used (static and OOP are not going well together; also, static can be a problem for parallel execution)
  • if there are classes that implement functionality that already exists in the Selenium library (in other words, if the tester is interested in re-inventing the wheel)
  • how error handling is implemented
  • if there is duplicated code
  • if the code uses static delay


DURING THE INTERVIEW

The phone interview is first.

This is an opportunity to understand how good the communication skills are.

And to assess more the programming skills by asking questions with different degrees of complexity.

The questions can be about the Selenium library and even more about Java.

Good Java knowledge is essential for good Selenium test automation.

This means much more than basic concepts since understanding of topics such as

  • polymorphism
  • interfaces
  • generics
  • predicates
  • annotations
  • streams
  • composition
  • code refactoring

is essential.

The in-person interview is next where the programming skills assessment continues.

I may show the tester some code samples and ask

  • what is correct
  • what is incorrect
  • what would he change and why



AFTER THE INTERVIEW

Finally, the practical test.

An end-to-end test needs to be automated with Java and Selenium WebDriver.

First, an automation framework should be created.

Second, the automation framework is used for the following end-to-end-test:
  1. open www.bestbuy.com
  2. search for a keyword
  3. select a product that is available online
  4. add the product to the cart
  5. open the order basket
  6. choose to continue the checkout as a not-logged in user
  7. specify the user address info
  8. specify the payment type
  9. specify invalid payment info
  10. submit the order
  11. check that the correct error is displayed



I know, this process is complicated and time consuming.

But there are no simple solutions for complicated problems.

Better hiring processes are needed.

If not, you will keep hiring fake testers that are "professional test automation engineers" and either create a lot of bad code that will eventually be thrown away.

Or will create one test per month.

Why are Selenium automation jobs decreasing?

from indeed.com




The market demand for test automation is higher than ever but the number of automation jobs is lower.


How can this be?



One reason is the "test automation" name.

Test automation is not a good name for this type of work.

Automated checking or tool-assisted testing (James Bach) are describing better what actually happens.

Automation does not automate or replace creative testing but just checks that simple and clear test cases work.



Because test precedes automation in the name, companies and testers thought that test automation is a part of testing and it should be done by testers.

Testers thought that test automation is the silver bullet for their careers and went ahead with the "learning phase".

After learning the bare minimum of Selenium and a programming language in less than a year, many claimed that they are automation engineers instead of manual testers.

And some companies, especially the ones without rigorous interviewing processes, hired the manual-testers-converted-overnight-to-automation-engineers.

These "engineers" started with enthusiasm to build automation projects and wrote code, lots of code.

Which in most cases was just a bunch of crap.



I have seen such projects built by automation "experts" who
  1. do not understand inheritance and composition
  2. have no clue how to use interfaces
  3. don’t know what page factory, loadable component or yes, maven are
  4. use maps instead of objects
  5. create test classes with thousands of lines of code and hundreds of methods
  6. create page classes with click/type/getText methods for each page element (again with thousands of lines of code)
  7. use static methods and variables heavily
  8. use utility classes a lots


These are testers that are experts at writing-VB-code-in-Java.

The only thing that matters for them is if the code works now.

It is less important that the code is inefficient, not object oriented, difficult to read and maintain.

It is also less important that the code fails randomly when executed in Jenkins.

If the tests fail, we just rerun them until they pass.

After a while, companies start realizing that things are not going well at all, especially when they have a few thousands of tests which fail with a 25-30% rate.

And, at this moment, they switch direction and hire either developers or testers who became developers.

In most cases, a good developer can do the work of 3-4 VB-in-JAVA automation experts.



So, see, it is completely possible that the business demand is higher but the number of jobs lower.

The market matures and filters out people who are not suitable or ready for automation work.

Pradeep Soundararajan (from Moolya) said somewhere on Quora that
Not all manual testers will disappear, only the unprofessional ones.

My opinion is that this is happening for test automation as well:
The professional automation engineers will stay, the other ones will fade away.


Contrary to what you hear from a lot of people, test automation is not easy and it is not for anyone.

To do it well, you have to learn a new job and become a developer.

Test automation - from theory to reality

If you have been reading about test automation in magazines, blogs or books, you get the idea that automation is nice, easy, straightforward and beautiful.

Because all these talk about theory, most of the time. 


Theory is always like a finished, simple, beautiful, well designed, professionally-done building. 






In theory, automation is about having 

  • independent tests
  • tests that create their own data and delete it after being executed 
  • dedicated test automation environment 
  • tests that run in parallel 
  • tests that use simulated external dependencies 
  • tests that run in 3 minutes  
  • good code written by professional people


This all sounds great and makes you want to get started with test automation tomorrow :) 




And how is test automation in reality? 

Have a look at this construction. 




Automation in real life means in many cases

  • dependent tests; if one test fails, multiple other tests fail 
  • tests that use manually created data; the data is also different from environment to environment; 
  • shared test automation environment; the tests are created and executed on an environment used as well for manual testing 
  • tests that run in "parallel"; instead of having tests executed in parallel on multiple Jenkins slaves, you have tests executed in "parallel" on the same slave 
  • tests that use real external dependencies 
  • tests that run in a few hours 
  • bad code written by non-professional people




Theory and reality are never similar. 

To get from reality to something similar to theory is difficult and takes a long time. 

But it is worth doing, that is for sure!

SeleniumJava.com post - How to deal with windows authentication popups

If you dont like Bugs Bunny, maybe you should not continue reading.

What is the first thing that I do every morning at work?
Check the results of the automation scripts executed in Jenkins over night.
I want to know how many scripts passed or failed because of the work done in the previous day.
Most days, some scripts pass and some fail.
But recently, most scripts failed.
This was very unusual so I looked into it right away.
All failures followed the same pattern: the scripts failed on opening the site in the browser.



A day in the life of an automated tester

What does an automation engineer do?

What skills does he need?

How does a work day look like?

What problems does he face?

How are they solved?

What else except writing code is involved in test automation?

Are all automation jobs the same?




Test automation jobs are as diverse as the manual testing ones.

Many things can be different between 2 automation jobs:
  • application type: web site, mobile app, windows application or a console utility
  • programming language: automation is done mostly in Java and C# but also in Ruby, Python and JavaScript
  • automation library: open source (example: Selenium WebDriver, Appium, Robot Framework) or proprietary (UFT)
  • how the tests are designed: unit tests, behaviour integration tests, etc
  • project's design: page object model, page factory, keyword driven are just a few different models that can be used for automation


Test automation jobs can focus on different things.
Some create the automation project from scratch.
Others create tests for an existing framework or redesign existing automation frameworks.


Every job is about solving problems.

This series of articles aims to describe a day in the life of an automated tester, the problems that the tester has and their solutions.

Everything that follows is about a fictive job but inspired from reality.

Thanks for reading.



Day 4 - Page Object Model
Day 3 - About Automation Test Data
Day 2 - What Type Of Automation Job Is This?
Day 1 - First Day Of A New Job