Power Your Software Testing with AI Agents and Cloud
The Native AI-Agentic Cloud Platform to Supercharge Quality Engineering. Test Intelligently and Ship Faster.
- TestMu AI (Formerly LambdaTest)
- /
- Blog
- /
- Write Your First Automation Script In Just 20 Mins!
Write Your First Automation Script In Just 20 Mins!
Writing a first Selenium automation script in Python takes about 20 minutes once Python and geckodriver are installed. The script opens a live page, finds an element by its class name, and waits for a result with WebDriverWait instead of a fixed delay, the same pattern production test suites use. This guide covers why automation matters and how to write and run your first UI test.
Last Updated on:
Writing a first Selenium automation script in Python takes about 20 minutes once Python and geckodriver are installed.
The script below opens a live page, finds an element by its class name, and waits for a result with WebDriverWait instead of a fixed delay, the same pattern production test suites use.
This guide covers why automation matters and how to write and run your first UI test.
Key Takeaways
- A first Selenium automation script in Python takes about 20 minutes once Python, Selenium, and geckodriver are installed.
- WebDriverWait polls for an element up to a timeout instead of a fixed delay, making a script faster on quick loads and more reliable on slow ones.
- Selenium 4 is the current major version, and geckodriver still bridges Selenium to Firefox the same way older Selenium versions did.
- A locator built from a single class name, such as desktop-searchBar, breaks a script the moment that class name changes on the target site.
- An AI test assistant can generate a Selenium script from a plain-language description, cutting the setup time for a first automation script.
- Selenium 4 ships no built-in self-healing, so a broken locator in a Selenium script still needs a person to fix it, unlike a self-healing test tool that repairs its own locators.
What Is The Need For Automation?
A first Selenium script for Firefox comes together in about 20 minutes, using Python's webdriver module to open myntra.com with a 30 second page load timeout and find the search bar by its desktop-searchBar class name. After typing watch and clicking submit, it waits up to 10 seconds for the results panel and saves a screenshot called loggedIn.png.
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.
You can also hasten your Selenium script generation by using AI test assistants like KaneAI.
KaneAI by TestMu AI is a GenAI Native QA Agent-as-a-Service platform crafted for quality engineering teams. It offers AI-driven features for test authoring, management, and debugging. With KaneAI, users can effortlessly create and modify complex test cases using natural language, making it faster and easier to start with test automation without needing deep technical expertise.
You can quickly generate your Selenium automation script by simply describing your testing needs in natural language. KaneAI effortlessly converts your instructions into a functional script, cutting down the time and complexity typically involved in getting started.
There are several ways to quickly start GUI testing automation 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.
- 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/
- Install selenium libraries for python. [
- Install geckodriver
Command to check python version using command line :- python –version
http://selenium-python.readthedocs.io/installation.html ]
command:- pip install selenium
Selenium 4 is the current major version, and geckodriver still bridges it to Firefox the same way. 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]:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from random import randint
browser = webdriver.Firefox()
browser.set_page_load_timeout(30)
browser.get('https://www.myntra.com/')
assert "Online Shopping" in browser.title
search = browser.find_element_by_class_name("desktop-searchBar") # Find the search box by class
search.send_keys("watch") #send the value of search field
submit_button = browser.find_element_by_class_name("desktop-submit")
submit_button.click()
#Lets wait for lobby page to load
delay = 10 # seconds max wait
myElem = WebDriverWait(browser, delay).until(EC.presence_of_element_located((By.CLASS_NAME, "horizontal-filters-title")))
browser.save_screenshot("loggedIn.png") ## This will be stored in the location/path mentioned or the current directory
browser.close() # close browser
Tips:- Locate selenium elements for python – http://selenium-python.readthedocs.io/locating-elements.html
The below glimpse of Selenium Advanced certification is ideal for testing professionals who want to acquire advanced, hands-on knowledge in Selenium automation testing.
Can AI Fix a Broken Selenium Locator Like desktop-searchBar Automatically?
Not inside Selenium itself. Selenium 4 has no built-in self-healing, so a renamed class such as desktop-searchBar still breaks the script above until a person edits the locator and reruns it.
AI-augmented test platforms close that gap by re-resolving a locator from the surrounding page structure instead of failing outright. The healer agent in Playwright Test Agents runs a failing test, repairs the broken locator, and returns a passing test or a skipped test when it judges the underlying feature broken, not the locator. This matters most inside a cross browser testing matrix, where the same locator has to survive on every browser, not just one.
Selenium itself gets no such repair automatically. A locator change on myntra.com, such as desktop-searchBar becoming search-bar-desktop, still needs a person to edit this code and rerun it every time the site changes, a real cost inside a regression testing suite where the same script runs unchanged for months.
A more resilient script also tries a second locator, such as an id or a data attribute, before it gives up, so the same class rename does not need an AI copilot at all.
Author
Salman is a Test Automation Evangelist and Community Contributor at TestMu AI, with over 6 years of hands-on experience in software testing and automation. He has completed his Master of Technology in Computer Science and Engineering, demonstrating strong technical expertise in software development, testing, AI agents and LLMs. He is certified in KaneAI, Automation Testing, Selenium, Cypress, Playwright, and Appium, with deep experience in CI/CD pipelines, cross-browser testing, AI in testing, and mobile automation. Salman works closely with engineering teams to convert complex testing concepts into actionable, developer-first content. Salman has authored 120+ technical tutorials, guides, and documentation on test automation, web development, and related domains, making him a strong voice in the QA and testing community.
Write Your First Automation Script FAQs
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance
- Advanced access controls
- Advanced data retention rules
- Advanced Local Testing
- Premium Support options
- Early access to beta features
- Private Slack Channel
- Unlimited Manual Accessibility DevTools Tests





