or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

events.mdindex.mdpagefactory.mdutilities.mdwaiting.md
tile.json

tessl/maven-org-seleniumhq-selenium--selenium-support

Selenium WebDriver support utilities providing Page Object Model, waiting mechanisms, event handling, and UI utilities for robust test automation

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.seleniumhq.selenium/selenium-support@3.141.x

To install, run

npx @tessl/cli install tessl/maven-org-seleniumhq-selenium--selenium-support@3.141.0

index.mddocs/

Selenium Support

Selenium Support is a comprehensive Java utility library that extends the core Selenium WebDriver functionality with higher-level abstractions and convenience utilities. It provides essential support classes including the Page Object Model pattern implementation, robust waiting mechanisms, event-driven programming support, and UI utilities that significantly reduce boilerplate code and improve test maintainability.

Package Information

  • Package Name: selenium-support
  • Package Type: Maven
  • Language: Java
  • Maven Coordinates: org.seleniumhq.selenium:selenium-support:3.141.59
  • Installation: Add to your pom.xml:
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-support</artifactId>
    <version>3.141.59</version>
</dependency>

Core Imports

import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ThreadGuard;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.LoadableComponent;
import org.openqa.selenium.support.events.EventFiringWebDriver;

Basic Usage

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;

// Page Object Model example
public class LoginPage {
    @FindBy(id = "username")
    private WebElement usernameField;
    
    @FindBy(id = "password") 
    private WebElement passwordField;
    
    @FindBy(id = "submit")
    private WebElement submitButton;
    
    public LoginPage(WebDriver driver) {
        PageFactory.initElements(driver, this);
    }
    
    public void login(String username, String password) {
        usernameField.sendKeys(username);
        passwordField.sendKeys(password);
        submitButton.click();
    }
}

// Usage with waits and utilities
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, 10);

// Initialize page object
LoginPage loginPage = new LoginPage(driver);

// Wait for element and interact
WebElement dropdown = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("country")));
Select select = new Select(dropdown);
select.selectByVisibleText("United States");

Architecture

The selenium-support library is organized into several key packages:

  • Core Support (org.openqa.selenium.support): Page Object annotations, utilities, and basic locators
  • Page Factory (org.openqa.selenium.support.pagefactory): Element locators, decorators, and Page Object infrastructure
  • UI Utilities (org.openqa.selenium.support.ui): Waiting mechanisms, dropdown helpers, and expected conditions
  • Events (org.openqa.selenium.support.events): Event-driven WebDriver wrappers and listener interfaces

Capabilities

Page Object Model Support

Provides annotations and factory methods for implementing the Page Object Model pattern with automatic element initialization and flexible locator strategies.

public class PageFactory {
    public static <T> T initElements(WebDriver driver, Class<T> pageClassToProxy);
    public static void initElements(WebDriver driver, Object page);
    public static void initElements(ElementLocatorFactory factory, Object page);
    public static void initElements(FieldDecorator decorator, Object page);
}

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
public @interface FindBy {
    How how() default How.UNSET;
    String using() default "";
    String id() default "";
    String name() default "";
    String className() default "";
    String css() default "";
    String tagName() default "";
    String linkText() default "";
    String partialLinkText() default "";
    String xpath() default "";
}

Page Object Factory

Robust Waiting Mechanisms

Comprehensive waiting utilities for handling dynamic web content with configurable timeouts, polling intervals, and expected conditions.

public class WebDriverWait extends FluentWait<WebDriver> {
    public WebDriverWait(WebDriver driver, long timeOutInSeconds);
    public WebDriverWait(WebDriver driver, long timeOutInSeconds, long sleepInMillis);
}

public class FluentWait<T> implements Wait<T> {
    public FluentWait<T> withTimeout(Duration timeout);
    public FluentWait<T> pollingEvery(Duration interval);
    public FluentWait<T> ignoring(Class<? extends Throwable> exceptionType);
    public <V> V until(Function<? super T, V> isTrue);
}

public class ExpectedConditions {
    public static ExpectedCondition<WebElement> presenceOfElementLocated(By locator);
    public static ExpectedCondition<WebElement> visibilityOfElementLocated(By locator);
    public static ExpectedCondition<WebElement> elementToBeClickable(By locator);
    public static ExpectedCondition<Boolean> titleIs(String title);
}

Waiting and Expected Conditions

Event-Driven WebDriver

Event firing capabilities for monitoring and logging WebDriver actions with customizable listener interfaces.

public class EventFiringWebDriver implements WebDriver {
    public EventFiringWebDriver(WebDriver driver);
    public EventFiringWebDriver register(WebDriverEventListener eventListener);
    public EventFiringWebDriver unregister(WebDriverEventListener eventListener);
}

public interface WebDriverEventListener {
    void beforeNavigateTo(String url, WebDriver driver);
    void afterNavigateTo(String url, WebDriver driver);
    void beforeClickOn(WebElement element, WebDriver driver);
    void afterClickOn(WebElement element, WebDriver driver);
    void onException(Throwable throwable, WebDriver driver);
}

Event Handling

UI Utilities and Helpers

Specialized utilities for common web interactions including dropdown selections, color handling, thread safety, component loading, and element locating strategies.

public class Select implements ISelect {
    public Select(WebElement element);
    public void selectByVisibleText(String text);
    public void selectByIndex(int index);
    public void selectByValue(String value);
    public List<WebElement> getOptions();
    public boolean isMultiple();
}

public class ThreadGuard {
    public static WebDriver protect(WebDriver actualWebDriver);
}

public abstract class LoadableComponent<T extends LoadableComponent<T>> {
    public T get();
    protected abstract void isLoaded() throws Error;
    protected abstract void load();
}

public class Color {
    public Color(int red, int green, int blue, double alpha);
    public static Color fromString(String value);
    public String asRgb();
    public String asHex();
}

public class ByIdOrName extends By {
    public ByIdOrName(String idOrName);
}

Utilities and Helpers

Types

public interface Wait<F> {
    <T> T until(Function<? super F, T> isTrue);
}

public interface ExpectedCondition<T> extends Function<WebDriver, T> {
}

public enum How {
    CLASS_NAME, CSS, ID, ID_OR_NAME, LINK_TEXT, NAME, PARTIAL_LINK_TEXT, TAG_NAME, XPATH, UNSET;
    public abstract By buildBy(String value);
}

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface CacheLookup {
}

public interface ISelect {
    boolean isMultiple();
    List<WebElement> getOptions();
    List<WebElement> getAllSelectedOptions();
    WebElement getFirstSelectedOption();
    void selectByVisibleText(String text);
    void selectByIndex(int index);
    void selectByValue(String value);
}