How to use setup method of com.github.epadronu.balin.config.ConfigurationBuilder class

Best Balin code snippet using com.github.epadronu.balin.config.ConfigurationBuilder.setup

Browser.kt

Source:Browser.kt Github

copy

Full Screen

...46 private val configurationBuilder: ConfigurationBuilder by ThreadLocalDelegate {47 ConfigurationBuilder()48 }49 /**50 * The name of the property that dictates which setup to use.51 */52 internal const val BALIN_SETUP_NAME_PROPERTY: String = "balin.setup.name"53 /**54 * Retrieves the configuration generated by the builder, taking in55 * account the value of the [BALIN_SETUP_NAME_PROPERTY] property.56 */57 internal val desiredConfiguration: ConfigurationSetup58 get() = configurationBuilder.build().run {59 setups[System.getProperty(BALIN_SETUP_NAME_PROPERTY) ?: "default"] ?: this60 }61 /**62 * Domain-Specific language that let's you configure Balin's global63 * behavior.64 *65 * @sample com.github.epadronu.balin.config.ConfigurationTests.call_the_configure_method_and_make_changes66 *67 * @param block here you can interact with the DSL.68 */69 fun configure(block: ConfigurationBuilder.() -> Unit) {70 block(configurationBuilder)71 }72 /**73 * This method represents the entry point for the Domain-Specific74 * Language which Balin is built around.75 *76 * `drive` is the main abstraction layer for Selenium-WebDriver. Inside77 * the [block] it receives as parameter, you can interact with the78 * driver and use all the features Balin has to offer.79 *80 * @sample com.github.epadronu.balin.core.BrowserTests.perform_a_simple_web_navigation81 *82 * @param driverFactory provides the driver on which the navigation and interactions will be performed.83 * @param autoQuit indicates if the driver should quit at the end of the [block].84 * @param block here you interact with the driver alongside of Balin's assistance.85 */86 fun drive(87 driverFactory: () -> WebDriver = desiredConfiguration.driverFactory,88 autoQuit: Boolean = desiredConfiguration.autoQuit,89 block: Browser.() -> Unit) = drive(Configuration(autoQuit, driverFactory), block)90 /**91 * This method represents the entry point for the Domain-Specific92 * Language which Balin is built around.93 *94 * `drive` is the main abstraction layer for Selenium-WebDriver. Inside95 * the [block] it receives as parameter, you can interact with the96 * driver and use all the features Balin has to offer.97 *98 * @sample com.github.epadronu.balin.core.BrowserTests.perform_a_simple_web_navigation99 *100 * @param configuration defines Balin's local behavior for [block] only.101 * @param block here you interact with the driver alongside of Balin's assistance.102 */103 fun drive(configuration: Configuration, block: Browser.() -> Unit) {104 val desiredConfiguration = configuration.run {105 setups[System.getProperty(BALIN_SETUP_NAME_PROPERTY) ?: "default"] ?: this106 }107 BrowserImpl(desiredConfiguration).apply {108 try {109 block()110 } catch (throwable: Throwable) {111 throw throwable112 } finally {113 if (configurationSetup.autoQuit) {114 quit()115 }116 }117 }118 }119 }...

Full Screen

Full Screen

ConfigurationTests.kt

Source:ConfigurationTests.kt Github

copy

Full Screen

