Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:22
Show Gist options
  • Select an option

  • Save dacr/c03246839a404f8cba8578dd61433bb3 to your computer and use it in GitHub Desktop.

Select an option

Save dacr/c03246839a404f8cba8578dd61433bb3 to your computer and use it in GitHub Desktop.
Playing with scalatest selenium integration to test remote sites. / published by https://github.com/dacr/code-examples-manager #b28bd758-e932-45ab-90b0-baeea5b28d50/681e2fbd971aa01f2c0326f6afa22e0dce2d0226
// summary : Playing with scalatest selenium integration to test remote sites.
// keywords : scala, scalatest, selenium
// publish : gist
// authors : David Crosson
// license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
// id : b28bd758-e932-45ab-90b0-baeea5b28d50
// created-on : 2020-05-31T19:54:52Z
// managed-by : https://github.com/dacr/code-examples-manager
// execution : scala ammonite script (http://ammonite.io/) - run as follow 'amm scriptname.sc'
import $ivy.`org.scalatest::scalatest:3.2.6`
import $ivy.`org.scalatestplus::selenium-3-141:3.2.5.0`
// Mandatory because by default selenium tools are very verbose...
java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(java.util.logging.Level.SEVERE)
java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(java.util.logging.Level.SEVERE)
import org.scalatest._, matchers._
import org.scalatestplus.selenium._
import org.openqa.selenium.WebDriver
import org.openqa.selenium.htmlunit.HtmlUnitDriver
class ThatSpec extends flatspec.AnyFlatSpec with should.Matchers with WebBrowser {
override def suiteName="ThatSpec"
implicit val driver: WebDriver = new HtmlUnitDriver()
"selenium" should "check httpbin.org home page" in {
val home = "https://httpbin.org"
go to (home)
pageTitle shouldBe "httpbin.org"
pageSource should include ("the developer - Website")
}
it should "navigate on httpbin.org" in {
val home = "https://httpbin.org"
go to (home)
pageTitle should be ("httpbin.org")
click on linkText("the developer - Website")
pageTitle should be ("httpbin.org")
pageSource should include ("uncomment to enable the green top header")
}
it should "navigate on wikipedia" in {
val wikihome= "https://en.wikipedia.org/wiki/Selenium_(software)"
go to (wikihome)
pageTitle should be ("Selenium (software) - Wikipedia")
click on linkText("Software testing")
pageTitle should be ("Software testing - Wikipedia")
pageSource should include ("stakeholders")
}
}
org.scalatest.tools.Runner.main(Array("-oDF", "-s", classOf[ThatSpec].getName))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment