balin / com.github.epadronu.balin.core / Browser

Browser

interface Browser : JavaScriptSupport, WaitingSupport, WebDriver

Balin's backbone. The Browser interface binds together the different abstractions that form part of the library.

Additionally, this interface defines the entry point for the Domain-Specific Language which Balin is built around.

Inherited Properties

configurationSetup

abstract val configurationSetup: ConfigurationSetup

The configuration setup used to customized Balin's behavior.

driver

abstract val driver: WebDriver

The driver to be used when evaluating isTrue in waitFor.

js

abstract val js: JavaScriptExecutor

Allows the execution of synchronous and asynchronous JavaScript code if such functionality is supported by the underlying driver.

Functions

at

open fun <T : Page> at(factory: (Browser) -> T): T

Tells the browser at what page it should be located.

to

open fun <T : Page> to(factory: (Browser) -> T): T

Navigates to the given page.

open fun to(url: String): String

Navigates to the given URL.

Inherited Functions

waitFor

open fun <T> waitFor(timeOutInSeconds: Long = configurationSetup.waitForTimeOutTimeInSeconds, sleepInMillis: Long = configurationSetup.waitForSleepTimeInMilliseconds, isTrue: () -> ExpectedCondition<T>): T

Repeatedly applies the underlying driver to the given function until one of the following occurs:

Companion Object Functions

configure

fun configure(block: ConfigurationBuilder.() -> Unit): Unit

Domain-Specific language that let's you configure Balin's global behavior.

drive

fun drive(driverFactory: () -> WebDriver = desiredConfiguration.driverFactory, autoQuit: Boolean = desiredConfiguration.autoQuit, block: Browser.() -> Unit): Unit
fun drive(configuration: Configuration, block: Browser.() -> Unit): Unit

This method represents the entry point for the Domain-Specific Language which Balin is built around.

Extension Functions

$

fun SearchContext.$(selector: String, index: Int): WebElement

Find the nth element that can be located by the given CSS selector.

fun SearchContext.$(selector: String, range: IntRange): List<WebElement>

Find all the elements that can be located by the given CSS selector, restricted by the specified range.

fun SearchContext.$(selector: String, vararg indices: Int): List<WebElement>

Find all the elements that can be located by the given CSS selector, restricted by the specified indices. (If no index is provided, then all matching elements will be returned.)

find

fun SearchContext.find(selector: String, index: Int): WebElement

Find the nth element that can be located by the given CSS selector.

fun SearchContext.find(selector: String, range: IntRange): List<WebElement>

Find all the elements that can be located by the given CSS selector, restricted by the specified range.

fun SearchContext.find(selector: String, vararg indices: Int): List<WebElement>

Find all the elements that can be located by the given CSS selector, restricted by the specified indices. (If no index is provided, then all matching elements will be returned.)

withAlert

fun Browser.withAlert(alertContext: Alert.() -> Unit): Unit

Switches to the currently active modal dialog for this particular driver instance.

withFrame

fun Browser.withFrame(index: Int, iFrameContext: () -> Unit): Unit
fun <T : Page> Browser.withFrame(index: Int, iFrameContext: T.() -> Unit): Unit

Select a frame by its (zero-based) index and switch the driver's context to it.

fun Browser.withFrame(nameOrId: String, iFrameContext: () -> Unit): Unit
fun <T : Page> Browser.withFrame(nameOrId: String, iFrameContext: T.() -> Unit): Unit

Select a frame by its name or ID. Frames located by matching name attributes are always given precedence over those matched by ID.

fun Browser.withFrame(webElement: WebElement, iFrameContext: () -> Unit): Unit
fun <T : Page> Browser.withFrame(webElement: WebElement, iFrameContext: T.() -> Unit): Unit

Select a frame using its previously located WebElement.

withWindow

fun Browser.withWindow(nameOrHandle: String? = null, windowContext: WebDriver.() -> Unit): Unit

Switch the focus of future commands for this driver to the window with the given name/handle.