InBrowser¶
-
public class
InBrowser
¶ A wrapper around Selenium WebDriver, used for interaction with the browser. In case only a single instance of the browser is used,
com.github.loyada.jdollarx.singlebrowser.InBrowserSinglton
offers a simpler API.
Constructors¶
Methods¶
clickAt¶
clickOn¶
contextClick¶
doubleClickOn¶
dragAndDrop¶
-
public Operations.DragAndDrop
dragAndDrop
(Path path)¶ Drag and drop in the browser. Several flavors of use: browser.dragAndDrop(source).to(target); browser.dragAndDrop(source).to(xCor, yCor);
Parameters: - path – the source element
Returns: a DragAndDrop instance, that allows to drag and drop to a location or to another DOM element
find¶
-
public WebElement
find
(Path el)¶ Finds an element in the browser, based on the xpath representing el. It is similar to WebDriver.findElement(), If el also has a WebElement (ie: getUnderlyingSource() is not empty), then it looks inside that WebElement. This is useful also to integrate with existing WebDriver code.
Parameters: - el –
- the path to find
Returns: - A WebElement instance from selenium, or throws NoSuchElementException exception
- el –
findAll¶
-
public List<WebElement>
findAll
(Path el)¶ Finds all elements in the browser, based on the xpath representing el. It is similar to WebDriver.findElements(), If el also has a WebElement (ie: getUnderlyingSource() is not empty), then it looks inside that WebElement. This is useful also to integrate with existing WebDriver code.
Parameters: - el –
- the path to find
Returns: - A list of WebElement from selenium, or throws NoSuchElementException exception
- el –
findPageWithNumberOfOccurrences¶
-
public WebElement
findPageWithNumberOfOccurrences
(Path el, int numberOfOccurrences, RelationOperator relationOperator)¶ Don’t use this directly. There are better ways to do equivalent operation.
Parameters: - el – the path to find
- numberOfOccurrences – the base number to find
- relationOperator – whether we look for exactly the numberOfOccurrences, at least, or at most occurrences
Returns: the first WebElement found
findPageWithout¶
getCssClasses¶
getSelect¶
-
public Select
getSelect
(Path el)¶ Get a Selenium select element, which provides a high level API to interacting with a “select” menu. Since the Selenium API is good enough, there was no need to create a specialized dollarx version.
Parameters: - el –
- must be a “select” path, with “option” elements for the various selectable options.
Returns: org.openqa.selenium.support.ui.Select instance
- el –
hoverOver¶
isDisplayed¶
-
public boolean
isDisplayed
(Path el)¶ is the element present and displayed? Typically you should not use this method directly. Instead, use CustomMatchers. Also, this is limited to checking the inlined css style, so it is quite limited.
Parameters: - el – the element
Returns: true if it is present and selected
isEnabled¶
isNotPresent¶
isPresent¶
isSelected¶
numberOfAppearances¶
-
public Integer
numberOfAppearances
(Path el)¶ Returns the number of elements in the browser that match the given path. Typically you should not use this method directly. Instead, use CustomMatchers.
Parameters: - el – the element to find
Returns: the number of elements in the browser that match the given path
pressKeyDown¶
-
public Operations.KeysDown
pressKeyDown
(CharSequence thekey)¶ Press key down in the browser, or on a specific element. Two flavors of use: browser.pressKeyDown(Keys.TAB).inBrowser(); browser.pressKeyDown(Keys.TAB).on(path);
Parameters: - thekey – a key to press
Returns: returns a KeysDown instance that allows to press a key on the browser in general or on a specific DOM element
releaseKey¶
-
public Operations.ReleaseKey
releaseKey
(CharSequence thekey)¶ Release key down in the browser, or on a specific element. Two flavors of use:
browser.releaseKey(Keys.TAB).inBrowser(); browser.releaseKey(Keys.TAB).on(path);
Parameters: - thekey – a key to release
Returns: returns a ReleaseKey instance that allows to release on the browser in general or on a specific DOM element
rightClick¶
scroll¶
-
public Operations.Scroll
scroll
()¶ scroll the browser. Several flavors of use:
browser.scroll().to(path); browser.scroll().left(50); browser.scroll().right(50); browser.scroll().up(50); browser.scroll().down(50);
Returns: a Scroll instance that allows to scroll by offset or to a location of a DOM element
scrollElement¶
-
public Operations.ScrollElement
scrollElement
(Path wrapper)¶
scrollElementWithStepOverride¶
-
public Operations.ScrollElement
scrollElementWithStepOverride
(Path wrapper, int step)¶
scrollTo¶
sendKeys¶
-
public Operations.KeysSender
sendKeys
(CharSequence... charsToSend)¶ send keys to the browser, or to a specific element. Two flavors of use: browser.sendKeys(“abc”).toBrowser(); browser.sendKeys(“abc”).to(path);
Parameters: - charsToSend – The characters to send. Can be “abc” or “a”, “b”, “c”
Returns: a KeySender instance that allows to send keys to the browser in general, or to a specific DOM element