How to use goToLearnPage method of com.github.epadronu.balin.core.ComponentTests class

Best Balin code snippet using com.github.epadronu.balin.core.ComponentTests.goToLearnPage

ComponentTests.kt

Source:ComponentTests.kt Github

copy

Full Screen

...98            }99        }100        // And a component for the navigation links101        class NavLinks(page: Page, element: WebElement) : Component(page, element) {102            fun goToLearnPage(): ReferencePage {103                `$`("a", 0).click()104                return browser.at(::ReferencePage)105            }106        }107        // And the Kotlin's website index page108        class IndexPage(browser: Browser) : Page(browser) {109            override val url = "https://kotlinlang.org/"110            override val at = at {111                title == "Kotlin Programming Language"112            }113            val navLinks by lazy {114                `$`("div.nav-links", 0).component(::NavLinks)115            }116        }117        Browser.drive(driverFactory) {118            // When I visit the Kotlin's website index page119            val indexPage = to(::IndexPage)120            // And I click on the Learn navigation link121            val referencePage = indexPage.navLinks.goToLearnPage()122            // Then the browser should land on the Reference page123            assertEquals(referencePage.header, "Learn Kotlin")124        }125    }126    @Test(dataProvider = "JavaScript-incapable WebDriver factory")127    fun `Use WebElement#click in a component to place the browser at a different page`(driverFactory: () -> WebDriver) {128        // Given the Kotlin's reference page129        class ReferencePage(browser: Browser) : Page(browser) {130            override val at = at {131                title == "Reference - Kotlin Programming Language"132            }133            val header by lazy {134                `$`("h1", 0).text135            }136        }137        // And a component for the navigation links138        class NavLinks(page: Page, element: WebElement) : Component(page, element) {139            fun goToLearnPage() = `$`("a", 0).click(::ReferencePage)140        }141        // And the Kotlin's website index page142        class IndexPage(browser: Browser) : Page(browser) {143            override val url = "https://kotlinlang.org/"144            override val at = at {145                title == "Kotlin Programming Language"146            }147            val navLinks by lazy {148                `$`("div.nav-links", 0).component(::NavLinks)149            }150        }151        Browser.drive(driverFactory) {152            // When I visit the Kotlin's website index page153            val indexPage = to(::IndexPage)154            // And I click on the Learn navigation link155            val referencePage = indexPage.navLinks.goToLearnPage()156            // Then the browser should land on the Reference page157            assertEquals(referencePage.header, "Learn Kotlin")158        }159    }160}161/* ***************************************************************************/...

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful