Skip to content

Commit

Permalink
Merge pull request #11 from TurekBot/fix-hello-world
Browse files Browse the repository at this point in the history
Fix the `HelloWorld` test
  • Loading branch information
EPadronU authored Jun 30, 2023
2 parents 4f9b7f2 + b9386e6 commit cef0c6a
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ package com.github.epadronu.balin.examples.helloworld
import com.github.epadronu.balin.core.Browser
import com.github.epadronu.balin.core.Page
import org.openqa.selenium.By
import org.openqa.selenium.interactions.Actions
import org.openqa.selenium.support.ui.ExpectedCondition
import org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable
import org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfElementLocated
import org.testng.Assert
import org.testng.annotations.BeforeClass
import org.testng.annotations.Test
Expand All @@ -38,11 +40,17 @@ class IndexPage(browser: Browser) : Page(browser) {
title == "Kotlin Programming Language"
}

private val tryItButton by lazy {
waitFor { elementToBeClickable(By.xpath("//a[@class='nav-item' and contains(text(),'Try Online')]")) }
private val playMenu by lazy {
waitFor { elementToBeClickable(By.xpath("//nav//li[*[text()='Play']]")) }
}
private val playgroundButton by lazy {
waitFor { elementToBeClickable(By.xpath("//nav//li[*[text()='Playground']]")) }
}

fun goToTryItPage(): TryItPage = tryItButton.click(::TryItPage)
fun goToTryItPage(): TryItPage {
Actions(driver).moveToElement(playMenu).perform()
return playgroundButton.click(::TryItPage)
}
}

class TryItPage(browser: Browser) : Page(browser) {
Expand All @@ -61,11 +69,16 @@ class TryItPage(browser: Browser) : Page(browser) {
}
}

private val codeArea by lazy {
By.cssSelector(".code-area")
}

private val runButton by lazy {
waitFor { elementToBeClickable(By.className("wt-button_mode_primary")) }
waitFor { elementToBeClickable(By.cssSelector("button[data-test='run-button']")) }
}

fun runHelloWorld(): String {
waitFor { visibilityOfElementLocated(codeArea) }
runButton.click()

return consoleOutput.text
Expand Down

0 comments on commit cef0c6a

Please sign in to comment.