dylandoamaral / zinteract

A ZIO wrapper to interact with a browser using Selenium.

Version Matrix

Zinteract

Actions Status codecov Scala Steward badge

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

Why use it

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

Using Zinteract

The latest version is 0.2.0, which is avaible for scala 2.13.

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

libraryDependencies ++= Seq(
  "dev.doamaral" %% "zinteract" % "0.2.0"
)

How it works

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

import zio.{App, ExitCode}
import zio.console

import zinteract.webdriver
import zinteract.builder.chrome
import zinteract.builder.ChromeBlueprint.default

import org.openqa.selenium.By

object FindElement extends App {
  val app = for {
    _       <- webdriver.link("https://www.selenium.dev/documentation/en/")
    element <- webdriver.findElement(By.id("the-selenium-browser-automation-project"))
    _       <- console.putStrLn(s"Title: ${element.getText()}")
  } yield ()

  val builder = chrome at "/path/to/chromedriver" using default

  override def run(args: List[String]): zio.URIO[zio.ZEnv, ExitCode] =
    app
      .provideCustomLayer(builder.buildLayer)
      .exitCode
}