-
Notifications
You must be signed in to change notification settings - Fork 1
/
ByTitleTest.kt
63 lines (46 loc) · 1.51 KB
/
ByTitleTest.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package seleniumtestinglib.locators
import seleniumtestinglib.JsFunction
import seleniumtestinglib.TL.By.title
import seleniumtestinglib.driver
import seleniumtestinglib.render
import java.util.regex.Pattern
import java.util.regex.Pattern.CASE_INSENSITIVE
import kotlin.test.Test
import kotlin.test.assertEquals
class ByTitleTest {
@Test
fun `by title`() {
driver.render("<div title='foobar'>Hello World!</div>")
val result = driver.findElement(title("foobar"))
assertEquals("Hello World!", result.text)
}
@Test
fun `by title on svg`() {
driver.render(
"""<svg>
<title>foobar</title>
<g><path /></g>
</svg>"""
)
val result = driver.findElement(title("foobar"))
assertEquals("foobar", result.text)
}
@Test
fun `not exact`() {
driver.render("<div title='foobar'>Hello World!</div>")
val result = driver.findElement(title("FOO", exact = false))
assertEquals("Hello World!", result.text)
}
@Test
fun regex() {
driver.render("<div title='foobar'>Hello World!</div>")
val result = driver.findElement(title(Pattern.compile("FOO", CASE_INSENSITIVE)))
assertEquals("Hello World!", result.text)
}
@Test
fun function() {
driver.render("<div title='foobar'>Hello World!</div>")
val result = driver.findElement(title(JsFunction("c => c.startsWith('foo')")))
assertEquals("Hello World!", result.text)
}
}