Skip to content

A modern, lightweight Delphi client (No third party) for the W3C WebDriver protocol (the same protocol used by Selenium). This library allows Delphi developers to automate browsers such as Chrome, Firefox, and Edge by communicating with their corresponding WebDriver executables.

License

Notifications You must be signed in to change notification settings

interestingitems/DelphiWebDriver

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DelphiWebDriver

A modern, lightweight Delphi client (No third party) for the W3C WebDriver protocol (the same protocol used by Selenium). This library allows Delphi developers to automate browsers such as Chrome, Firefox, and Edge by communicating with their corresponding WebDriver executables.


✨ Features

  • Create and manage WebDriver sessions
  • Navigate to URLs
  • Locate elements (By.Id, By.Name, By.ClassName, By.CSS, By.XPath...)
  • Click elements, send keys, submit forms
  • Take screenshots and save to file
  • Wait for elements to appear or conditions to be true
  • Manage cookies, frames
  • Interface-based memory management for stability
  • Cross-browser support (Chrome, Firefox, Edge)
  • headless mode support (Chrome, Firefox, Edge)
  • And more cool stuff is coming...

📁 Project Structure

/DelphiWebDriver
  /Source
    DelphiWebDriver.Core.pas
    DelphiWebDriver.Element.pas
    DelphiWebDriver.Interfaces.pas
    DelphiWebDriver.Types.pas
    DelphiWebDriver.Capabilities.pas
    DelphiWebDriver.Server.pas
    DelphiWebDriver.Cookies.pas
  /Demo
    DelphiWebDriverDemo.Main.pas
    DelphiWebDriverDemo.Main.fmx
  README.md
  LICENSE

Source/ contains the core library units Demo/ contains a small FMX demo showing Chrome automation


🚀 Getting Started

Requirements

Place the driver executable next to your application.


Example Usage

uses
  DelphiWebDriver.Core,
  DelphiWebDriver.Types,
  DelphiWebDriver.Capabilities,
  DelphiWebDriver.Server,
  DelphiWebDriver.Interfaces;

procedure TMainForm.StartDriverButtonClick(Sender: TObject);
var
  Server: TWebDriverServer;
  Driver: IWebDriver;
  Caps: TWebDriverCapabilities;
begin
  var DriverName := '';
  var BrowserName := '';
  if ChromeRadioButton.IsChecked then
    begin
      DriverName  := TBrowser.Chrome.DriverName;
      BrowserName := TBrowser.Chrome.Name;
    end;
  if FirefoxRadioButton.IsChecked then
    begin
      DriverName  := TBrowser.Firefox.DriverName;
      BrowserName := TBrowser.Firefox.Name;
    end;
  if EdgeRadioButton.IsChecked then
    begin
      DriverName  := TBrowser.Edge.DriverName;
      BrowserName := TBrowser.Edge.Name;
    end;

  if DriverName.IsEmpty then
    begin
      LogsMemo.Text := 'You must select driver';
      Exit;
    end;

  Server := TWebDriverServer.Create(DriverName);
  try
    Server.Start;
    Driver := TWebDriver.Create('http://localhost:9515');
    try
      Caps := TWebDriverCapabilities.Create;
      try
        Caps.BrowserName := BrowserName;
        if HeadlessModeCheckBox.IsChecked then
          Caps.Headless := True
        else
          Caps.Headless := False;

        // Optional Args
        // Caps.Args.Add('--disable-gpu');
        // Caps.Args.Add('--window-size=1920,1080');

        Driver.StartSession(Caps);
      finally
        Caps.Free;
      end;

      Driver.Navigate('https://www.google.com');
      Driver.WaitUntilPageLoad;

      LogsMemo.Text := Driver.GetPageSource;

    finally
      Driver.Quit;
    end;
  finally
    Server.Stop;
    Server.Free;
  end;
end;

⚡ Notes

  • Use interface variables (IWebDriver, IWebElement) for safe automatic memory management.
  • Avoid keeping element references after quitting the driver.
  • WaitUntilElement supports Id, Name, ClassName, CSS Selector, XPath.
  • TWebDriverServer helps start/stop ChromeDriver for your tests.

📜 License

MIT License


🤝 Contributing

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


🐞 Issues

If you find a bug, please provide:

  • Steps to reproduce
  • Expected behavior
  • Actual behavior
  • Delphi version
  • WebDriver and browser version

🗺️ Roadmap

  • Minimal viable implementation
  • Element location by CSS/XPath
  • Wait for elements and conditions
  • Click, send keys, submit forms
  • Wait for page to load
  • Screenshot support
  • Cross-browser (Chrome, Firefox, Edge)
  • Cookie management
  • Frame
  • JavaScript execution
  • handling headless mode
  • Full WebDriver command coverage

About

A modern, lightweight Delphi client (No third party) for the W3C WebDriver protocol (the same protocol used by Selenium). This library allows Delphi developers to automate browsers such as Chrome, Firefox, and Edge by communicating with their corresponding WebDriver executables.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Pascal 100.0%