balin / com.github.epadronu.balin.core / JavaScriptExecutor / set

set

open operator fun set(name: String, value: Any?): Unit

Set the value of a global-JavaScript variable.

Browser.drive(driverFactory = driverFactory) {
    // When I navigate to the Kotlin's page URL
    to("https://kotlinlang.org/")

    // And I set a global variable
    js["myGlobal"] = "super global variable"

    // And I retrieve such global variable via a `get` call
    val globalVariableValue = js["myGlobal"]

    // Then I should get the variable's value as is
    assertEquals(globalVariableValue, "super global variable")
}

Parameters

name - the name of the variable.

value - the value of the variable. (It can be null.)