Skip to content

Commit c6365c7

Browse files
authored
Merge pull request #1308 from UdashFramework/scala-steward-update/selenium-java-4.27.0
update/selenium java 4.27.0
2 parents 9dee7af + 778d3ef commit c6365c7

File tree

7 files changed

+60
-63
lines changed

7 files changed

+60
-63
lines changed

guide/backend/src/main/scala/io/udash/web/guide/demos/i18n/TranslationServer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package io.udash.web.guide.demos.i18n
22

3-
import java.{util => ju}
4-
5-
import io.udash.web.Implicits._
63
import io.udash.i18n.{Lang, ResourceBundlesTranslationTemplatesProvider, TranslationRPCEndpoint}
4+
import io.udash.web.Implicits.*
5+
6+
import java.util as ju
77

88
class TranslationServer extends TranslationRPCEndpoint(
99
new ResourceBundlesTranslationTemplatesProvider(
1010
TranslationServer.langs
1111
.map(lang =>
12-
Lang(lang) -> TranslationServer.bundlesNames.map(name => ju.ResourceBundle.getBundle(name, new ju.Locale(lang)))
12+
Lang(lang) -> TranslationServer.bundlesNames.map(name => ju.ResourceBundle.getBundle(name, new ju.Locale.Builder().setLanguage(lang).build()))
1313
).toMap
1414
)
1515
)

guide/selenium/src/test/resources/logback-test.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

guide/selenium/src/test/scala/io/udash/web/SeleniumTest.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package io.udash.web
22

3+
import com.typesafe.scalalogging.StrictLogging
34
import io.github.bonigarcia.wdm.WebDriverManager
45
import org.openqa.selenium.firefox.{FirefoxDriver, FirefoxOptions}
56
import org.openqa.selenium.remote.RemoteWebDriver
67
import org.openqa.selenium.{By, Dimension, WebElement}
78
import org.scalatest.concurrent.Eventually
8-
import org.scalatest.time.{Millis, Seconds, Span}
9-
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach}
109
import org.scalatest.matchers.should.Matchers
10+
import org.scalatest.time.{Millis, Seconds, Span}
1111
import org.scalatest.wordspec.AnyWordSpec
12+
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, Inspectors}
1213

1314
import java.time.Duration
1415

@@ -41,13 +42,15 @@ private final class InternalServerConfig extends ServerConfig {
4142

4243
override def createUrl(part: String): String = {
4344
require(part.startsWith("/"))
44-
s"http://127.0.0.2:${server.port}$part"
45+
s"http://localhost:${server.port}$part"
4546
}
4647
}
4748

