<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gabriel Trigo</title>
    <description>The latest articles on DEV Community by Gabriel Trigo (@gabrieltrigo).</description>
    <link>https://dev.to/gabrieltrigo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1027182%2F6b0068f8-2948-4a66-8c58-106783870799.png</url>
      <title>DEV Community: Gabriel Trigo</title>
      <link>https://dev.to/gabrieltrigo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gabrieltrigo"/>
    <language>en</language>
    <item>
      <title>Introduction to TSWebDriver4Delphi: Web Browser Automation in Delphi</title>
      <dc:creator>Gabriel Trigo</dc:creator>
      <pubDate>Thu, 01 Feb 2024 21:11:10 +0000</pubDate>
      <link>https://dev.to/gabrieltrigo/introduction-to-tswebdriver4delphi-web-browser-automation-in-delphi-p7i</link>
      <guid>https://dev.to/gabrieltrigo/introduction-to-tswebdriver4delphi-web-browser-automation-in-delphi-p7i</guid>
      <description>&lt;h2&gt;
  
  
  What is TSWebDriver4Delphi?
&lt;/h2&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://github.com/GabrielTrigo/TSWebDriver4Delphi" rel="noopener noreferrer"&gt;TSWebDriver4Delphi&lt;/a&gt; is a project that encapsulates a variety of tools enabling web browser automation. It specifically provides an infrastructure for the &lt;a href="https://www.w3.org/TR/webdriver2" rel="noopener noreferrer"&gt;W3C WebDriver&lt;/a&gt; specification. Following a similar approach to Selenium, TSWebDriver4Delphi allows automation of interactions with user interface elements, making tests more efficient and reliable.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;iframe src="https://player.vimeo.com/video/908480520" width="710" height="399"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;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 &lt;a href="https://www.selenium.dev/" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; with Python, &lt;a href="https://pptr.dev" rel="noopener noreferrer"&gt;Puppeteer&lt;/a&gt; in Node.JS, and &lt;a href="https://playwright.dev/dotnet" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt; in C#, the question arose: what about Delphi?&lt;br&gt;
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.&lt;br&gt;
In light of this scenario, I developed this tool in Delphi to streamline my work. Today, I share it with you.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Some features include:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Web Navigation&lt;/li&gt;
&lt;li&gt;Element Location&lt;/li&gt;
&lt;li&gt;Form Filling&lt;/li&gt;
&lt;li&gt;Screenshots Capture&lt;/li&gt;
&lt;li&gt;Waits&lt;/li&gt;
&lt;li&gt;Headless Mode Execution&lt;/li&gt;
&lt;li&gt;Handling Alerts and Pop-ups

&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Example of Use: Login Automation in the Chrome Browser
&lt;/h3&gt;

&lt;p&gt;Let's take a look at a basic example using &lt;a href="https://github.com/GabrielTrigo/TSWebDriver4Delphi" rel="noopener noreferrer"&gt;TSWebDriver4Delphi&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight pascal"&gt;&lt;code&gt;&lt;span class="k"&gt;uses&lt;/span&gt;
  &lt;span class="n"&gt;TSWebDriver&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TSWebDriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IBrowser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TSWebDriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IElement&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;var&lt;/span&gt;
  &lt;span class="n"&gt;ChromeWebDriver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ITSWebDriverBrowser&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;begin&lt;/span&gt;
  &lt;span class="n"&gt;ChromeWebDriver&lt;/span&gt; &lt;span class="p"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;TTSWebDriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;Driver&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;Browser&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;Chrome&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="n"&gt;ChromeWebDriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewSession&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="n"&gt;ChromeWebDriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NavigateTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'https://www.saucedemo.com'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;ChromeWebDriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WaitForPageReady&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="n"&gt;ChromeWebDriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FindElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;FBy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'user-name'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;SendKeys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'standard_user'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="n"&gt;ChromeWebDriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FindElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;FBy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'password'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;SendKeys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'secret_sauce'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="n"&gt;ChromeWebDriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FindElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FBy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'login-button'&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="n"&gt;Click&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="n"&gt;ChromeWebDriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CloseSession&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h3&gt;
  
  
  Run JavaScript:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight pascal"&gt;&lt;code&gt;&lt;span class="n"&gt;ChromeWebDriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ExecuteSyncScript&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'return document.title'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h3&gt;
  
  
  ⚠️ Warning: Alpha Stage
&lt;/h3&gt;

&lt;p&gt;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!&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Contribute and Get More Information:
&lt;/h3&gt;

&lt;p&gt;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 &lt;a href="https://github.com/GabrielTrigo/TSWebDriver4Delphi" rel="noopener noreferrer"&gt;TSWebDriver4Delphi&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;&lt;br&gt;
I am excited to see how TSWebDriver4Delphi can benefit our web testing automation efforts in the Delphi world. Let's build something amazing together! 🚀🔧&lt;/p&gt;

</description>
      <category>delphi</category>
      <category>webscraping</category>
      <category>automation</category>
      <category>webautomation</category>
    </item>
  </channel>
</rss>