...36 fun cleanup() {37 Browser.configure {38 autoQuit = ConfigurationSetup.Default.autoQuit39 driverFactory = ConfigurationSetup.Default.driverFactory40 setups = mapOf()41 }42 System.clearProperty(Browser.BALIN_SETUP_NAME_PROPERTY)43 }44 @Test45 fun `Use the default configuration`() {46 Assert.assertEquals(Browser.desiredConfiguration, ConfigurationSetup.Default)47 }48 @Test49 fun `Call the configure method but don't modify a thing`() {50 Browser.configure { }51 Assert.assertEquals(Browser.desiredConfiguration, ConfigurationSetup.Default)52 }53 @Test(description = "Call the configure method and make changes",54 dataProvider = "JavaScript-incapable WebDriver factory")55 fun call_the_configure_method_and_make_changes(testFactory: () -> WebDriver) {56 val desiredConfigurationSetup = Configuration(false, testFactory)57 Browser.configure {58 autoQuit = desiredConfigurationSetup.autoQuit59 driverFactory = desiredConfigurationSetup.driverFactory60 }61 Assert.assertEquals(Browser.desiredConfiguration, desiredConfigurationSetup)62 }63 @Test(dataProvider = "JavaScript-incapable WebDriver factory")64 fun `Call the configure method with a default setup and use it implicitly`(testFactory: () -> WebDriver) {65 val defaultConfigurationSetup: ConfigurationSetup = Configuration(false, testFactory)66 Browser.configure {67 setups = mapOf(68 "default" to setup {69 autoQuit = defaultConfigurationSetup.autoQuit70 driverFactory = defaultConfigurationSetup.driverFactory71 }72 )73 }74 Assert.assertEquals(Browser.desiredConfiguration, defaultConfigurationSetup)75 }76 @Test(dataProvider = "JavaScript-incapable WebDriver factory")77 fun `Call the configure method with a default setup and use it explicitly`(testFactory: () -> WebDriver) {78 val defaultConfigurationSetup: ConfigurationSetup = Configuration(false, testFactory)79 Browser.configure {80 setups = mapOf(81 "default" to setup {82 autoQuit = defaultConfigurationSetup.autoQuit83 driverFactory = defaultConfigurationSetup.driverFactory84 }85 )86 }87 System.setProperty(Browser.BALIN_SETUP_NAME_PROPERTY, "default")88 Assert.assertEquals(Browser.desiredConfiguration, defaultConfigurationSetup)89 }90 @Test(dataProvider = "JavaScript-incapable WebDriver factory")91 fun `Call the configure method with a development setup and don't use it`(testFactory: () -> WebDriver) {92 val developmentConfigurationSetup: ConfigurationSetup = Configuration(false, testFactory)93 Browser.configure {94 driverFactory = testFactory95 setups = mapOf(96 "development" to setup {97 autoQuit = developmentConfigurationSetup.autoQuit98 driverFactory = developmentConfigurationSetup.driverFactory99 }100 )101 }102 Assert.assertNotEquals(Browser.desiredConfiguration, developmentConfigurationSetup)103 }104 @Test(dataProvider = "JavaScript-incapable WebDriver factory")105 fun `Call the configure method with a development setup and use it`(testFactory: () -> WebDriver) {106 val developmentConfigurationSetup: ConfigurationSetup = Configuration(false, testFactory)107 Browser.configure {108 driverFactory = testFactory109 setups = mapOf(110 "development" to setup {111 autoQuit = developmentConfigurationSetup.autoQuit112 driverFactory = developmentConfigurationSetup.driverFactory113 }114 )115 }116 System.setProperty(Browser.BALIN_SETUP_NAME_PROPERTY, "development")117 Assert.assertEquals(Browser.desiredConfiguration, developmentConfigurationSetup)118 }119 @Test(dataProvider = "JavaScript-incapable WebDriver factory")120 fun `Call the drive method with a desired configuration`(testFactory: () -> WebDriver) {121 val desiredConfigurationSetup = Configuration(false, testFactory)122 Browser.drive(desiredConfigurationSetup) {123 Assert.assertEquals(configurationSetup, desiredConfigurationSetup)124 }125 }126 @Test(dataProvider = "JavaScript-incapable WebDriver factory")127 fun `Call the drive method with a default setup configuration and use it implicitly`(testFactory: () -> WebDriver) {128 val defaultConfigurationSetup: ConfigurationSetup = Configuration(false, testFactory)129 val desiredConfigurationSetup = ConfigurationBuilder().apply {130 setups = mapOf(131 "default" to setup {132 autoQuit = defaultConfigurationSetup.autoQuit133 driverFactory = defaultConfigurationSetup.driverFactory134 }135 )136 }.build()137 Browser.drive(desiredConfigurationSetup) {138 Assert.assertEquals(configurationSetup, defaultConfigurationSetup)139 }140 }141 @Test(dataProvider = "JavaScript-incapable WebDriver factory")142 fun `Call the drive method with a default setup configuration and use it explicitly`(testFactory: () -> WebDriver) {143 val defaultConfigurationSetup: ConfigurationSetup = Configuration(false, testFactory)144 val desiredConfigurationSetup = ConfigurationBuilder().apply {145 setups = mapOf(146 "default" to setup {147 autoQuit = defaultConfigurationSetup.autoQuit148 driverFactory = defaultConfigurationSetup.driverFactory149 }150 )151 }.build()152 System.setProperty(Browser.BALIN_SETUP_NAME_PROPERTY, "default")153 Browser.drive(desiredConfigurationSetup) {154 Assert.assertEquals(configurationSetup, defaultConfigurationSetup)155 }156 }157 @Test(dataProvider = "JavaScript-incapable WebDriver factory")158 fun `Call the drive method with a development setup configuration and don't use it`(testFactory: () -> WebDriver) {159 val developmentConfigurationSetup: ConfigurationSetup = Configuration(false, testFactory)160 val desiredConfigurationSetup = ConfigurationBuilder().apply {161 driverFactory = testFactory162 setups = mapOf(163 "development" to setup {164 autoQuit = developmentConfigurationSetup.autoQuit165 driverFactory = developmentConfigurationSetup.driverFactory166 }167 )168 }.build()169 Browser.drive(desiredConfigurationSetup) {170 Assert.assertEquals(configurationSetup, desiredConfigurationSetup)171 }172 }173 @Test(description = "Call the drive method with a development setup configuration and use it",174 dataProvider = "JavaScript-incapable WebDriver factory")175 fun call_the_drive_method_with_a_development_setup_configuration_and_use_it(testFactory: () -> WebDriver) {176 val developmentConfigurationSetup: ConfigurationSetup = Configuration(false, testFactory)177 val desiredConfigurationSetup = ConfigurationBuilder().apply {178 driverFactory = testFactory179 setups = mapOf(180 "development" to setup {181 autoQuit = developmentConfigurationSetup.autoQuit182 driverFactory = developmentConfigurationSetup.driverFactory183 }184 )185 }.build()186 System.setProperty(Browser.BALIN_SETUP_NAME_PROPERTY, "development")187 Browser.drive(desiredConfigurationSetup) {188 Assert.assertEquals(configurationSetup, developmentConfigurationSetup)189 }190 }191}192/* ***************************************************************************/...