48-
abstract class SeleniumTest extends AnyWordSpec with Matchers with BeforeAndAfterAll with BeforeAndAfterEach with Eventually {
49+
abstract class SeleniumTest extends AnyWordSpec
50+
with Matchers with BeforeAndAfterAll with BeforeAndAfterEach with Eventually with StrictLogging with Inspectors {
4951
override implicit val patienceConfig: PatienceConfig = PatienceConfig(scaled(Span(10, Seconds)), scaled(Span(50, Millis)))
5052

53+
logger.info("Setting up WebDriver")
5154
private val driverManager = WebDriverManager.firefoxdriver()
5255
driverManager.config().setServerPort(0)
5356
driverManager.setup()

guide/selenium/src/test/scala/io/udash/web/guide/demos/frontend/FrontendFormsTest.scala

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ package io.udash.web.guide.demos.frontend
22

33
import io.udash.web.SeleniumTest
44
import org.openqa.selenium.By.{ByClassName, ByCssSelector, ByTagName}
5-
import org.openqa.selenium.{By, Keys}
65

7-
import com.avsystem.commons._
86
import scala.util.Random
97

108
class FrontendFormsTest extends SeleniumTest {
@@ -19,12 +17,12 @@ class FrontendFormsTest extends SeleniumTest {
1917
val checkbox = checkboxes.findElement(new ByClassName(s"checkbox-demo-$propertyName"))
2018
checkbox.click()
2119
eventually {
22-
checkboxes.findElements(new ByCssSelector(s"[data-bind=$propertyName]")).asScala.forall(el => {
23-
el.getText == expect
24-
}) should be(true)
25-
checkboxes.findElements(new ByClassName(s"checkbox-demo-$propertyName")).asScala.forall(el => {
26-
el.getAttribute("selected") == checkbox.getAttribute("selected")
27-
}) should be(true)
20+
forAll(checkboxes.findElements(new ByCssSelector(s"[data-bind=$propertyName]")))(el =>
21+
el.getText shouldBe expect
22+
)
23+
forAll(checkboxes.findElements(new ByClassName(s"checkbox-demo-$propertyName")))(el =>
24+
el.isSelected shouldBe checkbox.isSelected
25+
)
2826
}
2927
}
3028

@@ -45,13 +43,13 @@ class FrontendFormsTest extends SeleniumTest {
4543
val checkbox = checkButtons.findElement(new ByCssSelector(s"[data-label=$propertyName]")).findElement(new ByTagName("input"))
4644
checkbox.click()
4745
eventually {
48-
checkButtons.findElements(new ByClassName("check-buttons-demo-fruits")).asScala.forall(el => {
46+
forAll(checkButtons.findElements(new ByClassName("check-buttons-demo-fruits")))(el => {
4947
val contains = el.getText.contains(propertyName)
50-
if (checkbox.getAttribute("selected") != null) contains else !contains
51-
}) should be(true)
52-
checkButtons.findElements(new ByCssSelector(s"[data-label=$propertyName]")).asScala.forall(el => {
53-
el.findElement(new ByTagName("input")).getAttribute("selected") == checkbox.getAttribute("selected")
54-
}) should be(true)
48+
assert(if (checkbox.isSelected) contains else !contains)
49+
})
50+
forAll(checkButtons.findElements(new ByCssSelector(s"[data-label=$propertyName]")))(el =>
51+
el.findElement(new ByTagName("input")).isSelected shouldBe checkbox.isSelected
52+
)
5553
}
5654
}
5755

@@ -68,13 +66,13 @@ class FrontendFormsTest extends SeleniumTest {
6866
val option = select.findElement(new ByCssSelector(s"[value='$propertyIdx']"))
6967
option.click()
7068
eventually {
71-
multiSelect.findElements(new ByClassName("multi-select-demo-fruits")).asScala.forall(el => {
69+
forAll(multiSelect.findElements(new ByClassName("multi-select-demo-fruits")))(el => {
7270
val contains = el.getText.contains(propertyName)
73-
if (option.getAttribute("selected") != null) contains else !contains
74-
}) should be(true)
75-
multiSelect.findElements(new ByTagName("select")).asScala.forall(el => {
76-
el.findElement(new ByCssSelector(s"[value='$propertyIdx']")).getAttribute("selected") == option.getAttribute("selected")
77-
}) should be(true)
71+
assert(if (option.isSelected) contains else !contains)
72+
})
73+
forAll(multiSelect.findElements(new ByTagName("select")))(el => {
74+
el.findElement(new ByCssSelector(s"[value='$propertyIdx']")).isSelected shouldBe option.isSelected
75+
})
7876
}
7977
}
8078

@@ -92,13 +90,13 @@ class FrontendFormsTest extends SeleniumTest {
9290
val radio = radioButtons.findElement(new ByCssSelector(s"[data-label=$propertyName]")).findElement(new ByTagName("input"))
9391
driver.executeScript("arguments[0].click();", radio)
9492
eventually {
95-
radioButtons.findElements(new ByClassName("radio-buttons-demo-fruits")).asScala.forall(el => {
96-
el.getText == propertyName
97-
}) should be(true)
98-
radioButtons.findElements(new ByCssSelector(s"input")).asScala.forall(el => {
99-
val eq = el.getAttribute("selected") == radio.getAttribute("selected")
100-
if (el.getAttribute("value").toInt == propertyIdx) eq else !eq
101-
}) should be(true)
93+
forAll(radioButtons.findElements(new ByClassName("radio-buttons-demo-fruits")))(el =>
94+
el.getText shouldBe propertyName
95+
)
96+
forAll(radioButtons.findElements(new ByCssSelector(s"input")))(el => {
97+
val eq = el.isSelected == radio.isSelected
98+
assert(if (el.getDomProperty("value").toInt == propertyIdx) eq else !eq)
99+
})
102100
}
103101
}
104102

@@ -117,12 +115,12 @@ class FrontendFormsTest extends SeleniumTest {
117115
val option = select.findElement(new ByCssSelector(s"[value='$propertyIdx']"))
118116
option.click()
119117
eventually {
120-
selectDemo.findElements(new ByClassName("select-demo-fruits")).asScala.forall(el => {
121-
el.getText == propertyName
122-
}) should be(true)
123-
selectDemo.findElements(new ByTagName(s"select")).asScala.forall(el => {
124-
el.findElement(new ByCssSelector(s"[value='$propertyIdx']")).getAttribute("selected") == option.getAttribute("selected")
125-
}) should be(true)
118+
forAll(selectDemo.findElements(new ByClassName("select-demo-fruits")))(el => {
119+
el.getText shouldBe propertyName
120+
})
121+
forAll(selectDemo.findElements(new ByTagName(s"select")))(el => {
122+
el.findElement(new ByCssSelector(s"[value='$propertyIdx']")).isSelected shouldBe option.isSelected
123+
})
126124
}
127125
}
128126

@@ -141,9 +139,9 @@ class FrontendFormsTest extends SeleniumTest {
141139
textArea.clear()
142140
textArea.sendKeys(text)
143141
eventually {
144-
textAreaDemo.findElements(new ByTagName(s"textarea")).asScala.forall(el => {
145-
el.getAttribute("value") == text
146-
}) should be(true)
142+
forAll(textAreaDemo.findElements(new ByTagName(s"textarea")))(el => {
143+
el.getDomProperty("value") shouldBe text
144+
})
147145
}
148146
}
149147

@@ -160,9 +158,9 @@ class FrontendFormsTest extends SeleniumTest {
160158
input.clear()
161159
input.sendKeys(text)
162160
eventually {
163-
inputsDemo.findElements(new ByCssSelector(s"input[type=$tpe]")).asScala.forall(el => {
164-
el.getAttribute("value") == text
165-
}) should be(true)
161+
forAll(inputsDemo.findElements(new ByCssSelector(s"input[type=$tpe]")))(el => {
162+
el.getDomProperty("value") shouldBe text
163+
})
166164
}
167165
}
168166

guide/selenium/src/test/scala/io/udash/web/guide/demos/frontend/FrontendIntroTest.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,21 @@ class FrontendIntroTest extends SeleniumTest {
8080
val between = demo.findElement(new ById("between"))
8181
val maximum = demo.findElement(new ById("maximum"))
8282

83-
var lastMinimum = minimum.getAttribute("value")
84-
var lastBetween = between.getAttribute("value")
85-
var lastMaximum = maximum.getAttribute("value")
83+
var lastMinimum = minimum.getDomProperty("value")
84+
var lastBetween = between.getDomProperty("value")
85+
var lastMaximum = maximum.getDomProperty("value")
8686

8787
for (_ <- 1 to 5) {
8888
randomizeButton.click()
8989
eventually {
90-
(lastMinimum != minimum.getAttribute("value") ||
91-
lastBetween != between.getAttribute("value") ||
92-
lastMaximum != maximum.getAttribute("value")) should be(true)
90+
(lastMinimum != minimum.getDomProperty("value") ||
91+
lastBetween != between.getDomProperty("value") ||
92+
lastMaximum != maximum.getDomProperty("value")) should be(true)
9393
}
9494

95-
lastMinimum = minimum.getAttribute("value")
96-
lastBetween = between.getAttribute("value")
97-
lastMaximum = maximum.getAttribute("value")
95+
lastMinimum = minimum.getDomProperty("value")
96+
lastBetween = between.getDomProperty("value")
97+
lastMaximum = maximum.getDomProperty("value")
9898
}
9999
}
100100
}

guide/selenium/src/test/scala/io/udash/web/guide/demos/frontend/FrontendRoutingTest.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.udash.web.guide.demos.frontend
22

33
import io.udash.web.SeleniumTest
4-
import org.openqa.selenium.By
54

65
class FrontendRoutingTest extends SeleniumTest {
76
override protected final val url = "/frontend/routing"
@@ -51,7 +50,7 @@ class FrontendRoutingTest extends SeleniumTest {
5150
link.getText should be("/frontend/routing/pizza")
5251
}
5352

54-
input.getAttribute("value") should be("It should not disappear... Selenium")
53+
input.getDomProperty("value") should be("It should not disappear... Selenium")
5554
}
5655

5756
"change URL basing on input without view redraw" in {
@@ -81,7 +80,7 @@ class FrontendRoutingTest extends SeleniumTest {
8180
}
8281

8382
init.getText should be("/frontend/routing")
84-
input.getAttribute("value") should be("It should not disappear... Selenium")
83+
input.getDomProperty("value") should be("It should not disappear... Selenium")
8584
}
8685
}
8786
}

project/Dependencies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ object Dependencies {
4242
val bootstrap4DatepickerVersion = "5.39.0"
4343
val momentJsVersion = "2.30.1"
4444

45-
val seleniumVersion = "4.26.0"
45+
val seleniumVersion = "4.27.0"
4646
val webDriverManagerVersion = "5.9.2"
4747
val scalaJsBenchmarkVersion = "0.10.0"
4848

0 commit comments

Comments
 (0)