Welcome to BhauAutomation!
Want to learn automation testing? Let’s start with Selenium WebDriver using simple English and practical Java examples.
What Is Selenium WebDriver?
Selenium WebDriver is a free, open-source tool that helps automate web browsers.
For example, instead of manually entering login details and clicking buttons, Selenium can perform these actions using code.
Why Do We Use Selenium?
-
Automate repetitive testing tasks.
-
Save time and effort.
-
Test websites on supported browsers.
-
Work with Java, Python, and other languages.
-
Integrate with testing frameworks like TestNG.
Tools You Need
-
Java JDK
-
Eclipse or IntelliJ IDEA
-
Selenium WebDriver
-
Google Chrome
-
Maven (for managing dependencies)
Your First Selenium Program
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class FirstTest {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("https://example.com");
System.out.println(driver.getTitle());
driver.quit();
}
}
Output:
Example Domain
This program opens a website, prints its title, and closes the browser. Add Selenium to your project before running it.
What Are Selenium Locators?
Locators help Selenium find elements on a webpage.
Common locators include:
-
ID
-
Name
-
Class Name
-
CSS Selector
-
XPath
Example:
driver.findElement(By.id("username"))
.sendKeys("testuser");
This code enters testuser into the username field.
What Should You Learn Next?
-
Browser commands
-
Locators and XPath
-
Waits and alerts
-
Dropdowns and frames
-
TestNG and assertions
-
Automation framework development
Frequently Asked Questions
Is Selenium free? Yes, Selenium is open-source.
Is Java compulsory? No. Selenium supports multiple programming languages.
Can beginners learn Selenium? Yes! Start with basic Java and practise simple automation programs.
Conclusion
Selenium WebDriver makes website testing easier by automating browser actions. Practise regularly, build small projects, and gradually develop your automation skills.
Keep Learning with BhauAutomation!
Explore more tutorials on Java, Selenium, API Testing, and Automation Testing Interview Questions.