Selenium 3.0 – Introduction and Installation (Selenium, Maven, Junit, IntelliJ)

Introduction

Selenium is the most popular free open source web automated testing suit. Available across a wide range of browsers and platforms.

seleniumsuite

In this tutorial we are going to dig deeper into Selenium 3.0 and how to configure and run our first automated test. Selenium 3.0 (Also known as Selenium WebDriver) offers a well-designed Object Oriented API that can communicate with the application under test via language binding with native browser drives. In simpler words Selenium WebDriver provides us with an interface that we can utilize to use the browsers native ability to interact with the application under test.

seleniuminterface

As a result of being a thin wrapper that is language binding with browsers WebDriver can support multiple language and browsers. For our tutorial we are going to demonstrate building our first test using Java and the Firefox.

Installation and Setup

In this tutorial we are going to install and setup Selenium using the following tools and frameworks.

Automation Framework: Selenium 3.0 (Selenium WebDriver)

Java Test Runner: Junit (TestNG can also be used)

Web Browser: Firefox.

Browser Driver: Gecko Driver.

Build System: Apache Maven.

IDE: Idea IntelliJ.

Note: This tutorial follows the steps from the installation tutorial from Software Test Academy. The main difference is adapting to the changes in Selenium 3.0.

Download and Install Java Development Kit (JDK)

Download Link: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Instruction for successful installation:

  • Select the appropriate JDK version and select “Accept License Agreement” to begin download.
  • After downloading the JDK proceed with installation.
  • Add the “JAVA_HOME” in your environmental variables.
    • On “My PC” right-click and press properties.
    • From the left side panel select “Advanced System Settings”

      env-variable-1
      Click on “Advanced system settings” on the left.
    • Click on ‘Environment Variables’

      env-variable-2
      Click ‘Environment Variables’
    • Add New Variable “JAVA_HOME” with the value set to the location the JDK was installed usually “C:\Program Files\Java\jdkenv-variable-3
    • Confirm successful installation of JDK by running the following command in the command prompt “java -version”, the following screen shot shows the expected response.sussesful-jdk

Download and Setup Apache Maven (build tool)

Download Link: https://maven.apache.org/download.cgi

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information. I find it much easier setting up Selenium through Maven.

Instruction for successful installation:

  • Download latest Binary “Zip Archive Version” (eg. “apache-maven-3.3.9-bin.zip”)
  • Unzip downloaded folder in “C:/Program Files”
  • Add the Maven folder in the environmental variables.
    1. On “My PC” right-click and press properties.
    2. From the left side panel select “Advanced System Settings”
    3. Click on “Environmental Variables”
    4. Add New Variable “PATH” with the value set to the location the Maven folder is located in (Eg. “C:\Program Files\apache-maven-3.3.9\bin”)
    5. Confirm successful installation of Maven by running the following command in the command prompt “mvn -v”, the following screen shot shows the expected response.maven-sussesful

Download and Setup Gecko Driver (Firefox Driver)

Download Link: https://github.com/mozilla/geckodriver/releases

Selenium used to be responsible for providing the driver for each browser. Starting with Selenium 3.0 each browser vendor is responsible of providing its own implmentation for its driver. All browsers follow the W3C specification for browser automation. For Gecko Driver (Still in Beta) is currently the appropriate driver for Firefox.

Instruction for successful installation:

  • Download “Gecko Driver”
  • Unzip driver to “C:\Gecko Driver”

geckodriver

Download and Install Idea IntelliJ IDE

Download Link:  https://www.jetbrains.com/idea/download/

Intellij is my preferred choice for an IDE. I recommend using Idea IntelliJ for valid reasons; however eclipse could also be used. No need for instruction just click ‘next’ on the installation manager and you should be all set.

