Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Kotlin] Added sample using_selenium code #2224

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package dev.selenium.getting_started

import org.junit.jupiter.api.*
import org.junit.jupiter.api.Assertions.assertEquals
import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import java.time.Duration

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class UsingSeleniumTest {
private lateinit var driver: WebDriver

@BeforeEach
fun setup() {
driver = ChromeDriver()
}

@Test
fun eightComponents() {
driver.get("https://www.selenium.dev/selenium/web/web-form.html")

val title = driver.title
assertEquals("Web form", title)

driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500))

val textBox = driver.findElement(By.name("my-text"))
val submitButton = driver.findElement(By.cssSelector("button"))

textBox.sendKeys("Selenium")
submitButton.click()

val message = driver.findElement(By.id("message"))
val value = message.text
assertEquals("Received!", value)
}

@AfterEach
fun teardown() {
driver.quit()
}
}
Loading