Class SingleBrowserPath

  • All Implemented Interfaces:
    Path

    public final class SingleBrowserPath
    extends Object
    implements Path
    An implementation of Path that is tailored to a singleton browser, thus allows some additional API's for actions (for those who favor object-oriented API style)
    • Constructor Detail

      • SingleBrowserPath

        public SingleBrowserPath​(BasicPath path)
    • Method Detail

      • getUnderlyingSource

        public Optional<org.openqa.selenium.WebElement> getUnderlyingSource()
        Specified by:
        getUnderlyingSource in interface Path
        Returns:
        The WebElement that is used as the underlying reference for the Path. In most cases, this Optional is empty.
      • getDescribedBy

        public Optional<String> getDescribedBy()
        Specified by:
        getDescribedBy in interface Path
        Returns:
        optional readable functional description of the Path
      • getAlternateXPath

        public Optional<String> getAlternateXPath()
        Specified by:
        getAlternateXPath in interface Path
        Returns:
        Should not be used unless you are developing for DollarX.
      • getXPath

        public Optional<String> getXPath()
        Description copied from interface: Path
        The Optional xpath is maps to. Note that the prefix that marks it is inside the document (for example; "//" as the prefix of the xpath) can be omitted. This is not a concern - it will be added automatically by DollarX when interacting with the browser.
        Specified by:
        getXPath in interface Path
        Returns:
        an optional containing the xpath this Path is mapped to. The optional is empty only in case it is used as a wrapper of a WebElement (not the typical case).
      • describedBy

        public Path describedBy​(String description)
        Description copied from interface: Path
        A useful method to give a readable description to the path, for example: Suppose that instead of describing it's DOM positions and attributes, you prefer to describe it as "search result". Then you'd call: searchResult = myElement.describedBy("search result"); Now, calling System.out.println(firstOccurrenceOf(searchResult)), will print: "first occurrence of search result" This will replace its toString() result.
        Specified by:
        describedBy in interface Path
        Parameters:
        description - a readable description to that expresses the functionality of the path
        Returns:
        a new Path similar to the old one but that is described by the given description
      • insideTopLevel

        public Path insideTopLevel()
        Description copied from interface: Path
        Returns an element that is explicitly inside the document. This is usually not needed - it will be added implicitly when needed.
        Specified by:
        insideTopLevel in interface Path
        Returns:
        a new Path
      • or

        public Path or​(Path another)
        Description copied from interface: Path
        match more than a single path. Example: div.or(span) - matches both div and span
        Specified by:
        or in interface Path
        Parameters:
        another - the alternative path to match
        Returns:
        returns a new path that matches both the original one and the given parameter
      • that

        public Path that​(ElementProperty... prop)
        Description copied from interface: Path
        returns a path with the provided properties. For example: div.that(hasText("abc"), hasClass("foo"));
        Specified by:
        that in interface Path
        Parameters:
        prop - - one or more properties. See ElementProperties documentation for details
        Returns:
        a new path with the added constraints
      • inside

        public Path inside​(Path another)
        Description copied from interface: Path
        Element that is inside another element
        Specified by:
        inside in interface Path
        Parameters:
        another - - the containing element
        Returns:
        a new Path with the added constraint
      • afterSibling

        public Path afterSibling​(Path another)
        Description copied from interface: Path
        The element is a sibling of the given path, and appears after it
        Specified by:
        afterSibling in interface Path
        Parameters:
        another - - the sibling element that appears before
        Returns:
        a new Path with the added constraint
      • immediatelyAfterSibling

        public Path immediatelyAfterSibling​(Path another)
        Description copied from interface: Path
        The sibling right before the element matches the given path parameter
        Specified by:
        immediatelyAfterSibling in interface Path
        Parameters:
        another - - the sibling element that appears after
        Returns:
        a new path with the added constraint
      • after

        public Path after​(Path another)
        Description copied from interface: Path
        The element appears after the given path
        Specified by:
        after in interface Path
        Parameters:
        another - - the element that appear before
        Returns:
        a new Path with the added constraint
      • beforeSibling

        public Path beforeSibling​(Path another)
        Description copied from interface: Path
        The element is a sibling of the given path, and appears before it
        Specified by:
        beforeSibling in interface Path
        Parameters:
        another - - the sibling element that appears after
        Returns:
        a new Path with the added constraint
      • immediatelyBeforeSibling

        public Path immediatelyBeforeSibling​(Path another)
        Description copied from interface: Path
        The sibling right after the element matches the given path parameter
        Specified by:
        immediatelyBeforeSibling in interface Path
        Parameters:
        another - - the sibling element that appears after
        Returns:
        a new path with the added constraint
      • before

        public Path before​(Path another)
        Description copied from interface: Path
        The element appears before the given path
        Specified by:
        before in interface Path
        Parameters:
        another - - the element that appear after
        Returns:
        a new Path with the added constraint
      • childOf

        public Path childOf​(Path another)
        Description copied from interface: Path
        The element is a direct child of the given path
        Specified by:
        childOf in interface Path
        Parameters:
        another - - the parent element
        Returns:
        a new Path with the added constraint
      • parentOf

        public Path parentOf​(Path another)
        Description copied from interface: Path
        The element is a parent of the given path
        Specified by:
        parentOf in interface Path
        Parameters:
        another - - the child element
        Returns:
        a new Path with the added constraint
      • containing

        public Path containing​(Path another)
        Description copied from interface: Path
        The element contains the given path, i.e. the given path parameter is inside the element
        Specified by:
        containing in interface Path
        Parameters:
        another - - the element that is inside our element
        Returns:
        a new Path with the added constraint
      • contains

        public Path contains​(Path another)
        Description copied from interface: Path
        The element contains the given path, i.e. the given path parameter is inside the element
        Specified by:
        contains in interface Path
        Parameters:
        another - - the element that is inside our element
        Returns:
        a new Path with the added constraint
      • ancestorOf

        public Path ancestorOf​(Path another)
        Description copied from interface: Path
        The element contains the given path, i.e. the given path parameter is inside the element
        Specified by:
        ancestorOf in interface Path
        Parameters:
        another - - the element that is inside our element
        Returns:
        a new Path with the added constraint
      • descendantOf

        public Path descendantOf​(Path another)
        Description copied from interface: Path
        The element is contained in the given path element, i.e. the given path parameter is wrapping it
        Specified by:
        descendantOf in interface Path
        Parameters:
        another - - the element that is wrapping our element
        Returns:
        a new Path with the added constraint
      • withGlobalIndex

        public Path withGlobalIndex​(Integer index)
        Description copied from interface: Path
        Return the nth occurrence of the element in the entire document. Count starts at 1. The following expressions are equivalent: occurrenceNumber(4).of(myElement)); myElement.withGlobalIndex(4); Return the nth occurrence of the element in the entire document. Count starts at 1. For example: occurrenceNumber(3).of(listItem)
        Specified by:
        withGlobalIndex in interface Path
        Parameters:
        index - the number of occurrence
        Returns:
        a new Path with the added constraint
      • withClass

        public Path withClass​(String cssClass)
        Description copied from interface: Path
        The element has the given class name
        Specified by:
        withClass in interface Path
        Parameters:
        cssClass - the class name
        Returns:
        a new Path with the added constraint
      • withClasses

        public Path withClasses​(String... cssClasses)
        Description copied from interface: Path
        The element has the given class names
        Specified by:
        withClasses in interface Path
        Parameters:
        cssClasses - the class names
        Returns:
        a new Path with the added constraint
      • withText

        public Path withText​(String txt)
        Description copied from interface: Path
        Element with text equals (ignoring case) to txt. Equivalent to path.that(hasText(txt))
        Specified by:
        withText in interface Path
        Parameters:
        txt - - the text to equal to, ignoring case
        Returns:
        a new Path with the added constraint
      • withTextContaining

        public Path withTextContaining​(String txt)
        Description copied from interface: Path
        The element has text, containing the given txt parameter. The match is case insensitive.
        Specified by:
        withTextContaining in interface Path
        Parameters:
        txt - the text to match to
        Returns:
        a new Path with the added constraint
      • find

        public org.openqa.selenium.WebElement find()
        Find the (first) element in the browser for this path
        Returns:
        the WebElement
      • findAll

        public List<org.openqa.selenium.WebElement> findAll()
        Find all elements in the browser with this path
        Returns:
        a list of all WebElements with this path
      • scrollTo

        public org.openqa.selenium.WebElement scrollTo()
        scroll the browser until this element is visible
        Returns:
        the WebElement that was scrolled to
      • hover

        public void hover()
        hover over the element with this path in the browser
      • rightClick

        public void rightClick()
        right click at the location of this element
      • click

        public void click()
        click at the location of this element
      • doubleClick

        public void doubleClick()
        doubleclick at the location of this element
      • dragAndDrop

        public Operations.DragAndDrop dragAndDrop()
        drag and drop this element, to another element or another location. Examples:
         
            element.dragAndDrop().to(anotherElement);
            element.dragAndDrop().to(50, 50);
         
         
        Returns:
        DragAndDrop instance. See examples for usage.