A ZIO friendly library to interact with a browser using Selenium.
- You need to test website interactions
- You want to create browser automation
- You need to run selenium in parallel
- You want to retry elegantly using zio schedule
- You want to use selenium purely
If you're using sbt, add the following to your build:
libraryDependencies ++= Seq(
"dev.doamaral" %% "zio-selenium" % "1.0.1"
)
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)
}
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!