Skip to content

rangana-lasith/selenium-script-runner

Repository files navigation

Selenium Script Runner

A lightweight, script-driven browser automation tool built with Java and Selenium WebDriver. Define browser workflows in simple text files — no coding required — and integrate results directly into Zabbix monitoring.


Features

  • Script-driven automation — Write browser workflows as plain-text instruction files
  • Multi-tab support — Open, switch between, and close browser tabs within a single run
  • Encrypted credentials — Store passwords securely using AES-256-GCM encryption; never hardcode credentials in scripts
  • Zabbix integration — Push execution status, response times, and results to one or more Zabbix servers automatically
  • Headless mode — Run Firefox without a visible GUI, ideal for servers and CI pipelines
  • Flexible configuration — All settings controlled through config.properties

Prerequisites

Requirement Version Notes
Java 11+ JDK required to build; JRE sufficient to run
Firefox Any recent Must be installed on the machine
GeckoDriver Matching Firefox version Download here
Maven 3.6+ For building from source
Zabbix Server Any Optional — only if using monitoring integration

Quick Start

1. Clone the repository

git clone https://github.com/your-username/selenium-script-runner.git
cd selenium-script-runner

2. Download GeckoDriver

Download the GeckoDriver binary for your OS from Mozilla's releases page and place it at:

resources/geckodriver.exe        # Windows
resources/geckodriver            # Linux/macOS

3. Configure the runner

Copy and edit the configuration file:

cp config.properties config.properties.local

Edit config.properties to set your Firefox path, GeckoDriver path, and (optionally) Zabbix server details. See Configuration Reference below.

4. Build the JAR

mvn clean package

This produces a fat JAR at target/selenium-script-runner-1.0.0.jar.

5. Run a script

java -jar target/selenium-script-runner-1.0.0.jar example_script

Run multiple scripts (each in its own browser tab):

java -jar target/selenium-script-runner-1.0.0.jar script_one script_two script_three

Script Syntax

Scripts are plain text files placed in the scripts/ directory. Each line is a command in command=value format. Lines starting with # are comments.

Supported Commands

Command Syntax Description
open_URL open_URL=https://example.com Navigate to a URL
wait wait=3 Pause for N seconds
wait_for_text_selector wait_for_text_selector=<xpath>,<timeout>,<expected_text> Wait until an element contains a specific string
click click=<xpath> Click an element
input input=<xpath>,<text> Type text into a field
input_password input_password=<xpath> Type stored encrypted password into a field
scroll_to_bottom scroll_to_bottom Scroll to the bottom of the page
open_new_tab open_new_tab Open a new browser tab
switch_to_tab switch_to_tab=<index> Switch to tab by index (0-based)
close_tab close_tab Close the current tab

Example Script

# Login to an application and verify the dashboard loads
open_URL=https://app.example.com/login
wait=2
wait_for_text_selector=/html/body/h1,10,Welcome Back
click=/html/body/form/input[@name='username']
input=/html/body/form/input[@name='username'],myuser
click=/html/body/form/input[@name='password']
input_password=/html/body/form/input[@name='password']
click=/html/body/form/button[@type='submit']
wait=5
wait_for_text_selector=/html/body/div[@class='dashboard']/h2,15,Dashboard

Encrypted Credentials

Never put passwords in plain-text scripts. The runner includes built-in AES-256-GCM credential encryption.

Store a credential

java -jar target/selenium-script-runner-1.0.0.jar credentials

Follow the prompts — enter the script name and password. Encrypted files are saved to credentials/ and are excluded from Git via .gitignore.

Use the credential in a script

Use input_password=<xpath> in your script. The runner automatically looks for a matching credential file for the current script name.


Configuration Reference

All settings live in config.properties:

# WebDriver
webdriver.gecko.driver=resources/geckodriver.exe
firefox.binary.path=C:\Program Files\Mozilla Firefox\firefox.exe
firefox.headless=false

# Logging
show.logs=true
show.responseTime=false

# Zabbix (optional)
zabbix.sender=false
multiple.zabbix.servers=false
1.zabbix.server.ip=YOUR_ZABBIX_SERVER_IP
zabbix.server.port=10051
zabbix.sender.path=resources/zabbix/bin/zabbix_sender.exe

Zabbix Integration

When zabbix.sender=true, the runner automatically sends:

  • Execution status (success / failure) per script
  • Response time (time from script start to completion)

Configure your Zabbix host and item keys to match your hostnames. Multiple Zabbix servers are supported using numbered properties (1.zabbix.server.ip, 2.zabbix.server.ip, etc.).


Project Structure

selenium-script-runner/
├── src/
│   └── main/
│       └── java/
│           └── SeleniumScriptRunner.java   # Main application
├── scripts/
│   └── example_script                      # Example automation script
├── resources/
│   ├── geckodriver.exe                     # GeckoDriver binary (not in Git)
│   └── zabbix/
│       ├── bin/                            # Zabbix sender binaries (not in Git)
│       └── conf/
│           └── zabbix_agentd.conf          # Zabbix agent config template
├── credentials/                            # Encrypted credential files (not in Git)
├── config.properties                       # Runtime configuration
├── pom.xml                                 # Maven build file
└── .gitignore

Building & Packaging

# Build fat JAR (includes all dependencies)
mvn clean package

# The output JAR is at:
target/selenium-script-runner-1.0.0.jar

The Maven Shade plugin bundles all Selenium dependencies into a single executable JAR for easy deployment.


Security Notes

  • Never commit real credentials — the credentials/ directory is in .gitignore
  • Never put passwords in script files — use the credentials command and input_password directive
  • Review your scripts before pushing — ensure they don't contain internal URLs, usernames, or IP addresses
  • Zabbix IPs in config.properties are placeholders — replace before running, don't commit real values

License

MIT License. See LICENSE for details.


Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change.

About

Browser automation tool with Zabbix integration

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages