DEV Community

Cover image for Introduction to TSWebDriver4Delphi: Web Browser Automation in Delphi
Gabriel Trigo
Gabriel Trigo

Posted on

Introduction to TSWebDriver4Delphi: Web Browser Automation in Delphi

What is TSWebDriver4Delphi?

TSWebDriver4Delphi is a project that encapsulates a variety of tools enabling web browser automation. It specifically provides an infrastructure for the W3C WebDriver specification. Following a similar approach to Selenium, TSWebDriver4Delphi allows automation of interactions with user interface elements, making tests more efficient and reliable.

The conception of this project originated from the need to perform web scraping on a specific site. Despite numerous options for this task, such as Selenium with Python, Puppeteer in Node.JS, and Playwright in C#, the question arose: what about Delphi?
I chose not to resort to the renowned CEF4Delphi, seeking a lighter alternative with fewer dependencies. I wanted a solution that efficiently addressed the demands, providing a more agile and uncomplicated experience.
In light of this scenario, I developed this tool in Delphi to streamline my work. Today, I share it with you.

Some features include:

  • Web Navigation
  • Element Location
  • Form Filling
  • Screenshots Capture
  • Waits
  • Headless Mode Execution
  • Handling Alerts and Pop-ups

Example of Use: Login Automation in the Chrome Browser

Let's take a look at a basic example using TSWebDriver4Delphi:

  TSWebDriver, TSWebDriver.IBrowser, TSWebDriver.IElement;

  ChromeWebDriver: ITSWebDriverBrowser;

  ChromeWebDriver := TTSWebDriver.New().Driver().Browser().Chrome();






Enter fullscreen mode Exit fullscreen mode

Run JavaScript:

ChromeWebDriver.ExecuteSyncScript('return document.title');
Enter fullscreen mode Exit fullscreen mode

⚠️ Warning: Alpha Stage

I want to remind everyone that the project is currently in alpha stage. I am still refining classes and methods, and changes may occur as we progress. Feel free to explore, test, and, of course, provide valuable feedback!

How to Contribute and Get More Information:

TSWebDriver4Delphi is an open-source project, and I encourage the community to contribute, report issues, and suggest improvements. The repository is available on GitHub at TSWebDriver4Delphi.

I am excited to see how TSWebDriver4Delphi can benefit our web testing automation efforts in the Delphi world. Let's build something amazing together! 🚀🔧

Top comments (0)