Skip to content

Commit

Permalink
Simplify Electron Selenium test (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrdom authored Mar 23, 2024
1 parent 2f0d071 commit 23ef993
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit 23ef993

Please sign in to comment.