Skip to Main Content

Getting started with Web Automation using Selenium

If you’re a web tester, you’ll eventually come across Selenium, an open-source test automation tool that’s been gaining popularity since its launch in 2004 and is still trustworthy while being conventional.
undefined

Conventional yet powerful tool

Putting the system to the test in the face of adversity is a challenging task, and you'll need a tool to assist yourself. It is one of the most widely used automation testing tools. You've come to the right place if you're new to this tool and want to learn how it works from the ground up. In this blog, I'll give you a quick overview of the Selenium WebDriver Architecture and how to set it up in Ubuntu.

What is Selenium?

Selenium is an open-source tool that lets you interact directly with browsers using automation test scripts on a variety of browsers It is platform-independent as the same code works on all the major OS like Windows, macOS, and UNIX. Testers can execute a huge number of test cases in a short amount of time using the tool, and it also aids in the development and execution of full, browser-based regression automation suites. It works with a number of different programming languages, such as Java, JavaScript, Python, C#, and others. It can be easily integrated with several frameworks like the ANT or Maven for compiling the source code. There are also many kinds of testing that can be automated using Selenium. Some are Unit Testing, Regression Testing, and Automated Browser Testing.

All the updates are easily available and do not require any specific training. Thus, this makes WebDriver a budget-friendly tool.

What is Selenium WebDriver Architecture?

The architecture consists of four layers:

selenium_webdriver_Glide_Invest
  1. Selenium WebDriver Client Libraries - When we choose a tool, the first thing that comes to mind is: Does this tool support the language that I am familiar with? Yes, Selenium Web driver supports a wide range of languages, including Java, C#, Python, Ruby, PHP, and others, and allows testers to automate in their comfort zone.
  2. JSON wire protocol - JSON, or JavaScript Object Notation, is a simple data format for storing and exchanging information. In the WebDriver architecture, the JSON wire protocol is used to communicate between Selenium scripts and Browser Drivers.
  3. Browser Drivers - We have a browser driver for each of the browsers that Selenium supports. As a result, these browser drivers communicate with their respective browsers and carry out commands by decoding Json sent by the browser, and then the response is given back in the form of the HTTP response.
  4. Browsers - Selenium can only run tests on browsers that are installed locally, either on the client or server machines. As a result, you'll need to install a browser on your system and it supports a variety of browsers, such as Chrome, Firefox, Internet Explorer, and others.

Getting Started

Setting up Selenium-WebDriver for Python on Ubuntu is simple; we'll go through everything you need to know step by step.

  1. Install Python
    • Python (version 2.X or 3.X should be okay. I am using Python 3)
    • Check whether python is already installed on your system by typing python3 –V command into your terminal.
    • If you get Python 3..on your terminal, that means the Python is already installed and if it is not installed, you have to run sudo apt-get install python3.9 –y or apt install python3-pip.
  2. Install Selenium package
    • Run pip3 install selenium
  3. Steps for installing Firefox driver
    • Since the default browser on Ubuntu is Firefox, I would like to use Firefox in my case. Download the driver based on the Firefox version installed on your system. You can check the version by entering ALT >> Help>>About Firefox
    • Go to the https://github.com/mozilla/geckodriver/releases and in this guide, we will use wget to download the file. To download, make a right-click on get and copy the link.
    • Now open the terminal and copy-paste the below command and replace it with the right Firefox link wget https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriv er-v0.30.0-linux64.tar.gz.
    • Extract the tar file by running tar -xvzf geckodriver-v0.30.0-linux64.tar.gz
    • Make it executable using chmod +x geckodriver
    • Move geckodriver binary to your system PATH by running mv geckodriver /usr/bin/local
  4. Run the Python Script
    • Here is an example of a script I have written in Python, which will launch the browser automatically and open the Glide Invest site, and will print the title on the console
    • I'm using the pycharm editor here, but you may use whichever editor you like.

Screenshot of selenium script

Screenshot of selenium script

Conclusion

On the Ubuntu operating system, we covered the fundamentals of getting started with selenium and python. In the next blog, we will see how to set up a project and write a script in detail for automating web-based applications.

Stay Tuned!!

Click to start searching
Recent Posts
Focused funds: Should you invest in them?
5 minsOctober 04, 2022
Multi-asset allocation mutual funds: Should you invest in one scheme instead of three?
7 minsSeptember 30, 2022
Rich Dad’s Cashflow Quadrant Book Review
11 minsSeptember 27, 2022
Money frauds Online: More and More People keep falling Prey
6 minsSeptember 23, 2022
World Rowing Championship 2022: Different Investing Lessons the Sport Offers
7 minsSeptember 20, 2022
Posts by Categories
International Investing (3)
Glide Portfolio (3)
Tech (3)
Passive Investing (7)
Goal Planning (9)
Investment basics (10)
All Stash! (10)

Like What You See? Want to learn the simple ways to make investment stress-free?

Sign up for our newsletter & get the best expert advice & news around the financial world

We won’t annoy you more than once a week, Pinky Promise!

Focused funds: Should you invest in them?

Trying to understand focused funds & invest in it? Here is all you need to know about focused mutual funds, its definition, taxation, returns & who should you invest in it

Multi-asset allocation mutual funds: Should you invest in one scheme instead of three?

Learn about multi-asset mutual funds and where to invest them? Learn more about multi-asset mutual funds, benefits, limitation & performance.

Rich Dad’s Cashflow Quadrant Book Review

The Cashflow Quadrant book by Rich Dad provides all the information needed to achieve financial freedom and achieve your income goals.