Skip to content

Commit 26d0164

Browse files
committed
make regex more similar to TL
1 parent b65b1d4 commit 26d0164

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/src/main/kotlin/com/luissoares/ByPlaceholderText.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ data class ByPlaceholderText(
2323
}
2424
}
2525
} ?: regexText?.let {
26+
val regexContains = Regex(".*${regexText.pattern}.*", regexText.options)
2627
getWebDriver(context).filterAll { element ->
2728
element.getAttribute("placeholder")
28-
?.let(regexText::matches)
29+
?.let(regexContains::matches)
2930
?: false
3031
}
3132
}

lib/src/test/kotlin/com/luissoares/ByPlaceholderTextTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ByPlaceholderTextTest {
5353
driver.getFromHtml("<input placeholder='Username' />")
5454

5555
val result = driver.findElement(
56-
ByPlaceholderText(regexText = Regex(".*user.*", IGNORE_CASE))
56+
ByPlaceholderText(regexText = Regex("user", IGNORE_CASE))
5757
)
5858

5959
assertEquals("input", result.tagName)

0 commit comments

Comments
 (0)