Full Screen

Full Screen

ConfigurationBuilder.kt

Source:ConfigurationBuilder.kt Github

copy

Full Screen

...23 *24 * @see ConfigurationSetup25 * @sample com.github.epadronu.balin.config.ConfigurationTests.call_the_configure_method_and_make_changes26 *27 * @property setups may contain configuration setups to be used according to the `balin.setup.name` system property.28 * @constructor Creates a new configuration builder.29 */30class ConfigurationBuilder : ConfigurationSetupBuilder() {31 var setups: Map<String, ConfigurationSetup> = mapOf()32 /**33 * Domain-Specific language that let's you create a configuration.34 *35 * @sample com.github.epadronu.balin.config.ConfigurationTests.call_the_drive_method_with_a_development_setup_configuration_and_use_it36 *37 * @param block here you can interact with the DSL.38 */39 fun setup(block: ConfigurationSetupBuilder.() -> Unit): ConfigurationSetup = ConfigurationSetupBuilder().apply {40 block()41 }.build()42 /**43 * Creates a new configuration.44 *45 * @return a new configuration setup using the options provided to the builder.46 */47 override fun build(): Configuration = Configuration(48 autoQuit, driverFactory, waitForSleepTimeInMilliseconds, waitForTimeOutTimeInSeconds, setups)49}50/* ***************************************************************************/...

Full Screen

Full Screen

setup

Using AI Code Generation

copy

Full Screen

1com.github.epadronu.balin.config.ConfigurationBuilder.setup()2com.github.epadronu.balin.config.ConfigurationBuilder.setup()3com.github.epadronu.balin.config.ConfigurationBuilder.setup()4com.github.epadronu.balin.config.ConfigurationBuilder.setup()5com.github.epadronu.balin.config.ConfigurationBuilder.setup()6com.github.epadronu.balin.config.ConfigurationBuilder.setup()7com.github.epadronu.balin.config.ConfigurationBuilder.setup()8com.github.epadronu.balin.config.ConfigurationBuilder.setup()9com.github.epadronu.balin.config.ConfigurationBuilder.setup()10com.github.epadronu.balin.config.ConfigurationBuilder.setup()11com.github.epadronu.balin.config.ConfigurationBuilder.setup()12com.github.epadronu.balin.config.ConfigurationBuilder.setup()13com.github.epadronu.balin.config.ConfigurationBuilder.setup()14com.github.epadronu.balin.config.ConfigurationBuilder.setup()15com.github.epadronu.balin.config.ConfigurationBuilder.setup()

Full Screen

Full Screen

setup

Using AI Code Generation

copy

Full Screen

1Configuration configuration = new ConfigurationBuilder()2 .withDriver(Driver.CHROME)3 .withHeadlessMode(true)4 .withBrowserSize(BrowserSize.FULL_HD)5 .withImplicitWait(10)6 .withPageLoadTimeout(10)7 .withScriptTimeout(10)8 .withProxy(Proxy.NO_PROXY)9 .build();10Balin balin = new Balin(configuration);11balin.openBrowser();12balin.navigateTo("

Full Screen

Full Screen

setup

Using AI Code Generation

copy

Full Screen

1 .forBrowser("firefox")2 .withDriverPath("/path/to/driver")3 .setup();4 .forBrowser("internet explorer")5 .withDriverPath("/path/to/driver")6 .setup();7 .forBrowser("opera")8 .withDriverPath("/path/to/driver")9 .setup();10 .forBrowser("safari")11 .withDriverPath("/path/to/driver")12 .setup();13 .forBrowser("phantomjs")14 .withDriverPath("/path/to/driver")15 .setup();16 .forBrowser("htmlunit")17 .withDriverPath("/path/to/driver")18 .setup();19 .forBrowser("htmlunitwithjs")20 .withDriverPath("/path/to/driver")21 .setup();22 .forBrowser("chrome")

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Balin automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in ConfigurationBuilder

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful