
We understand the role of Selenium WebDriver in automating web based tasks and testing functionality of web applications. We understand what WebDriver is and that all actions are performed within the context of a WebDriver.
Selenium has a great suite of additional tools to assist with web testing such as Selenium RC, Selenium IDE and Selenium Grid. We give a quick overview of these technologies and what they do.
We'll set up our a Selenium project in IntelliJ using the Maven template. Maven is an easy way to get the selenium dependencies in 1 simple step!
Our first hands on Selenium test. We'll load a webpage and check its title.
When you interact with a webpage, you do so by interacting with specific elements on the page. This example demonstrates how to find a specific element using its class name attribute.
Locate all anchor elements by tag name to gather every link on the page, then iterate to read their attributes in the order they appear.
Explore retrieving web element attributes in Selenium by locating elements with class name, using get text and get attribute methods, and accessing location and size for robust automated tests.
Retrieving data from a webtable teaches you to navigate the table hierarchy—table body, rows, and cells—by using find elements to collect cell text and print it row by row.
Explore locating elements with css selectors in selenium, using tag names and nested selectors to find and print text from elements, and understand descendant relationships for precise element targeting.
Learn to click at a specific location with Selenium by getting button locations and using the Actions class to move by offset and click between two buttons.
Locate radio button inputs with Selenium using XPath, verify type radio and value attributes, and toggle selection by clicking to test selecting and deselecting within a single form.
learn to automate multi-select actions in a web page with selenium by holding the control or command key to select multiple options in a select element and verify the results.
Use selenium actions to double click the message element to trigger a color change from blue to yellow, verifying the color with get CSS value before and after.
Learn to trigger a context menu by right-clicking a target button, open the menu, and select an option (for example edit) using selectors and actions in Selenium.
Explore how the WebDriver window interface controls the browser size, including maximizing, full screen, and setting dimensions, with practical Selenium examples.
Use explicit waits in Selenium to wait until a dropdown menu item becomes clickable before clicking it, employing WebDriverWait and the expected conditions class.
Switch between frames in a web page to access elements inside each frame by using the frame's id or name, then switch back to the main window to continue testing.
Switch to an iframe in Selenium by locating the frame element, storing the main window handle, and switching back after interacting with elements inside the frame.
Identify the main window, collect all window handles, switch to each non-main window, and close it to keep only the main window open.
Identify and interact with alert boxes using Selenium, including launching alerts, detecting with explicit waits, switching to the alert, and accepting or reading its text.
Explore how the Firefox driver connects selenium scripts to the Firefox browser via the web driver interface and the wire protocol, including gecko driver setup and Firefox profile customization.
Learn how to launch an Internet Explorer browser with Selenium on Windows, using the IE driver, by setting the driver executable path and downloading the proper 32/64-bit driver.
Learn to capture browser screenshots with selenium using the get screenshot interface, enabling debugging and result comparison across Chrome, Firefox, and IE by saving images to a specified local file.
Learn to capture a screenshot of a specific element in Selenium by writing a static function that crops the full page image to the element's size and location.
Understand how the observer pattern connects publishers and subscribers through events and callbacks to propagate state changes, such as temperature changes affecting an electricity bill.
Explore the observer pattern and Selenium event listeners to auto-create screenshots on click events by implementing before click and after click handlers with an event firing driver.
Selenium is a specialized, easy-to-use framework for automating interactions with web browsers, whether it’s to test the functionality of web apps that you’ve developed or to automate boring and repetitive tasks or to perform activities like scraping websites.
In this course, we’ll be working with Selenium’s Java API to test browser functionality and automate tasks using nearly 45 solved examples of use cases you might encounter on a regular basis. We’ll look at scenarios like
1) scraping websites for specific elements identified by HTML tags, CSS selectors
2) Testing User interactions of all kinds as click, entering text, drag and drop, selecting from dropdowns
3) Automating Browser Navigation and Handling cookies
4) Switching between your main browser window and pop-up alerts, embedded iframes
5) Interacting with HTML5 based elements like video players
6) and Parallelly running tests across multiple browsers and platforms from your local machine using Selenium Grid
Selenium makes automating all the tasks we’ve mentioned very straightforward but as your tasks get more and more sophisticated you’ll want to use best practices to structure your code. We’ll talk about the Page Object Model design pattern and how you can use it to design testing scripts that are easy to maintain.