-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathUsingSeleniumTest.kt
43 lines (33 loc) · 1.1 KB
/
UsingSeleniumTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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()
}
}