Open topic with navigation

## Class By

java.lang.Object

org.openqa.selenium.By

com.hpe.leanft.selenium.By

Direct Known Subclasses:
  By.ByAttributes, By.ByRegClassName, By.ByRegId, By.ByRegLinkText, By.ByRegName, By.ByRegRole, By.ByRegTagName, By.ByRegText, By.ByRegType, By.ByStyles, By.ByText, By.ByVisible, ByAny

    public abstract class By
    extends org.openqa.selenium.By

Contains all LeanFT for Selenium By methods for locating elements.

## Nested Class Summary

Nested Classes

Modifier and Type | Class and Description
--- | ---
`static class` | `By.ByAttributes` A locator that locates elements by the provided attributes (strings or regular expressions).
`static class` | `By.ByRegClassName` A locator that locates elements by the provided regular expression class name parameter.
`static class` | `By.ByRegId` A locator that locates elements by the provided regular expression ID parameter.
`static class` | `By.ByRegLinkText` A locator that locates elements by the provided regular expression link text parameter.
`static class` | `By.ByRegName` A locator that locates elements by the provided regular expression name parameter.
`static class` | `By.ByRegRole` A locator that locates elements by the provided regular expression role parameter.
`static class` | `By.ByRegTagName` A locator that locates elements by the provided regular expression tag name parameter.
`static class` | `By.ByRegText` A locator that locates elements by the provided regular expression visible text parameter.
`static class` | `By.ByRegType` A locator that locates elements by the provided regular expression type parameter.
`static class` | `By.ByStyles` A locator that locates elements by the provided styles (string or regular expressions).
`static class` | `By.ByText` A locator that locates elements by the provided visible text.
`static class` | `By.ByVisible` A locator that locates elements that are either visible or not, depending on the parameter passed.
`static class` | `By.FLAGS`

Nested classes/interfaces inherited from class org.openqa.selenium.By

`org.openqa.selenium.By.ByClassName, org.openqa.selenium.By.ByCssSelector, org.openqa.selenium.By.ById, org.openqa.selenium.By.ByLinkText, org.openqa.selenium.By.ByName, org.openqa.selenium.By.ByPartialLinkText, org.openqa.selenium.By.ByTagName, org.openqa.selenium.By.ByXPath`

## Method Summary

All Methods

Modifier and Type | Method and Description
--- | ---
`static org.openqa.selenium.By` | `attribute(String name, Pattern value)` Returns a locator that locates elements according to a single attribute.
`static org.openqa.selenium.By` | `attribute(String name, String value)` Returns a locator that locates elements according to a single attribute.
`static org.openqa.selenium.By` | `attributes(Map<String,?> attributes)` Returns a locator that locates elements according to one or more attributes.
`static By` | `className(Pattern className)` Returns a locator that locates elements by the provided regular expression className parameter.
`static By` | `id(Pattern id)` Returns a locator that locates elements by the provided regular expression ID parameter.
`static By` | `linkText(Pattern linkText)` Returns a locator that locates elements by the provided regular expression linkText parameter.
`static By` | `name(Pattern name)` Returns a locator that locates elements by the provided regular expression name parameter.
`static By` | `role(Pattern role)` Returns a locator that locates elements by the provided regular expression role parameter.
`static By` | `role(String role)` Returns a locator that locates elements by the provided role parameter.
`static By` | `style(String name, Pattern value)` Returns a locator that locates elements according to a single style.
`static By` | `style(String name, String value)` Returns a locator that locates elements according to a single style.
`static By` | `styles(Map<String,?> styles)` Returns a locator that locates elements according to one or more styles.
`static By` | `tagName(Pattern tagName)` Returns a locator that locates elements by the provided regular expression tagName parameter.
`static By` | `type(Pattern type)` Returns a locator that locates elements by the provided regular expression type parameter.
`static By` | `type(String type)` Returns a locator that locates elements by the provided type parameter.
`static By` | `visible(boolean visible)` Returns a locator that locates elements that are either visible or not, depending on the parameter passed.
`static By` | `visibleText(Pattern visibleText)` Returns a locator that locates element by the provided regular expression visibleText parameter.
`static By` | `visibleText(String visibleText)` Returns a locator that locates elements by the provided visibleText parameter.
`static By` | `visibleText(String visibleText, By.FLAGS flags)` Returns a locator that locates elements by the provided regular expression visibleText that is case insensitive.

Methods inherited from class org.openqa.selenium.By

`className, cssSelector, equals, findElement, findElements, hashCode, id, linkText, name, partialLinkText, tagName, toString, xpath`

Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Method Detail

- name

      public static By name(Pattern name)

  Returns a locator that locates elements by the provided regular expression name parameter.
  Parameters:
    `name` - The name of the elements in the form of a regular expression.
  Returns:
    A locator that locates elements with the given name.

