🚀 Getting Started with Python for Selenium Automation – Installations, Setup & Best Practices (Beginner Guide)
🚀 Getting Started with Python for Selenium Automation – From Beginner to Pro (Part 2)
(Search "Blog 1: What is Automation Testing" on this site to read it)
Now that we’re aligned with the “why”, let’s dive into the how. Cause we crave for practice rather than theory:
This post will walk you through:
-
Installing Python the right way
-
Setting up your development environment
-
Installing Selenium
-
Writing your first test
-
Structuring your project using GitHub
-
Best practices for beginners
Let’s start building your automation journey!
🐍 Step 1: Install Python (Latest Version Recommended)
👉 Why Python for Selenium?
🔧 How to Install Python:
Before installing, let's check if you have Python. I personally suggest the latest version (currently latest3.13.5), check it by using:
python --version
If you have lower version then download latest one.
Python is clean, readable, has great community support, and works beautifully with Selenium for test automation.
-
Download the latest version (Python 3.13+ is preferred)
-
During installation, check “Add Python to PATH”
-
Verify installation via terminal/command prompt:
💡 Pro Tip: Use pyenv for managing multiple Python versions if you’re a Linux or Mac user.
I use Windows and don't have much knowledge of Mac and Linux. But tell me, I used Linux, Debian Linux( cutefish Os, it fine wine in OS) and also MacBook Air, I know how it works basic.
💻 Step 2: Set Up Your Development Environment
Let’s make sure your environment is neat and organised.
🧰 Recommended Tools:
-
VS Code – Lightweight and feature-rich (Download)
-
Git – Version control (Download)
-
GitHub – Store your test scripts online (Repo)
-
Python Virtual Environment – Keeps dependencies clean
PyCharm - The best for Python. I use the community version. You may also like a general smooth working thing " phale istemal karo phir vishwas karo -- Pycharm"
Create a New Project Folder:
📦 Step 3: Install Selenium
Now let’s bring in the hero of our story. Cause once a amma said "everyone thinks they are rowdy until real comes".
You can directly use CMD to download it, or you may use the terminal of tools, so if the device works properly, use CMD, if not use terminal tools, save a lot of time still figuring out why...... ahhhh (sigh).........
Verify it works:
You’re now officially a Selenium user!
🌐 Step 4: Install WebDriver (Chrome/Edge/Firefox)
Selenium needs a driver to communicate with the browser. So install it if you don't use them or simply if you don't wanna do anything else, or then try using Edge or Firefox, simple and good. But remember in training, opting simple solution (Greedy method) doesn't always work best for dynamic problems, my experience says it.
Let me explain why, cause in my Internship at XYZ company, I was assigned to write a script for the automation, so I used Chrome, which was easy and had many functionalities, but the after completing basic login script it work properly but using general browser cause pwd alert js which hinder in next so i switch to fire fox now when I completed my scripting my senior used chrome so i have to write it again with the help of senior I got the idea to how o mange these kind of errror.
A better guide uses Chromium web driver if required help in that comment.......
But for the rest, here are the steps to download Chrome cause you can use Chrome on any OS.
🔹 For Chrome:
-
Check your Chrome version:
Menu → Help → About Chrome -
Download ChromeDriver matching your version
Add it to your system PATH
Optional: Use webdriver_manager To skip manual steps:
Example usage:
✍️ Step 5: Your First Automation Script
Let’s open Google and search for something using Python & Selenium:
Okay, I used this trick to send 1000 messages of "I miss you" to my friend, it was fun..... wanna try, I will guide it also. But first, here try running this and write it, don't copy it, you wanna work on yourself...
Done my little friends, becoming a genius, proud of you.....
Congrats, buddy🎉, you’ve automated a Google search!
📁 Step 6:Organisee Code with GitHub
Your code deserves a home. Create a repository on GitHub:
🔗 https://github.com/kuro-shiv/Automation_Selenium_Python
Basic Git Commands:
Keeping everything on GitHub ensures:
-
Version control
-
Collaboration
-
Visibility for job portfolios
🧠 Best Practices for Beginners
-
✅ Always use a virtual environment
-
✅ Keep scripts modular (one function = one action)
-
✅ Comment your code
-
✅ Use proper waits instead of
time.sleep()Later (we’ll cover this) -
✅ Use
.gitignoreto avoid uploading sensitive files -
✅ Log test results (we’ll cover
unittestandpytestsoon)
🔄 What’s Next in Blog #3?
Here’s a sneak peek into the next post:
-
Learn how to locate web elements using advanced techniques
-
Understand the different locator strategies (ID, Name, XPath, CSS Selector, etc.)
-
Build a mini form test case
🎁 Bonus Tip: Speed Boost with VS Code Extensions
-
Python by Microsoft
-
Pylance for IntelliSense
-
GitLens for Git visualisation
-
Jupyter (if you're planning to write in notebooks)
✅ Conclusion
In this second step of your Selenium automation journey, we’ve laid a strong foundation by understanding the core architecture of Selenium and how it interacts with browsers. You’ve now set up your environment, installed Selenium, and written your first Python script to automate a browser—huge progress already!
Remember: becoming a Selenium pro isn’t just about writing test cases—it’s about understanding the flow, learning best practices, and building reusable, maintainable scripts. In upcoming blogs, we’ll dive into advanced interactions such as working with dynamic elements, handling pop-ups, performing end-to-end test scenarios, and integrating with test frameworks like PyTest or unittest.
Keep experimenting, play around with different websites, and try modifying your script. The more you break it, the more you'll learn.
Stay tuned, stay curious — and don’t forget to ⭐ star the GitHub repo for updates and code.
🙌 Final Thoughts
You’ve now taken a solid step toward becoming a Selenium Automation Tester using Python. The setup phase is boring for some, but it’s the foundation of everything pro-level.
Stay tuned for the next post! And don’t forget to:
✅ Star the GitHub Repo
✅ Share this blog with your friends
✅ Drop your questions or suggestions in the comments


Comments
Post a Comment