John Doe
QA Automation Engineer
Browser automation framework for web application testing
Selenium WebDriver is a web framework that allows you to execute cross-browser tests. It provides a programming interface to create and run test cases, giving you the ability to create robust, browser-based regression automation suites and tests.
// Maven dependency
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.8.0</version>
</dependency>
// Gradle dependency
implementation 'org.seleniumhq.selenium:selenium-java:4.8.0'
pip install selenium
// Download browser drivers from:
// Chrome: https://sites.google.com/chromium.org/driver/
// Firefox: https://github.com/mozilla/geckodriver/releases
// Edge: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
// Set system property for Java
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class FirstTest {
public static void main(String[] args) {
// Set the path to chromedriver
System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");
// Initialize browser
WebDriver driver = new ChromeDriver();
// Open Google
driver.get("https://www.google.com");
// Get and print title
System.out.println("Page title is: " + driver.getTitle());
// Close browser
driver.quit();
}
}
from selenium import webdriver
from selenium.webdriver.common.by import By
# Initialize Chrome driver
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
# Open Google
driver.get("https://www.google.com")
# Find search box and type query
search_box = driver.find_element(By.NAME, "q")
search_box.send_keys("Selenium WebDriver")
search_box.submit()
# Print title
print("Page title is:", driver.title)
# Close browser
driver.quit()
JavaScript testing framework
Cross-browser automation
Testing framework
Unit testing framework
Use explicit waits instead of thread.sleep()
Implement Page Object Model pattern
Keep tests independent and atomic
Use proper selectors (ID, CSS, XPath)
Implement proper test reporting