Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Handle Web Drivers with Event Firing Web Driver
2.1.
Use Web Driver Event Listeners
2.2.
Use Remote Web Driver
3.
Frequently Asked Questions
3.1.
Does Katalon use Web Driver?
3.2.
How to change the font size in Katalon Studio?
3.3.
What is Katalon Studio?
4.
Conclusion
Last Updated: Jun 28, 2024

Handle WebDrivers with EventFiringWebDriver in Katalon Studio

Introduction

Let's ensure we understand the foundational concepts before delving further into the subjects. Here is a brief introduction if you are unfamiliar with Katalon Studio.

Handle WebDrivers with EventFiringWebDriver in Katalon Studio

          

Katalon Studio is a tool that is developed by KM technology. It will also help you automate Web Based Applications, Mobile Applications, and API Testing. It increases the speed of delivery and time to market. Our organisation has become better.

This product's recording feature is helpful for our testing needs. User-friendliness and AI smart healing capabilities are two of Its most valuable features.        

This article explains how to handle Web drivers with the support of Event firing Web driver in katalon studio. 

Without further ado, let's get started.

Handle Web Drivers with Event Firing Web Driver

This can be used, for instance, to log operations or to set off specific events before them.

📜 Suppose you want to learn more about this class. You can go through the Selenium documentation.

💁 Note: With Katalon Studio version 7.0.0, you can set event-driven features related to your WebDrivers for test execution by using the Selenium-based class Event Firing Web Driver.

Use Web Driver Event Listeners

The Web Driver Event Listener is a tool you can use to handle events the Web Driver starts, such as those that occur before or after clicking or before or after navigating. Web Driver Event Listeners is an interface to receive events from the Web Driver, whereas EventFiringWebDriver is a class that wraps around the WebDriver to fling events.
 

📜 Suppose you want to learn more about this class. You can go through the Selenium documentation here: Web Driver Event Listener.

📲 The use of a custom Web Driver Event Listener is shown below:

1️⃣ Create a package with a keyword in it. Click File > New > Package to start. Here, the package's name is customkeyword.

Step image

 

2️⃣ To manage WebDriver events, add a new keyword.

a. Select File > New > Keywords. New dialogue box appears.

b. For your keyword, click Browse to select a package, then type the class name by hand. In this case, we select the package we built in Step 1 and give the keyword the name MyCustomWebEventListener. Press OK. A brand-new keyword page loads.

c. Insert the sample code from below into the newly formed keyword.

import org.openqa.selenium.WebDriver
import org.openqa.selenium.support.events.AbstractWebDriverEventListener
public class MyCustomWebEventListener extends AbstractWebDriverEventListener {
    @Override
    public void beforeNavigateTo(String url, WebDriver driver) {
        println "Before navigating to " + url;
    }
}
Step image

 

3️⃣ Open the test script. Copy the sample code below, and then paste it to register MyCustomWebEventListener with WebDriver:

import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.support.events.EventFiringWebDriver as EventFiringWebDriver
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import customlistener.MyCustomWebEventListener as MyCustomWebEventListener
WebUI.openBrowser('')
WebDriver webdriver = DriverFactory.getWebDriver()
EventFiringWebDriver eventFiring = ((webdriver) as EventFiringWebDriver)
eventFiring.register(new MyCustomWebEventListener())
DriverFactory.changeWebDriver(eventFiring)
WebUI.navigateToUrl('www.google.com')
WebUI.closeBrowser()

 

4️⃣ Press Run, then check the Console log to see the outcome.

Use Remote Web Driver

There are two parts that make up a remote WebDriver: a client and a server. The server is just a Java servlet, which can be hosted on any contemporary JEE app server. The client is your WebDriver test.The main difference is that a remote WebDriver needs to be set up in order for it to execute your tests on a different computer.

📜 Since Event Firing Web Driver does not implement the Remote Web Driver interface, you must take the following steps in order to obtain a Remote Web Driver instance safely:

....
// Cast Katalon's WebDriver into EventFiringWebDriver
EventFiringWebDriver eventFiring = (EventFiringWebDriver) DriverFactory.getWebDriver()
// Get the driver wrapped inside
WebDriver wrappedWebDriver = eventFiring.getWrappedDriver()
// Cast the wrapped driver into RemoteWebDriver
RemoteWebDriver katalonWebDriver = (RemoteWebDriver) wrappedWebDriver
// Katalon now uses RemoteWebDriver instead of your local driver

                           

Frequently Asked Questions

Does Katalon use Web Driver?

The Selenium engine is used by Katalon Studio to automate web application testing. This indicates that Katalon makes use of the Selenium Web Driver technology while shielding consumers from the challenges of using Web Driver. 

How to change the font size in Katalon Studio?

For Katalon Studio: Access Colors and Fonts by going to Window> Preferences > General > Appearance. Choose Dialog Font, then change the font size. Activation dialogue first appears after the app has launched. To activate your licence, log into your account.

What is Katalon Studio?

It is a tool that is developed by KM technology. It will help you to automate Web Based Applications, Mobile Applications, and API Testing as well. 

Conclusion

Congratulations on finishing the blog! We have discussed how to handle Web drivers with the support of Event firing Web driver in katalon studio, in which we talk about the use of Us Web Driver Event Listeners and the Use of Remote Web Driver.

We hope this blog has helped you enhance your knowledge of Handle Web Drivers with Event Firing Web Drivers in Katalon Studio. If you'd like to learn more, Check out the following links:

🔥 Sample API Test Projects in Katalon

🔥 Library Management in Katalon Studio

🔥Ready API

Please refer to our guided pathways on Code studio to learn more about DSACompetitive ProgrammingJavaScriptSystem Design, etc. Enroll in our courses, and use the accessible sample exams and questions as a guide. For placement preparations, look at the interview experiences and interview package.

Please up vote 🏆 our blogs if you find them helpful and informative!

Happy coding🤗

Live masterclass