🚀 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.
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:python --version
Python is clean, readable, has great community support, and works beautifully with Selenium for test automation.
-
Download the latest version (Python 3.10+ 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.
💻 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
Create a New Project Folder:
📦 Step 3: Install Selenium
Now let’s bring in the hero of our story.
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.
🔹 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:
Congrats 🎉, 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
.gitignore
to avoid uploading sensitive files -
✅ Log test results (we’ll cover
unittest
andpytest
soon)
🔄 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 like working with dynamic elements, handling popups, 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