dylandoamaral / zio-selenium   1.0.1

Apache License 2.0 GitHub

A ZIO wrapper to interact with a browser using Selenium.

Scala versions: 2.13

ZIO Selenium

A ZIO friendly library to interact with a browser using Selenium.

Why use it 🤔

For users:

  • You need to test website interactions
  • You want to create browser automation

For users:

  • You need to run selenium in parallel
  • You want to retry elegantly using zio schedule
  • You want to use selenium purely

Using ZIO Selenium

If you're using sbt, add the following to your build:

libraryDependencies ++= Seq(
  "dev.doamaral" %% "zio-selenium" % "1.0.1"
)

How it works

Here is a sample to link to a particular website and retrieve the title:

import org.openqa.selenium.{By, WebDriverException}
import org.openqa.selenium.chrome.ChromeDriver

import zio._
import zio.selenium._

object FindElement extends ZIOAppDefault {

  val app: ZIO[WebDriver, Throwable, Unit] =
    for {
      _       <- WebDriver.get("https://www.selenium.dev/documentation/en/")
      element <- WebDriver.findElement(By.id("the-selenium-browser-automation-project"))
      text    <- element.getText
      _       <- Console.printLine(s"Title: $text")
    } yield ()

  val layer: Layer[WebDriverException, WebDriver] = WebDriver.layer(new ChromeDriver())

  override def run = app.provide(layer)
}

Community 🤝

If you have a problem using ZIO Selenium or if you want to add features, issues and pull requests are welcome.

Don't hesitate to give a ⭐ to the project if you like it!