- id

      public static By id(Pattern id)

  Returns a locator that locates elements by the provided regular expression ID parameter.
  Parameters:
    `id` - The ID of the elements in the form of a regular expression.
  Returns:
    A locator that locates elements with the given ID.

- className

      public static By className(Pattern className)

  Returns a locator that locates elements by the provided regular expression className parameter.
  Parameters:
    `className` - The className of the elements in the form of a regular expression.
  Returns:
    A locator that locates elements with the given className.

- linkText

      public static By linkText(Pattern linkText)

  Returns a locator that locates elements by the provided regular expression linkText parameter.
  Parameters:
    `linkText` - The linkText of the elements in the form of a regular expression.
  Returns:
    A locator that locates elements with the given linkText.

- tagName

      public static By tagName(Pattern tagName)

  Returns a locator that locates elements by the provided regular expression tagName parameter.
  Parameters:
    `tagName` - The tagName of the elements in the form of a regular expression.
  Returns:
    A locator that locates elements with the given tagName.

- role

      public static By role(String role)

  Returns a locator that locates elements by the provided role parameter.
  Parameters:
    `role` - The role of the elements.
  Returns:
    A locator that locates elements with the given role.

- role

      public static By role(Pattern role)

  Returns a locator that locates elements by the provided regular expression role parameter.
  Parameters:
    `role` - The role of the elements in the form of a regular expression.
  Returns:
    A locator that locates elements with the given role.

- type

      public static By type(String type)

  Returns a locator that locates elements by the provided type parameter.
  Parameters:
    `type` - The type of the elements.
  Returns:
    A locator that locates elements with the given type.

- type

      public static By type(Pattern type)

  Returns a locator that locates elements by the provided regular expression type parameter.
  Parameters:
    `type` - The role of the elements in the form of a regular expression.
  Returns:
    A locator that locates elements with the given type.

- visibleText

      public static By visibleText(String visibleText)

  Returns a locator that locates elements by the provided visibleText parameter.
  Parameters:
    `visibleText` - The visible text of the elements.
  Returns:
    A locator that locates elements by the visible text.

- visibleText

      public static By visibleText(Pattern visibleText)

  Returns a locator that locates element by the provided regular expression visibleText parameter.
  Parameters:
    `visibleText` - The visible text of the elements in the form of a regular expression.
  Returns:
    A locator that locates elements by the visible text.

- visibleText

      public static By visibleText(String visibleText,
                                   By.FLAGS flags)

  Returns a locator that locates elements by the provided regular expression visibleText that is case insensitive.
  Parameters:
    `visibleText` - The visible text of the elements in the form of a regular expression.
    `flags` - The flag CASE_INSENSITIVE indicating that the visible text is case insensitive.
  Returns:
    A locator that locates elements by the visible text with the given flag.

- visible

      public static By visible(boolean visible)

  Returns a locator that locates elements that are either visible or not, depending on the parameter passed.
  Parameters:
    `visible` - Whether the elements are visible.
  Returns:
    A locator that locates elements that are either visible or not, depending on the parameter passed.

- styles

      public static By styles(Map<String,?> styles)

  Returns a locator that locates elements according to one or more styles. You can also use regular expressions.
  Parameters:
    `styles` - Dictionary of <key, value>.
  Returns:
    a locator that locates elements by their styles.

- style

      public static By style(String name,
                             String value)

  Returns a locator that locates elements according to a single style.
  Parameters:
    `name` - The name of the style.
    `value` - The value of the style.
  Returns:
    a locator that locates elements by a style.

- style

      public static By style(String name,
                             Pattern value)

  Returns a locator that locates elements according to a single style.
  Parameters:
    `name` - The name of the style.
    `value` - The Pattern of the style.
  Returns:
    a locator that locates elements by a style.

- attributes

      public static org.openqa.selenium.By attributes(Map<String,?> attributes)

  Returns a locator that locates elements according to one or more attributes. You can also use regular expressions.
  Parameters:
    `attributes` - Dictionary of <key, value>.
  Returns:
    a locator that locates elements by their attributes.

- attribute

      public static org.openqa.selenium.By attribute(String name,
                                                     String value)

  Returns a locator that locates elements according to a single attribute.
  Parameters:
    `name` - The name of the attribute.
    `value` - The value of the attribute.
  Returns:
    a locator that locates elements by an attribute.

- attribute

      public static org.openqa.selenium.By attribute(String name,
                                                     Pattern value)

  Returns a locator that locates elements according to a single attribute.
  Parameters:
    `name` - The name of the attribute.
    `value` - The Pattern of the attribute.
  Returns:
    a locator that locates elements by an attribute.