Write Your First Automation Script In Just 20 Mins!

Posted by Nishant Kashyap | December 12, 2017
Automation β€’

18874 Views | 2 Min Read

What Is The Need For Automation?

In today’s world, testing can not be efficient without automation. We need automation for avoiding repetitive work, making sure that the time from development to deployment is reduced with good quality.In order to achieve these, we need reliable automation tests and regression suite. Manual test(s) should just support automation for feature/product testing and release not vice-versa.

We need good, quality automation tests, not just automation tests. We need tests which are reliable, robust, easy to code, debug, scale and can run in parallel on distributed environment.

How do I write my first UI test?

One love for Selenium! Isn’t it ?

Since, Selenium is an open source testing tool it serves the need for cost-effective automation testing and the community always support the cost effective tool with required features.
It’s capability to operate on almost every OS and multiple language support i.e. Pearl, PHP,Python, Java, .NET(C#) and Ruby provides the flexibility that every user wants.
The language which is mostly used for building the program is independent of the language that is being used by the web application or website. Which implies that you can develop the test script in any of the mentioned languages that the Selenium supports.

There are several ways to quickly start automating a GUI flow using selenium. Let’s do it using python.

Pre-Req : We need python and selenium binding to be installed in the machine. If you don’t have already , follow the below steps.

  1. Download and install Python :-
    • MAC: https://www.python.org/downloads/mac-osx/
    • Linux: https://www.python.org/downloads/source/
    • Windows: https://www.python.org/downloads/windows/

    Command to check python version using command line :-
    python –version

  2. Install selenium libraries for python. [
  3. http://selenium-python.readthedocs.io/installation.html ]

    command:-
    pip install selenium

  4. Install geckodriver
  5. Since we will use latest version of selenium(3.0) with latest firefox bindings , download geckodriver :- https://github.com/mozilla/geckodriver/releases

    OR
    Install using command line ( using brew ):-
    brew install geckodriver

    We are all set to write our first test!
      Let’s search for an item in myntra.com

    Code [ Self Explanatory]:

    Tips:- Locate selenium elements for python – http://selenium-python.readthedocs.io/locating-elements.html

    Written by Nishant Kashyap(Guest Post)

    Nishant Kashyap brings over a decade of combined experience in development and test automation which includes Selenium RC /2.0 (Webdriver), TestNG, JUnit , REST, Appium and designing test frameworks on API , UI , Mobile , game automation bots! He has built and spearheaded software quality and testing teams at some of the leading firms such as Adobe, LinkedIn, and Oracle!

Related Articles