Class ByFactory


  • public class ByFactory
    extends Object
    More factories for By objects.

    To make the code flow, instantiate this object in the variable named "by"

    Mainly from Capybara's "selector.rb". To obtain the actual evaluation, I run "bundle exec irb" from selenium-tests, then "require 'xpath'", and just evaluate XPath::HTML.radio_button("XXX").

    Author:
    Kohsuke Kawaguchi
    See Also:
    CapybaraPortingLayer.by
    • Constructor Detail

      • ByFactory

        public ByFactory()
    • Method Detail

      • xpath

        public org.openqa.selenium.By xpath​(String xpath)
      • xpath

        public org.openqa.selenium.By xpath​(String format,
                                            Object... args)
        Construct XPath inserting placeholders using String.format.
        Parameters:
        format - Format specifier for xpath. Only string placeholders are supported - do not put quotes around them.
      • path

        public org.openqa.selenium.By path​(String path,
                                           Object... args)
        Returns the "path" selector that finds an element by following the form-element-path plugin.

        form-element-path-plugin

      • url

        public org.openqa.selenium.By url​(String path,
                                          Object... args)
      • action

        public org.openqa.selenium.By action​(String path,
                                             Object... args)
      • name

        public org.openqa.selenium.By name​(String name,
                                           Object... args)
      • link

        public org.openqa.selenium.By link​(String locator)
        Capybara's :link selector.
        Parameters:
        locator - Text, id, title, or image alt attribute of the link
      • href

        public org.openqa.selenium.By href​(String locator)
        Link href selector.
        Parameters:
        locator - href of the link
      • checkbox

        public org.openqa.selenium.By checkbox​(String locator)
        Finds checkbox.
        Parameters:
        locator - Text
      • radioButton

        public org.openqa.selenium.By radioButton​(String locator)
        Select radio button by its label text.
      • input

        public org.openqa.selenium.By input​(String locator)
        Finds input fields.
        Parameters:
        locator - Text, id, title.
      • button

        public org.openqa.selenium.By button​(String locator)
        Finds a button
      • css

        public org.openqa.selenium.By css​(String css,
                                          Object... args)
      • tagName

        public org.openqa.selenium.By tagName​(String name)
      • option

        public org.openqa.selenium.By option​(String name)
      • id

        public org.openqa.selenium.By id​(String s)
      • parent

        public org.openqa.selenium.By parent()
      • ancestor

        public org.openqa.selenium.By ancestor​(String tagName)
      • areaPath

        public org.openqa.selenium.By areaPath​(String pathPrefix)
        "/foo/bar" matches div elements with path attribute "/foo/bar" or "/foo/bar[n]". Does not match "/foo/bar/baz" or "/foo/bar[1]/baz".
      • partialLinkText

        public org.openqa.selenium.By partialLinkText​(String linkText)
        Parameters:
        linkText - The text to match against
        Returns:
        a By which locates A elements that contain the given link text