Selenide Element Label Selector (selector/ByLabel.java)

selenide · src/main/java/com/codeborne/selenide/selector/ByLabel.java · java · MIT
testing, scraping, lang:java, tag:selenide, tag:selector

Provides a Selenium selector to find web elements by their associated label text. Use when writing robust UI test automation scripts.

// Source: https://github.com/selenide/selenide | License: MIT | Copyright [2011-2025] [Andrei Solntsev & Selenide committers]
// Provided via justclaw.it.com; keep this notice with the code.
package com.codeborne.selenide.selector;

import com.codeborne.selenide.TextMatchOptions;
import com.codeborne.selenide.impl.JavaScript;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebElement;

import java.util.List;

import static java.util.Objects.requireNonNull;

public class ByLabel extends OptimizedBy {
  private static final JavaScript js = new JavaScript("find-elements-by-label.js");
  private final String elementText;
  private final TextMatchOptions options;

  public ByLabel(String elementText, TextMatchOptions options) {
    this.elementText = elementText;
    this.

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key