From 23ef993ffa554c5193eb23af8ebc167f49287aff Mon Sep 17 00:00:00 2001 From: Domantas Petrauskas <5850190+ptrdom@users.noreply.github.com> Date: Sat, 23 Mar 2024 10:57:17 +0200 Subject: [PATCH] Simplify Electron Selenium test (#177) --- .../src/test/scala/example/SeleniumSpec.scala | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sbt-scalajs-esbuild-electron/examples/e2e-test-selenium-jvm/e2e-test/src/test/scala/example/SeleniumSpec.scala b/sbt-scalajs-esbuild-electron/examples/e2e-test-selenium-jvm/e2e-test/src/test/scala/example/SeleniumSpec.scala index 130ad0a3..86cb4bd5 100644 --- a/sbt-scalajs-esbuild-electron/examples/e2e-test-selenium-jvm/e2e-test/src/test/scala/example/SeleniumSpec.scala +++ b/sbt-scalajs-esbuild-electron/examples/e2e-test-selenium-jvm/e2e-test/src/test/scala/example/SeleniumSpec.scala @@ -14,7 +14,7 @@ import org.scalatestplus.selenium.WebBrowser import scala.annotation.tailrec import scala.sys.process._ -class SeleniumSpec extends AnyFreeSpec with Matchers { +class SeleniumSpec extends AnyFreeSpec with Matchers with WebBrowser { val targetDirectory = { // test can be executed by IntelliJ Run/Debug configurations and from sbt, @@ -82,14 +82,12 @@ class SeleniumSpec extends AnyFreeSpec with Matchers { options.setExperimentalOption("debuggerAddress", s"localhost:$debugPort") implicit val webDriver: WebDriver = new ChromeDriver(options) try { - new WebBrowser { - pageTitle shouldBe "Hello World!" - find(xpath("//h1[text()='PRELOAD WORKS!']")) shouldBe defined - find(xpath("//h1[text()='RENDERER WORKS!']")) shouldBe defined - executeScript( - "return window.getComputedStyle(document.getElementById('css-hook'), '::after')['content']" - ).asInstanceOf[String] shouldBe "\"CSS WORKS!\"" - } + pageTitle shouldBe "Hello World!" + find(xpath("//h1[text()='PRELOAD WORKS!']")) shouldBe defined + find(xpath("//h1[text()='RENDERER WORKS!']")) shouldBe defined + executeScript( + "return window.getComputedStyle(document.getElementById('css-hook'), '::after')['content']" + ).asInstanceOf[String] shouldBe "\"CSS WORKS!\"" } finally { webDriver.quit() }