Setting up the enviroment

  1. Run IntelliJ IDE and click on ‘File’ and ‘New Project’.
  2. Select Maven from the left side and locate your Java SDK on the top and click ‘Next’.intellij-1
  3. Fill GroupID and ArtifactID and click ‘Next’. (I went for “SeleniumTestOne” however anything should work.intellij-2
  4. Fill in the project name as you like and click ‘Finish’. (Again I went for “SeleniumTestOne”)
  5. After clicking ‘Finish’ press on ‘Enable Auto-Import’ to automatically import the files added in the pom.xml file.intellij-4
  6. Setting up the pom.xml file to import the needed Selenium and JUnit libraries.
  7. Go to the project tree it should be shown as below.
    • Right click on ‘java’ then new ‘Package’, and give your package a name. (My example “FirstSeleniumTest”)
    • Right click on the newly created ‘Package’ then new ‘Java Class’, give your class a name. (My example “SeleniumFirstTest”)projecttree
  8. Write your first Java test automation code as below:
    package FirstSeleniumTest;
    import org.junit.Test;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    
    public class SeleniumFirstTest {
       @Test
       public void testOne(){
           System.setProperty("webdriver.gecko.driver", "C:\\GeckoDriver\\geckodriver.exe");
           //creae new WebDriver
           WebDriver FireFoxDriver = new FirefoxDriver();
           //Open google
           FireFoxDriver.get("https://www.google.com/ncr");
           //insert Hello! in search area
           FireFoxDriver.findElement(By.name("q")).sendKeys("Hello!");
        }
    }
  9. Press run and wait for the result.firstresult

We have concluded running our first automation test using Selenium, IntelliJ, Maven and JUnit. If you have any questions please feel free to ask. 🙂

Sources:

  1. http://www.seleniumhq.org/docs/
  2.  http://www.swtestacademy.com/quick-start-to-selenium-webdriver-with-java-junit-maven-intellij/
  3. http://www.guru99.com/introduction-to-selenium.html
  4. http://toolsqa.com/selenium-webdriver/selenium-introduction/
  5. https://dzone.com/articles/why-idea-better-eclipse
Selenium 3.0 – Introduction and Installation (Selenium, Maven, Junit, IntelliJ)

A culture of pessimism

It’s amazing how we have a complete population competing on becoming the greatest pessimist. A trend of great cultural pessimism is ruling our life. Online social media technologies has increased our possibilities of connecting through rich media content including text, images, and videos. In my daily routine of scrolling through my endless social network news-feed I have to go through a ton of shit included in our news, our stories, and sadly our jokes. Offline in friendly gatherings the pessimism continues through hopeless conversations. It’s astounding how everyone is talking about how they lead an unfortunate life; I personally call it the “I am unlucky syndrome”.

The continuous flow of pessimism has led to a grim reality where every day living in our nation feels tighter and worse. It nearly feels as if all hope is gone, and that any effort for positive change is just a waste of effort and time. STOP! Yes, you reading this just stop!

You weren’t expecting me to talk directly to you right? Well here are some interesting facts about you. Right now you are reading this stream of words on some sort of smart device, you are reading it over the internet, and guess what you are reading it in English too. Chances are you have a roof over your head and food in your fridge. Do you have any ideas where I am going with this? Well let me tell you plain and simple. Unlike most of Egypt’s population who can’t read or use the internet. You are capable of both which makes you intellectually responsible for providing a better future for our nation.

You can proceed to spread your negative thoughts about how unfortunate it is living in a poverty stricken developing country. However truthfully we do not need your pessimism. It is only leading and contributing to stress, anxiety, and depression. We need your ideas, time, and effort to start a new culture of knowledge and optimism.

A few years back I was sitting with a highly respectable Egyptian statisticians and he told me a very interesting fact. That an average Egyptian merely reads half a page per year. This is ridiculous, how can we hope for a better tomorrow when we are not learning from centuries’ worth of knowledge. Thousands of revolutionary people have their decades worth of life experience written and ready for you to consume within days. For a change stop consuming the shit in our news and in our statuses and start consuming books and articles which are available online cheaply and in many cases free.

For a better future stop feeding the pessimism, you are capable and responsible for providing a better future for your nation. Your simple act of cutting pessimism, educating yourself, and spreading your knowledge is sufficient to initiate a new culture where knowledge and optimism would one day lead to a tipping point for a brighter future.

ACTION FOR YOU: Read and spread knowledge and optimism .. I recommend you read “The Tipping Point” by Malcom Gladwell. Where he goes into more details on how small action can make big differences.

“The tipping point is that magic moment when an idea, trend, or social behavior crosses a threshold, tips, and spreads like wildfire.” – Malcom Gladwell, The Tipping Point

A culture of pessimism

Ideas worth executing

I like ideas, ideas make me feel alive. I spend hours of my day simply thinking about ideas. For many it may seem as if I am not doing much. I thought about it, well they are right I am not doing much. Ideas alone are worth pennies. On the other hand the execution of ideas is worth plenty.

I have thousands of ideas going through my head

  • Projects I want to start.
  • Books I want to read.
  • Books I want to write.
  • Languages I want to learn.
  • Blogs I want to start.
  • Communities I want to grow.
  • Trips I want to go.
  • Challenges I want to tackle.

I thought about it all.  I thought about it in great detail too. It’s beautiful really the excitement I feel with every new idea. It’s a stream euphoria starting from the top of my brain to the bottom of my spine. Truly ideas excite me, for me ideas are worth the world. It’s the failing of executing those ideas that make my ideas worth little to everyone else other than me.

Every now and then I execute one of my ideas, leaving me on the top of a trail of success and pride. However I know I am not executing enough. For this today I decided to share my thoughts with you. Hoping to introduce a new phase of acceleration and growth to my life.

For me my failure to execute stems from my fear of taking new steps. A friend once referred me to a Russian author called Fyodor Dostoevsky, in his book Crime and Punishment lies this beautiful quote:

 “Taking a new step, uttering a new word, is what people fear the most.” – Fyodor Dostoevsky

Fyodor pinpointed it perfectly we fear novelty, and ideas are very novel (I laughed writing this).  Pushing past our comfort zone is where all the magic happens. It takes time and effort. We may fail, but only through execution is where our ideas can live leading to growth. Growth is where we truly thrive.

Bonus: Just two month ago my dear friend Hanya Seleem told me about an idea she has about designing her very own custom made mobile covers. Hanya decided to execute her idea, it took time and effort. Yet just last week she launched her very first product line (Here: Hanya Saleem Designs). First of all they are beautiful. Is it a success? Maybe I don’t know, but I know one thing for a fact. Now when I think of Hanya I think of Hanya as a creator, not just another face from seven billion.

Execute … Create … Fail … Repeat … Succeed … Be someone not just another face from seven billion.

Ideas worth executing

The new beginning

Today is the first day of the rest of your life. ~

I focused on my 3 basic areas of my life for nearly two years (Education, Knowledge, and Social life). Beside that I also focused on trying to figure out what I wanted to accomplish in life. It was tough I didn’t have a clue what I really wanted. I wanted to be successful, but it wasn’t the money nor fame that I was after. Success in our modern culture is measured by money and fame. I built a vague idea of what I needed to do first. I needed to redefine what the word “success” means in my world. Define it to something of higher value to me then money and fame. Shortly later I redefined success to living comfortably, working hard, playing hard, and having loads of fun. This is where I came up with two mottos that redefine success in my world.

My first motto is short, but it carries a deep yet simple meaning:

“Work hard; Play Hard”

Simply it means what it says. When it is time to work do your very best. Don’t slack nor cut around edges. Give it your all 100% of time, energy, and love (Yes Love, if you don’t love what you are doing just cut the bullshit and stop doing it right NOW!) When I am programming this is always the case. I code with all my passion I give it dedicated time and energy. I love my code to an extent I feel connected to my programs. The hard work pays off ending into programs I am proud of and good grades (I am still a student). When it is time to work; do nothing but work. When it is time to play; Do nothing, but play. Play hard means giving your play time your 100% of time, energy and love. Get crazy and be like an energetic child who is discovering a new world for the first time. Actually this is not only about work and play. This is about every single thing in your life. If you are eating, writing, singing, or even admiring the wall ahead of you give it your everything. The point of “Work Hard; Play Hard” is to let you experience life to its fullest and this ladies and gentlemen is SUCCESS.

My second motto to success simply describes how I would like to be living. It is quite clear, however I will also go a little into it:

“Live to ENJOY, LEARN, and SERVE”

This is exactly how I want to be spending my time. Enjoying every moment I live. The world is a big playground don’t take things to seriously enjoy it instead. Enjoy the challenges, the adventures, the risks, and even resting days (Resting days: Days where you sit and do nothing at all, YES enjoy those). Enjoy the amazingly good days as well as the not so good ones. Enjoy it all because you really live only once. Learn is another word I associate with success. You need to learn continuously every single moment teaches us something new. Absorb it all because every single new thing you learn is what makes you in the end. Last thing is serve, we all have abilities that differentiate us from one another. Your abilities are someone else’s needs. As much as we all love to get things in return for what we give, but nothing ever feels better than giving without return. Serve the community, the people, and the environment. Serve as long as you can. Three words that can make someone’s life into a great success enjoy, learn, and serve.

The new beginning

This F***ed up Moment, Your time is Precious !!

A few weeks ago I wrote this short post:

“Your time is precious don’t waste it doing the wrong things. Use every moment to create something. Getting closer to God is something. Creating a bond with someone is something. Creating a new project is something. Creating anything that has value to you. Don’t waste your time doing the wrong things, or with the wrong people. Use it to enjoy, learn, and serve I would always say. I can have weeks of laziness. However I am happiest when I am using my time creating something. Use your time you don’t have much left”

At this specific moment I felt how short our life’s truly is and that there isn’t enough time left. I typed this quickly and posted it for everyone to see. However I want to re-write this with a better structure and style.

The Panic:

Well, if I were you I would start panicking because really you don’t have much left. Every day that passes is one day taken from your life. Today is one of those days. How did you use today? Did you do something fun? Did you learn something new? Did you help someone achieve something? Did you show gratitude for the things you have? We can go on and on with questions. However if the answers to all the questions are “NO”. Then I have bad news for you today was WASTED. Yes, it was wasted you did nothing special. You haven’t even done anything basic. Sorry for being harsh, but till when will you keep saying in the future I will be great. In the future I will create. In the future I will be different. Shut up and realize what you missed today. You missed an amazing day with a little effort you could have started something that could make you great and change your life to the better forever.

The Math:

Let’s do some basic math, I am a programmer after all I think with numbers. First, get on your favorite search engine and find what the life expectancy is in your country. Then calculate how much time you have left. Of course this is an estimate you could over and under live this estimate by years.

The life expectancy here in Egypt is 70 years. If you are 10 well statistics say you still have another 60. If you are 65 you need to start enjoying your time seriously. I stopped here, however if you want to do further calculations go ahead.

The “Its Okay moment”

I hope I freaked you quite enough to start realizing that time is running out and you need to start doing more. However relax time is running out, but there is always plenty of time to make it count. Even if this hour is your last it’s plenty to change your life. However it is you who decides to either make it count or let it go in waste. Some of the world’s most inspirational people did amazing things in extremely short time. Don’t feel discouraged to be great today. STOP the bullshit of the future is going to be amazing all you have is TODAY

This F***ed up Moment, Your time is Precious !!

My humble view on Life

In my attempt to answer the question “What is Life?” here is what I ended up with after minutes of deep thinking. It didn’t take long because the answer is obvious, yet so many of us just can’t see it.

20090530-edge7

The Beginning (Journey) we all come into life with a reason and purpose to fulfill. It could be something as small as help someone reach their dream or as big as Changing the world. It doesn’t really matter what the purpose of your life is, but the fact is there is one. Some people leave life without knowing what their purpose is they leave unsatisfied and empty. Do me a favor and don’t leave empty take this moment to find your purpose. Once you know your purpose push forward and get done with it.

The present (live) is all you have got. Give it every ounce of energy you have and start enjoying now. Stop worrying about the future you might even never see it. I am sure there is a couple things on your mind that you are delaying for later. Stop delaying and start doing now.

The Focus we keep focusing our energy on wrong choices giving it our all. Take this Moment to think of the things that occupy your mind everything from your work to the small things you do. Do those things really deserve all this focus? If not just stop and focus on things that really deserve your attention. (Note: I am not telling you to stop doing them. Just give it less importance).

The Discovery the world is a beauty out there it has everything from seas to beautiful mountains. Give some time to really go and give those things the attention they deserve. Get out of the four wall world you are living and experience what real life has to offer. While you are at it don’t forget to thank the creator of everything around you.

The People around you are all exactly like you trying to figure life. A lot of them are failing miserably. Take the chance and get closer to them. Unite and solve life’s mystery together it will make things a lot easier.

Life is a mystery we are all trying to solve a long journey that ends before you know it. While you are at it live every moment once it’s gone it’s gone forever. Focus on the right things don’t give too much attention to things that don’t really matter. Discover the beauty we are given and thank the creator.  It’s easier with people.

My humble view on Life

Kill the Routine

       Hello ladies and gentlemen today I would like to happily declare you as part of the routine. Yes, a routine where society placed you convincing you that this is what life is all about. From the day you were born till the day you die you are part of society’s routine. A routine that makes you believe that happiness is waiting for you on the other side of the road. A routine you never questioned, as a matter of fact you market the routine. Encouraging your friends and family to join your ultimate misery. Misery! Yes, you heard that right. I am sure by now you are wondering what I really mean by the word routine. Hang on as I slowly reveal to you what this is all about.

     We are born in a world where belief controls our life. Everything we encounter along the day has a certain belief associated with it. The emotions we feel are all based on certain beliefs that we have built on certain actions. For example when you see a colorful advertisement on the television with a fast paced tune we feel happy and cheerful because that’s our belief of happiness colorful and fast. Imagine this small example on everything. We base our lives on BELIEFS  From the moment we are born society starts to build our beliefs telling and showing us how we should feel about things. Until the day we are put in school and here ladies and gents where the routine all starts.  Society comes in and says “School is where all successful and happy people are formed”. Boom the 12 years just flashes in a moment and school is finished with all its moments it’s gone forever. We just finished school shouldn’t happiness just show up? “No” says the society, “All the successful people have higher degrees and successful people are happy!” Here we go again with a new goal of having a higher degree to reach success and therefore happiness. Boom another 4 years at least have passed and here again we turn to society asking have I finally reached? “Of course not” says society “You should find a well-paying job to feel the freedom”. Fed up, a quarter of our life has already passed and we still didn’t find the happiness we were promised a decade ago. We still listen to society and start our job hunt an interview after the other and finally a well-paying job is landed. The enthusiasm has been halved still looking to society for desperate hope questioning the whole process. Society with a quick move picks us up. Promising that the journey is nearly over saying “Well done my dear, you are nearly done all that’s left to do is build your empire. You must acquire three things and Happiness would automatically be granted. Become rich. Have power. Become famous.” Although we have started to question society this time it looks so much clearer power, money, and fame would defiantly satisfy our hunger for happiness. The journey has begun gaining power, money, and fame for the next few decades we have grown our three sources of happiness, but happiness is nowhere to be found. Society has promised and we believed so we decide to put more effort and time into reaching happiness. There comes a moment where some of us realize that society has lied and go a different route maybe finding happiness. The depressing truth is that the majority never realize sitting on their death bed wondering maybe they haven’t made enough money, power, or fame. Leaving the world disappointed believing they haven’t worked hard enough. Unhappy they leave.

     Here is where most the society has fallen prey to a self-made monster of routine. The routine has been lived by millions of people and still would be lived by millions to come. The purpose of this article is not to limit your dreams. Education is an essential part of our development. Also money, power, and fame are all essential parts of our lives, but at no moment should they be our priorities. This is an eye opener that encourages you to question the routine. Only you know what makes you happy. Discover, risk, fail, succeed, and repeat until you find your path to happiness. Defy the society, the routine, the beliefs, and start building your own trail to happiness. Once you have reached turn around and watch as society follow hoping to reach a place where you and I only know the secret behind.

Kill the Routine