Class SingleBrowserPath
- java.lang.Object
-
- com.github.loyada.jdollarx.singlebrowser.SingleBrowserPath
-
-
Field Summary
Fields Modifier and Type Field Description static SingleBrowserPathanchorstatic SingleBrowserPathbodystatic SingleBrowserPathbuttonstatic SingleBrowserPathdivstatic SingleBrowserPathelementstatic SingleBrowserPathformstatic SingleBrowserPathheaderstatic SingleBrowserPathheader1static SingleBrowserPathheader2static SingleBrowserPathheader3static SingleBrowserPathheader4static SingleBrowserPathheader5static SingleBrowserPathheader6static SingleBrowserPathhtmlstatic SingleBrowserPathinputstatic SingleBrowserPathlistItemstatic SingleBrowserPathsectionstatic SingleBrowserPathspanstatic SingleBrowserPathsvgstatic SingleBrowserPathunorderedList
-
Constructor Summary
Constructors Constructor Description SingleBrowserPath(BasicPath path)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Pathafter(Path another)The element appears after the given pathPathafterSibling(Path another)The element is a sibling of the given path, and appears after itPathancestorOf(Path another)The element contains the given path, i.e.Pathand(ElementProperty... prop)Alias equivalent toPath.that(com.github.loyada.jdollarx.ElementProperty...).Pathbefore(Path another)The element appears before the given pathPathbeforeSibling(Path another)The element is a sibling of the given path, and appears before itPathchildOf(Path another)The element is a direct child of the given pathvoidclick()click at the location of this elementPathcontaining(Path another)The element contains the given path, i.e.Pathcontains(Path another)The element contains the given path, i.e.PathdescendantOf(Path another)The element is contained in the given path element, i.e.PathdescribedBy(String description)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".voiddoubleClick()doubleclick at the location of this elementOperations.DragAndDropdragAndDrop()drag and drop this element, to another element or another location.org.openqa.selenium.WebElementfind()Find the (first) element in the browser for this pathList<org.openqa.selenium.WebElement>findAll()Find all elements in the browser with this pathOptional<String>getAlternateXPath()Optional<String>getDescribedBy()List<ElementProperty>getElementProperties()Optional<org.openqa.selenium.WebElement>getUnderlyingSource()Optional<String>getXPath()The Optional xpath is maps to.Optional<String>getXpathExplanation()voidhover()hover over the element with this path in the browserPathimmediatelyAfterSibling(Path another)The sibling right before the element matches the given path parameterPathimmediatelyBeforeSibling(Path another)The sibling right after the element matches the given path parameterPathinside(Path another)Element that is inside another elementPathinsideTopLevel()Returns an element that is explicitly inside the document.Pathor(Path another)match more than a single path.PathparentOf(Path another)The element is a parent of the given pathvoidrightClick()right click at the location of this elementorg.openqa.selenium.WebElementscrollTo()scroll the browser until this element is visiblevoidsendKeys(CharSequence... charsToSend)send keys to elementPaththat(ElementProperty... prop)returns a path with the provided properties.StringtoString()PathwithClass(String cssClass)The element has the given class namePathwithClasses(String... cssClasses)The element has the given class namesPathwithGlobalIndex(Integer index)Return the nth occurrence of the element in the entire document.PathwithText(String txt)Element with text equals (ignoring case) to txt.PathwithTextContaining(String txt)The element has text, containing the given txt parameter.
-
-
-
Field Detail
-
element
public static final SingleBrowserPath element
-
div
public static final SingleBrowserPath div
-
span
public static final SingleBrowserPath span
-
listItem
public static final SingleBrowserPath listItem
-
button
public static final SingleBrowserPath button
-
unorderedList
public static final SingleBrowserPath unorderedList
-
input
public static final SingleBrowserPath input
-
anchor
public static final SingleBrowserPath anchor
-
form
public static final SingleBrowserPath form
-
html
public static final SingleBrowserPath html
-
body
public static final SingleBrowserPath body
-
header1
public static final SingleBrowserPath header1
-
header2
public static final SingleBrowserPath header2
-
header3
public static final SingleBrowserPath header3
-
header4
public static final SingleBrowserPath header4
-
header5
public static final SingleBrowserPath header5
-
header6
public static final SingleBrowserPath header6
-
header
public static final SingleBrowserPath header
-
svg
public static final SingleBrowserPath svg
-
section
public static final SingleBrowserPath section
-
-
Constructor Detail
-
SingleBrowserPath
public SingleBrowserPath(BasicPath path)
-
-
Method Detail
-
getUnderlyingSource
public Optional<org.openqa.selenium.WebElement> getUnderlyingSource()
- Specified by:
getUnderlyingSourcein interfacePath- Returns:
- The WebElement that is used as the underlying reference for the Path. In most cases, this Optional is empty.
-
getXpathExplanation
public Optional<String> getXpathExplanation()
- Specified by:
getXpathExplanationin interfacePath
-
getDescribedBy
public Optional<String> getDescribedBy()
- Specified by:
getDescribedByin interfacePath- Returns:
- optional readable functional description of the Path
-
getAlternateXPath
public Optional<String> getAlternateXPath()
- Specified by:
getAlternateXPathin interfacePath- Returns:
- Should not be used unless you are developing for DollarX.
-
getXPath
public Optional<String> getXPath()
Description copied from interface:PathThe 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.
-
getElementProperties
public List<ElementProperty> getElementProperties()
- Specified by:
getElementPropertiesin interfacePath- Returns:
- Should not be typically used, unless you are developing for DollarX
-
describedBy
public Path describedBy(String description)
Description copied from interface:PathA 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:
describedByin interfacePath- 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:PathReturns an element that is explicitly inside the document. This is usually not needed - it will be added implicitly when needed.- Specified by:
insideTopLevelin interfacePath- Returns:
- a new Path
-
or
public Path or(Path another)
Description copied from interface:Pathmatch more than a single path. Example: div.or(span) - matches both div and span
-
that
public Path that(ElementProperty... prop)
Description copied from interface:Pathreturns a path with the provided properties. For example: div.that(hasText("abc"), hasClass("foo"));
-
and
public Path and(ElementProperty... prop)
Description copied from interface:PathAlias equivalent toPath.that(com.github.loyada.jdollarx.ElementProperty...). Added for readability. Example:div.that(hasClass("a")).and(hasText("foo"));
-
inside
public Path inside(Path another)
Description copied from interface:PathElement that is inside another element
-
afterSibling
public Path afterSibling(Path another)
Description copied from interface:PathThe element is a sibling of the given path, and appears after it- Specified by:
afterSiblingin interfacePath- 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:PathThe sibling right before the element matches the given path parameter- Specified by:
immediatelyAfterSiblingin interfacePath- 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:PathThe element appears after the given path
-
beforeSibling
public Path beforeSibling(Path another)
Description copied from interface:PathThe element is a sibling of the given path, and appears before it- Specified by:
beforeSiblingin interfacePath- 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:PathThe sibling right after the element matches the given path parameter- Specified by:
immediatelyBeforeSiblingin interfacePath- 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:PathThe element appears before the given path
-
childOf
public Path childOf(Path another)
Description copied from interface:PathThe element is a direct child of the given path
-
parentOf
public Path parentOf(Path another)
Description copied from interface:PathThe element is a parent of the given path
-
containing
public Path containing(Path another)
Description copied from interface:PathThe element contains the given path, i.e. the given path parameter is inside the element- Specified by:
containingin interfacePath- 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:PathThe element contains the given path, i.e. the given path parameter is inside the element
-
ancestorOf
public Path ancestorOf(Path another)
Description copied from interface:PathThe element contains the given path, i.e. the given path parameter is inside the element- Specified by:
ancestorOfin interfacePath- 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:PathThe element is contained in the given path element, i.e. the given path parameter is wrapping it- Specified by:
descendantOfin interfacePath- 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:PathReturn 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:
withGlobalIndexin interfacePath- Parameters:
index- the number of occurrence- Returns:
- a new Path with the added constraint
-
withClass
public Path withClass(String cssClass)
Description copied from interface:PathThe element has the given class name
-
withClasses
public Path withClasses(String... cssClasses)
Description copied from interface:PathThe element has the given class names- Specified by:
withClassesin interfacePath- Parameters:
cssClasses- the class names- Returns:
- a new Path with the added constraint
-
withText
public Path withText(String txt)
Description copied from interface:PathElement with text equals (ignoring case) to txt. Equivalent topath.that(hasText(txt))
-
withTextContaining
public Path withTextContaining(String txt)
Description copied from interface:PathThe element has text, containing the given txt parameter. The match is case insensitive.- Specified by:
withTextContainingin interfacePath- 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.
-
sendKeys
public void sendKeys(CharSequence... charsToSend) throws Operations.OperationFailedException
send keys to element- Parameters:
charsToSend- the keys to send. Examples:input.sendKeys("abc"); input.sendKeys("a", "bc");- Throws:
Operations.OperationFailedException- - operation failed. Includes root cause.
-
-