From 45154671ae23e8764348da34b67aab2f093c0860 Mon Sep 17 00:00:00 2001 From: slivieratos Date: Mon, 4 Mar 2024 17:53:05 +0100 Subject: [PATCH 1/2] Make jestdom test run on Firefox --- .../main/kotlin/seleniumtestinglib/JestDom.kt | 2 +- .../main/kotlin/seleniumtestinglib/WebElement.kt | 6 +++--- .../jestdom/AccessibleNameTest.kt | 4 ++-- .../seleniumtestinglib/jestdom/FocusTest.kt | 5 +++-- .../seleniumtestinglib/jestdom/StyleTest.kt | 16 +++++++++++++--- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/src/main/kotlin/seleniumtestinglib/JestDom.kt b/lib/src/main/kotlin/seleniumtestinglib/JestDom.kt index e7d4657..44d7ef6 100644 --- a/lib/src/main/kotlin/seleniumtestinglib/JestDom.kt +++ b/lib/src/main/kotlin/seleniumtestinglib/JestDom.kt @@ -95,7 +95,7 @@ data class JestDomMatcher( fun toHaveAccessibleName() { requireNotNull(element) - validate(element.accessibleName.isNotBlank()) + validate(element.accessibleName.isNullOrBlank().not()) } fun toHaveAccessibleName(expectedAccessibleName: String) { diff --git a/lib/src/main/kotlin/seleniumtestinglib/WebElement.kt b/lib/src/main/kotlin/seleniumtestinglib/WebElement.kt index 521566b..1972f01 100644 --- a/lib/src/main/kotlin/seleniumtestinglib/WebElement.kt +++ b/lib/src/main/kotlin/seleniumtestinglib/WebElement.kt @@ -65,7 +65,8 @@ val WebElement.isFocused: Boolean get() = equals(wrappedDriver.switchTo().activeElement()) val WebElement.isRequired - get() = ((tagName == "input") and (getAttribute("type") == "file") or (ariaRole?.lowercase() in setOf( + get() = ((tagName == "input") and (getAttribute("type") in setOf("file", "password", "date")) + or (ariaRole?.lowercase() in setOf( "textbox", "checkbox", "radio", @@ -73,7 +74,6 @@ val WebElement.isRequired "spinbutton", "combobox", "listbox", - "date", ))) and (getAttribute("required") in setOf( "", "true" @@ -155,4 +155,4 @@ enum class Event { AnimationStart, AnimationEnd, AnimationIteration, TransitionCancel, TransitionEnd, TransitionRun, TransitionStart, PointerOver, PointerEnter, PointerDown, PointerMove, PointerUp, PointerCancel, PointerOut, PointerLeave, GotPointerCapture, LostPointerCapture, PopState, Offline, Online, DoubleClick -} \ No newline at end of file +} diff --git a/lib/src/test/kotlin/seleniumtestinglib/jestdom/AccessibleNameTest.kt b/lib/src/test/kotlin/seleniumtestinglib/jestdom/AccessibleNameTest.kt index c8edfe6..80553b7 100644 --- a/lib/src/test/kotlin/seleniumtestinglib/jestdom/AccessibleNameTest.kt +++ b/lib/src/test/kotlin/seleniumtestinglib/jestdom/AccessibleNameTest.kt @@ -8,6 +8,7 @@ import seleniumtestinglib.expect import seleniumtestinglib.render import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertTrue import kotlin.text.RegexOption.IGNORE_CASE class AccessibleNameTest { @@ -19,7 +20,6 @@ class AccessibleNameTest { """accessible name""", """""", """""", - """