homebrew-core/Formula/selenium-server.rb

48 lines
1.5 KiB
Ruby

class SeleniumServer < Formula
desc "Browser automation for testing purposes"
homepage "https://www.selenium.dev/"
url "https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.5.0/selenium-server-4.5.0.jar"
sha256 "74ed61b1b8c4b6d30449e50be17ecb7b9fd70013373dcfa8447f5c66e3eb53cd"
license "Apache-2.0"
livecheck do
url "https://www.selenium.dev/downloads/"
regex(/href=.*?selenium-server[._-]v?(\d+(?:\.\d+)+)\.jar/i)
end
bottle do
sha256 cellar: :any_skip_relocation, all: "ca44817764cebed5e9d83f7e46acfdfb528346d273ae82bf6e0a022ddb6996ce"
end
depends_on "openjdk"
on_linux do
# We need to have any webdriver installed for testing,
# macOS comes with safaridriver, let's use geckodriver for linux
depends_on "geckodriver" => :test
end
def install
libexec.install "selenium-server-#{version}.jar"
bin.write_jar_script libexec/"selenium-server-#{version}.jar", "selenium-server"
end
service do
run [opt_bin/"selenium-server", "standalone", "--port", "4444"]
keep_alive false
log_path var/"log/selenium-output.log"
error_log_path var/"log/selenium-error.log"
end
test do
port = free_port
fork { exec "#{bin}/selenium-server standalone --port #{port}" }
sleep 6
output = shell_output("curl --silent localhost:#{port}/status")
output = JSON.parse(output)
assert_equal true, output["value"]["ready"]
assert_match version.to_s, output["value"]["nodes"].first["version"]
end
end