Web UI Automation with the Selenium Suite and AutoIT
A website test may need to open a page, enter a name, click Login and check a message. Selenium can repeat these browser actions from a recorded test or program.
Automation means software performs the planned steps. You still need to choose useful checks and compare the actual result with the expected result.
Selenium is a set of tools for automating browsers. It can repeat actions such as login, search and checkout. Tests also need checks to decide whether the actions produced the expected result.
Your test code is the remote control, the browser is the car. You press buttons on the remote (click, type), and the car moves on the track (the website). WebDriver is the radio signal between them.
The Selenium suite
| Component | What it is | Typical use |
|---|---|---|
| Selenium IDE (Integrated Development Environment) | A browser extension that records and plays back your actions as commands (open, click, type, assert text) |
Quick tests, learning, exporting tests to code |
| Selenium RC (Remote Control, Selenium 1) | A server that injects JavaScript into the browser; tests in Java etc. talk to it through DefaultSelenium |
Old (legacy) – replaced by WebDriver |
| Selenium WebDriver (Selenium 2+) | Language libraries that drive the browser natively through a browser driver (ChromeDriver, GeckoDriver) using the W3C (World Wide Web Consortium) WebDriver protocol | Modern automation in Java, C#, Python, JS |
| Selenium Grid | A hub + nodes to run tests in parallel on many browsers/machines | Cross-browser testing, faster suites |
flowchart LR
T[Test code<br/>Java + WebDriver] -->|W3C WebDriver JSON over HTTP| D[ChromeDriver]
D --> B[Chrome browser]
B --> A[Web application]
RC[Selenium RC server] -. "legacy: injects JavaScript (Selenium Core)" .-> B
| Selenium RC | WebDriver | |
|---|---|---|
| Architecture | Test → RC server → JavaScript inside the browser | Test → browser driver → browser (native) |
| Server needed | Yes | No (except for Grid) |
| Speed and realism | Slower, limited by the JavaScript sandbox | Faster, behaves like a real user |
| Status | Deprecated | Current standard |
Locators – finding elements
Before the robot can click a button, it must find it on the page. A locator is the "address" of an element.
| Locator | Example | Note |
|---|---|---|
By.id |
By.id("username") |
Fastest and most stable |
By.name |
By.name("q") |
Good for form fields |
By.className |
By.className("btn-primary") |
May match many elements |
By.linkText / partialLinkText |
By.linkText("Checkout") |
Links only |
By.cssSelector |
By.cssSelector("#cart .total") |
Powerful and fast |
By.xpath |
By.xpath("//button[text()='Login']") |
Most flexible, but can break easily |
Synchronisation – handling dynamic pages
Modern pages load parts of the content later (asynchronously). A test that clicks before an element exists fails with NoSuchElementException.
| Wait | How | Recommendation |
|---|---|---|
Thread.sleep(3000) |
A fixed pause | Avoid – slow and unreliable |
| Implicit wait | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)) |
A global rule: keep trying for up to 10 s when finding elements |
| Explicit wait | new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.id("pay"))) |
Best – waits for one specific condition |
| Fluent wait | An explicit wait with your own polling interval and ignored exceptions | For unusual conditions |
Assertions and evidence
- Check the outcome with assertions: page title, element text, URL (Uniform Resource Locator), element visible.
- In Selenium IDE:
assert text,assert title,verify element present(assert stops the test on failure, verify notes it and continues). - Take screenshots with
((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE)– useful for each step and when a test fails.
Page Object Model
Put each page's locators and actions in one class, such as LoginPage. Tests call methods such as login(user, pass). When a page changes, update that page class instead of repeating edits across tests.
AutoIT – when Selenium cannot reach
Selenium controls the web page. A Windows file-selection or login dialog is outside that page. AutoIT can control these Windows dialogs. The example below types a file path and clicks the Open button.
WinWaitActive("Open")
ControlSetText("Open", "", "Edit1", "C:\files\resume.pdf")
ControlClick("Open", "", "Button1")
What the script does: wait for the Open window → type the file path into the file-name box (Edit1) → click the Open button (Button1).
The script is compiled to an .exe and called from the Selenium test with Runtime.getRuntime().exec("upload.exe") right after clicking the Browse button.
Explain the four Selenium components, RC vs WebDriver, the main locators, and implicit vs explicit waits. AutoIT complements Selenium for native OS (Operating System) dialogs.
Practise it
Virtual lab · Testing Tools · 30 min
Record, assert and replay tests with Selenium IDE
Install the Selenium IDE extension, record a login on the VLP Demo Store, add assertions, build a negative test, watch a broken assertion fail, run the suite and export the test to Java JUnit.
Virtual lab · Testing Tools · 25 min
Selenium Remote Control: server + registration test
Start the Selenium RC server from the command prompt, run a JUnit test that uses the classic DefaultSelenium API to fill the registration form, and follow every Selenese command in the server log.
Virtual lab · Testing Tools · 35 min
Automate a complete checkout with Selenium WebDriver
Run an end-to-end purchase test on the VLP Demo Store, discover why a fixed Thread.sleep makes it fail, replace it with an explicit wait, and review the screenshots captured at every step.
Virtual lab · Testing Tools · 40 min
Handle a Windows file-upload dialog with AutoIt
Run your first AutoIt script in SciTE, inspect the native “Open” dialog with AutoIt Window Info, write and compile upload.au3, and call the executable from a Selenium WebDriver test to upload a résumé.
Quick revision
- IDE records, RC is legacy, WebDriver drives browsers natively, Grid runs in parallel.
- Prefer id/name/CSS (Cascading Style Sheets) locators; use XPath when needed.
- Use explicit waits instead of
Thread.sleep. - Assert results and take screenshots as evidence.
- AutoIT automates Windows dialogs such as file upload.
Practise this topic
Hands-on virtual labs
Apply what you just read in a realistic, guided simulation. Free with a verified account.
Create a free account to track your progress and unlock virtual labs.