0% found this document useful (0 votes)
2 views

Lesson 9

The document provides a comprehensive overview of test automation, including its advantages, disadvantages, and various tools such as Selenium and RestAssured. It discusses the differences between manual and automated testing, the integration of automation tools with CI/CD pipelines, and outlines the test automation process and frameworks. Additionally, it highlights specific tools for API testing and their comparisons, along with challenges faced in test automation.

Uploaded by

mythemyaseen6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lesson 9

The document provides a comprehensive overview of test automation, including its advantages, disadvantages, and various tools such as Selenium and RestAssured. It discusses the differences between manual and automated testing, the integration of automation tools with CI/CD pipelines, and outlines the test automation process and frameworks. Additionally, it highlights specific tools for API testing and their comparisons, along with challenges faced in test automation.

Uploaded by

mythemyaseen6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 69

Test Automation

paramtech.com.tr
©2024. Tüm hakları saklıdır.
Contents

1 Introduction to Test Automation

2 RestAssured and API Automation

3 Introduction to Selenium

4 Selenium Components
1 - Introduction to Test Automation
1- Introduction to Test Automation

01 Test Automation

Test automation involves using automated tools to perform tests that check the functionality of
software applications. This approach saves time and reduces human errors.

Differences between manual testing and automation testing:


Criterion Manual Testing Automation Testing
Method Done manually. Done with tools.

Time Takes more time. Faster.

Flexible, can test anything. Only suitable for test cases


Flexibility
that can be automated.

Error Risk Higher risk of human error. Lower risk of human error.
1
1- Introduction to Test Automation

01 Why Use Test Automation?

Reasons for using test automation:

● Time Saving: Tests are executed quickly and can be repeated.


● Reduced Human Error: Human error risk is reduced.
● Large Test Sets: Large tests can be executed quickly.
● Early Bug Detection: Bugs are detected early.
● CI/CD Support: Can be integrated into continuous integration
pipelines.
● Long-Term Savings: Initial investment but saves cost over time.

1
1- Introduction to Test Automation

01 Advantages and Disadvantages of Test


Automation

Advantages Disadvantages
Fast Test Execution: Tests are executed quickly. High Initial Cost: Requires investment in
tools and software development.

Reduced Human Error: Human errors are Ongoing Maintenance Needed: Tests and
minimized. tools require maintenance over time.

Time Saving: Saves time, especially for large test Only for Repetitive Tests: Automation
sets. may not cover all types of tests.

Early Bug Detection: Bugs are detected earlier Incompatibility with Software Changes:
in the development process. Changes in the software may invalidate
automation tests.

Continuous Testing: Can be integrated into Limited Complexity of Tests: Automation


CI/CD pipelines for continuous testing. may struggle with highly complex tests.

1
1- Introduction to Test Automation

01 Main Tools Used for Test


Automation

Selenium: A widely used open-source tool for testing web applications. It supports multiple
programming languages (Java, Python, C#, etc.).

Cypress: A modern tool for testing web applications, especially designed for JavaScript-based web
applications, offering fast and efficient testing.

Playwright: A powerful test automation tool for web applications. It supports multiple browsers
and is used for testing modern web applications.

Appium: An open-source automation testing tool for mobile applications on both Android and iOS
platforms.

Espresso: A test automation tool for Android applications developed by Google. It is specifically
designed for Android UI testing.
1
1- Introduction to Test Automation

01 Main Tools Used for Test


Automation

RestAssured: A Java-based library used to test REST APIs. It is commonly used for API validation
tests.

Karate: A tool for testing APIs, supporting both RESTful and SOAP APIs. It uses Gherkin syntax for
writing tests.

TestNG: A testing framework similar to JUnit, but with more advanced features like parallel test
execution.

Postman: A popular tool for API testing, especially for validating RESTful APIs.

1
1- Introduction to Test Automation

01 Integration with Continuous


Integration Tools

Jenkins: An open-source continuous integration (CI) and continuous delivery (CD) tool that facilitates the
automated testing and deployment of software projects.

GitHub Actions: A tool that integrates directly with GitHub to automate continuous integration and
continuous delivery workflows, triggering actions based on changes made in the GitHub repository.

GitLab CI/CD: A continuous integration and continuous delivery platform that integrates with GitLab,
automating tests and deployments throughout the software development lifecycle.

Azure Pipeline: A CI/CD tool that runs on the Microsoft Azure platform, automating the build, test, and
deployment processes for projects hosted on Azure, GitHub, or other repositories.

1
1- Introduction to Test Automation

01 Report Tools

Allure Report:

Allure is a tool that generates stylish, interactive test reports with detailed visuals, including test
steps, screenshots, and success/failure statuses.

Extent Reports:

Extent Reports is a comprehensive HTML reporting tool that visualizes test results with rich details,
such as success rates, failure logs, and screenshots, often used with Selenium and Appium.

1
1- Introduction to Test Automation

01 Challenges in Test Automation

● Choosing the right tool.


● Inability to create accurate test scenarios.
● Testing dynamic or changing content (e.g., changes in UI elements).
● Time and resource limitations.

1
1- Introduction to Test Automation

01 Test Automation Process

● Defining the test strategy.


● Preparing test scenarios.
● Choosing the test automation framework (Data-Driven, Keyword-Driven, Hybrid
Framework).
● Configuring the test environment.
● Writing test scripts.
● Executing tests and reporting results.

1
1- Introduction to Test Automation

01 Test Automation Framework

● Data-Driven Framework

A Data-Driven Framework is a test automation framework where test data is separated


from the test script logic. Test scripts fetch data from external sources like Excel, CSV,
databases, or JSON files, allowing the same script to be executed with multiple data sets.
Key Features:

● Separation of test data and test logic.


● Enables testing with multiple data sets.
● Reduces duplication of test scripts for different input values.

1
1- Introduction to Test Automation

01 Test Automation Framework

● Keyword-Driven Framework

A Keyword-Driven Framework uses keywords to represent actions. Testers write tests by


defining sequences of keywords rather than coding directly. Each keyword corresponds
to a method that performs a specific action.
Key Features:

● Actions (keywords) like "Click," "Input," "Verify" are predefined.


● Test scripts are written in simple files like Excel, with keywords and corresponding
data.
● Easy for non-programmers to write tests.

1
1- Introduction to Test Automation

01 Test Automation Framework

● Hybrid Framework

A Hybrid Framework combines the advantages of both Data-Driven and Keyword-Driven


frameworks. It allows the use of both test data and keywords, making the framework highly
flexible.

Key Features:

● Combines test data and keyword-driven functionalities.


● Highly scalable and modular.
● Preferred for large and complex test suites.

1
1- Introduction to Test Automation

01 Page Object Model

Page Object Model (POM) is a design pattern in test automation. Each page of the application is
represented as a class, and this class contains the page elements and methods used to interact with
those elements.

Advantages:

● Ease of Maintenance: When the UI changes, only the corresponding class needs to be updated.
● Reusability: The same page objects can be reused across different test cases.
● Less Code Duplication: Code becomes modular, following the DRY principle.
● Readability: Test scripts are cleaner and more understandable.

Structure:

● Page Class: Contains page elements and related methods.


● Example: LoginPage.java
● Test Class: Contains the test scenarios.
● Example: LoginTest.java
1
2 - RestAssured and API Automation
2 - RestAssured and API Automation

02 Rest Assured

Rest Assured is a Java-based framework used for testing RESTful web services. It allows you to easily make
HTTP requests and validate responses with a simple API. It is an ideal tool for automation testing, particularly
to verify the functionality and accuracy of an API.

Why Use Rest Assured?

● Ease of Use: It allows testing of RESTful APIs with minimal code writing.
● Java-Based: It integrates well with popular Java test frameworks like JUnit or TestNG.
● Versatility: It can work with both JSON and XML-based data.
● Validation: It provides built-in methods to easily validate HTTP responses and data.
● CI/CD Integration: It can be integrated with tools like Jenkins to automate API testing.

2
2 - RestAssured and API Automation

02 Rest Assured vs Postman

Feature Postman RestAssured

User Interface GUI-based with no coding required Code-based, Java library for automation

Scripting Capabilities JavaScript scripting for testing Java-based, offers full programming flexibility

Manual Testing Ideal for manuel testing Primarily focused on automated testing

Integration It integrates with CI/CD tools It can be integrated into CI/CD pipelines
(Jenkins, GitHub Actions) and through the CLI (Newman) but offers limited
testing frameworks (JUnit, TestNG). flexibility.

Complex Testing Suitable for basic to intermediate Provides advanced options for handling
Scenarios scenarios complex scenarios

Reporting Comprehensive reporting can be Basic reporting can be done using collection
done using frameworks like reports and CLI (Newman).
JUnit/TestNG.

2
2 - RestAssured and API Automation

02 When to Use Which Tool?

Feature Rest Assured Postman

When performing manual It is not suitable for manual Ideal for manual testing.
testing testing.

When writing automated Suitable for complex and Can be used for simple
test scenarios automation-focused automation scenarios.
scenarios.

When CI/CD integration is Provides strong and flexible Can be integrated via CLI
required CI/CD integration. but is less flexible.

2
2 - RestAssured and API Automation

02 Rest Assured Advantages


and Disadvantages

Advantages Disadvantages

Readable Code: Its simple and understandable Java Dependency: It can only be used in Java-based
syntax makes it user-friendly. projects, not suitable for other languages.

Wide Format Support: Easily works with data Lack of GUI: It does not offer a user-friendly
formats like JSONPath and XMLPath. graphical interface; it works entirely through code.

Integration: Being Java-based, it easily integrates Learning Curve: Learning Java and API testing
with popular frameworks like JUnit, TestNG, and concepts can take time for beginners..
Maven

Validation and Reporting: It provides powerful tools Limited Features: Rest Assured is focused only on
for validating HTTP response codes, response times, HTTP-based API testing, offering limited support for
and JSON/XML. other types of protocols or APIs.

2
2 - RestAssured and API Automation

02 HTTP METHODS - GET

EXAMPLE :

Summary:

This code sends a GET request using Rest Assured,


validates that the response status code is 200
(successful), and prints the body of the response to
the console. This is a simple test scenario to check
whether the API is working correctly.

2
2 - RestAssured and API Automation

02 HTTP METHODS - GET

> @Test

● This is an annotation used in test frameworks


like JUnit or TestNG. It indicates that the
method is a test method and can be executed
by the test framework

> RestAssured.baseURI

● This line sets the base URL for Rest Assured. It


defines the root URL for all API requests. In this
example, all API requests will be made to the
address https://demoqa.com.

2
2 - RestAssured and API Automation

02 HTTP METHODS - GET

> HTTP Response response = given()

● given(): This is the method used to start


building the API request. It is where we define
the parameters needed for the API request.
● Response response: This is a variable used to
store the HTTP response. We will capture the
response from the API in this variable.

2
2 - RestAssured and API Automation

02 HTTP METHODS - GET

> header("Content-Type", "application/json")

● The header() method adds headers to the HTTP


request. In this case, the Content-Type header is
set to application/json, indicating that the data
being sent to the API is in JSON format.

> when()

● The when() method specifies which HTTP


operation will be performed. After this method,
we will define a GET request.

2
2 - RestAssured and API Automation

02 HTTP METHODS - GET

> then()

● This method is used to perform assertions or


validations after the request has been made.
We will use this to validate the response from
the API.

> statusCode(200)

● This line asserts that the API response should


return an HTTP 200 OK status code, meaning
the request was successful.

2
2 - RestAssured and API Automation

02 HTTP METHODS - GET

> extract()

● This method is used to extract data from the


response. It allows you to capture specific parts
of the response.

> response()

● This method returns the response obtained


from the previous extract() step as a Response
object. This object allows us to access more
details about the response (such as body,
headers, status code, etc.).

2
2 - RestAssured and API Automation

02 HTTP METHODS - GET


Response Example

The response returned


when the scenario is
executed:

2
2 - RestAssured and API Automation

02 HTTP METHODS - POST

> JSONObject

● A class used to construct JSON objects. Here, it


helps in creating the request body in JSON
format.

> Creating the Request Body (JSON Body)

● A JSONObject is created to construct the


request body.
● The put() method is used to add key-value pairs
to the JSON object

2
2 - RestAssured and API Automation

02 HTTP METHODS - POST

> Creating a Nested JSON Object

● A nested JSON object (bookingDates) is created for the


check-in and check-out dates.
● put() method is used to add "checkin" and "checkout"
fields.

> Adding the Nested JSON to the Main JSON Object

● The bookingDates nested object is added to the main


requestBody object.
● Additionally, a key "additionalneeds" is added with the
value "Breakfast".

> post()

● Sends the POST request to the /booking endpoint


2
2 - RestAssured and API Automation

02 HTTP METHODS - POST


Response Example

The response returned


when the scenario is
executed:

2
3 - Introduction to Selenium
3 - Introduction to Selenium

03 Selenium

Selenium is an open-source automation tool used for testing web


applications. It simulates user interactions by running tests on
different browsers. Selenium can be used with various
programming languages (Java, Python, C#, etc.) and supports
popular web browsers (Chrome, Firefox, Safari, etc.).

3
3 - Introduction to Selenium

03 Advantages and Disadvantages of Selenium

Advantages Disadvantages
Open-source and free to use Installation and setup process can be time-consuming.

Supports multiple programming languages (Java, Lacks a built-in reporting mechanism; requires integration
Python, C#, etc.). with third-party tools.

Compatible with multiple platforms (Windows, macOS, Does not provide direct support for visual validation (e.g.,
Linux). image-based testing).

Works with most browsers (Chrome, Firefox, Edge, Limited integration with mobile devices; additional tools like
Safari, etc.). Appium are needed.

Allows parallel test execution. Prone to errors caused by external factors like network
delays.

Has an active community and is constantly updated. Capturing dynamic web elements can be complex and
time-consuming.

3
4 - Selenium Components
4 - Selenium Components

04

4.1 Selenium WebDriver

4.2 Selenium Grid

4.3 Selenium IDE

4
4 - Selenium Components

04 Selenium WebDriver &


Supported Browsers
Selenium WebDriver is an automation tool used for testing web applications, directly interacting with browsers.
As a part of Selenium, WebDriver enables users to programmatically perform actions that can be done manually
in a browser, such as clicking, form filling, and scrolling.

Google Chrome Apple Safari


WebDriver: chromedriver WebDriver: Safari WebDriver
Support: The most popular browser with extensive Support: Enables test automation on macOS and iOS devices for
support through regular updates. Safari.

Mozilla Firefox Opera


WebDriver: geckodriver WebDriver: operadriver
Support: Compatible with both legacy and modern Support: Works with Chromium-based Opera versions.
versions of the browser.

Microsoft Edge Internet Explorer (IE)


WebDriver: msedgedriver WebDriver: IEDriverServer
Support: Fully supports Chromium-based Edge versions. Support: Still usable on legacy systems but has limited support in
Selenium 4. It is recommended to migrate to modern browsers.

4
4 - Selenium Components

04 Finding Selenium Web


Elements - ID

Find by ID: The fastest and most reliable method when elements have a unique ID attribute.

For Example:

4
4 - Selenium Components

04 Finding Selenium Web


Elements - Css Selector

Find by Css Selector: Locates elements using CSS rules.

For Example:

● #menu_load_money

● [id='menu_login']

● .btn-uyeol

4
4 - Selenium Components

04 Finding Selenium Web


Elements - XPath

Find by XPath: A powerful method for handling complex structures or


dynamic elements.

For Example:
Attribu
te
Name

Like input,
div, img value of
etc. the
attribute

XPath=//tagname[@Attrib
attribute
ute='value']

//a[@id='menu_login'] Select
attribute

tagname value
4
4 - Selenium Components

04 Finding Selenium Web


Elements - Other Types

Find by Name: driver.findElement(By.name("element_name"));


Allows finding elements by their "name" attribute.

Find by Class Name: driver.findElement(By.className("class_name"));


Finds elements using their CSS class name.

Find by Tagname: driver.findElement(By.tagName("tag_name"));


Useful for locating elements with a specific HTML tag, like <div> or <input>.

Finds elements using custom HTML attributes:


driver.findElement(By.cssSelector("[aria-label='example']"));
Finds elements using custom HTML attributes

4
4 - Selenium Components

04 Basic Selenium WebDriver Commands

● findElement(): Locates a specific web element on the page.

Usage: WebElement element = driver.findElement(By.id("element_id"));

● sendKeys(): Used to input text into a text field or input box.

Usage: element.sendKeys("your text");

● click(): Used to click on buttons or clickable elements.

Usage: element.click()

4
4 - Selenium Components

04 Basic Selenium WebDriver Commands

Example:

WebElement gsmNumber= driver.findElement(By.id("gsm"));

gsmNumber.sendKeys("55555");

WebElement password = driver.findElement(By.id("password"));

password .sendKeys("1234");

WebElement loginButton =
driver.findElement(By.id("loginButton"));

loginButton.click();
4
4 - Selenium Components

04 Basic Selenium WebDriver Commands

● getText(): Retrieves the visible text of an element.

Example: Getting the text of a button

WebElement loginButtonText = driver.findElement(By.id("menu_login"));

String buttonName = loginButtonText.getText();

4
4 - Selenium Components

04 Basic Selenium WebDriver Commands

● getAttribute(): Retrieves the value of a specific attribute of an element.

Example: Getting the value attribute of a button

WebElement buttonName = driver.findElement(By.id("menu_create_account"));

String buttonLink = buttonName.getAttribute("href");

4
4 - Selenium Components

04 Basic Selenium WebDriver Commands

● getTitle(): Gets the title of the current page.

Usage: driver.getTitle();

● getCurrentUrl(): Gets the current URL of the page.

Usage: driver.getCurrentUrl();

● isDisplayed(): Checks if an element is visible on the


page. visible but not enabled
Usage: element.isDisplayed();

● isEnabled(): Checks if an element is enabled (active).

element.isEnabled();
4
4 - Selenium Components

04 Basic Selenium WebDriver Commands

● clear(): Clears the existing text from an input field.

Usage: element.clear();

● isSelected(): Checks if an element is selected (used for checkboxes or radio buttons).

Usage: element.isSelected();

Example:

WebElement checkbox = driver.findElement(By.id("terms"));

if (checkbox.isSelected()) {System.out.println("Checkbox is selected");}

else {System.out.println("Checkbox is not selected");}

4
4 - Selenium Components

04 Basic Selenium WebDriver Commands


● navigate(): Used to navigate the browser.

> Navigate to a specific URL: driver.navigate().to("https://example.com");

> Navigate back: driver.navigate().back();

> Navigate forward: driver.navigate().forward();

> Refresh the page: driver.navigate().refresh();

● quit(): Closes all browser windows and ends the WebDriver session.

Usage: driver.quit();

● close(): Closes the currently focused browser window.

Usage: driver.close();
4
4 - Selenium Components

04 WebDriver Wait

When testing web applications, it’s essential to wait for dynamic elements to
load before interacting with them. Selenium provides three main types of
WebDriver Waits to handle such scenarios effectively:

1. Implicit Wait
2. Explicit Wait
3. Fluent Wait

4
4 - Selenium Components

04 WebDriver Wait - Implicit Wait

● Purpose: Tells WebDriver to wait for a specified amount of time for an


element to be present in the DOM before throwing an exception.
● How It Works:
● Applies globally to all element searches.
● Stops waiting as soon as the element is found.
● Advantages: Simple to implement; applies to all elements.

Usage:

driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));

// WebDriver waits up to 10 seconds for the element

WebElement element = driver.findElement(By.id("dynamicElement"));


4
4 - Selenium Components

04 WebDriver Wait - Explicit Wait Wait until the


element is
visible
● Purpose: Waits for a specific condition or
element to be available before
proceeding.
● How It Works: ● Usage:
● Conditions are defined using the
WebDriverWait wait = new
ExpectedConditions class.
WebDriverWait(driver,Duration.ofSecon
● Applies to specific elements or
ds(15));
scenarios.
● Advantages: Flexible and allows WebElement element =
targeting specific elements. Suitable for wait.until(ExpectedConditions.visibility
dynamic content. OfElementLocated(By.id("dynamicElem
ent")));

4
4 - Selenium Components

04 WebDriver Wait - Fluent Wait Set Fluent Wait


(30 seconds
timeout, polls
● Purpose: Waits for a condition to be met every 5 seconds)
with customizable polling intervals.
● How It Works: ● Usage:
● Checks for the element or condition
FluentWait<WebDriver> wait = new
at regular intervals. FluentWait<>(driver)
● Stops waiting when the condition is .withTimeout(Duration.ofSeconds(30))
met or the timeout is reached. .pollingEvery(Duration.ofSeconds(5));
● Advantages:
WebElement element = wait.until(new
○ Provides control over polling
Function<WebDriver, WebElement>() {
intervals.
○ Can ignore specific exceptions public WebElement apply(WebDriver driver) {
during polling. return
driver.findElement(By.id("dynamicElement")); }

4
4 - Selenium Components

04 WebDriverWait Comparison Table

Feature Implicit Wait Explicit Wait Fluent Wait

Scope Applies globally to all Applies to specific elements Applies to specific


element searches. or conditions. elements with polling.

Wait Time Fixed for all elements. Varies based on conditions. Fully customizable
timeout and polling.

Performanc May wait unnecessarily More efficient as it targets Efficient and precise for
e long. specific conditions. dynamic elements.

Best Use Static elements with Dynamic elements or Highly dynamic content
Cases predictable load times. conditions requiring with variable load times.
precision.

4
4 - Selenium Components

04 Integration with Test Frameworks

● Selenium + TestNG Integration

While Selenium is used to automate web applications, TestNG serves as a testing


framework for managing, organizing, and reporting tests. Together, these two
tools create a more powerful and flexible test automation framework.

The annotations provided by TestNG allow tests to run in a specific order or under
certain conditions. Here are the most commonly used TestNG annotations and
examples.

4
4 - Selenium Components

04
Example:
Integration with Test Frameworks
@Test(priority = 1)

● @Test: Defines a test method. TestNG public void testDashboard() {


automatically runs methods with the @Test System.out.println("Dashboard
annotation. test is running.");
Features: }
priority: Determines the execution order of tests. @Test(enabled = false)
enabled: Controls whether the test will be executed public void testSettings() {
or not.
System.out.println("Settings
test is skipped.");}

4
4 - Selenium Components

04 Integration with Test Frameworks

● @BeforeMethod: Defines code to run before each test method.

@BeforeMethod

public void setup() {System.out.println("Test scenario started.");}

● @AfterMethod: Defines code to run after each test method.

@AfterMethod

public void teardown() { System.out.println("Test scenario successfully completed.");}

4
4 - Selenium Components

04 Integration with Test Frameworks

● @BeforeClass: Runs once before all the tests in the class.

@BeforeClass

public void beforeClass() {

WebDriver driver = new ChromeDriver();

driver.manage().window().maximize();}

● @AfterClass: Runs once after all the tests in the class.

@AfterClass

public void afterClass() {driver.quit();}

4
4 - Selenium Components

04 Integration with Test Frameworks

● @BeforeSuite: Runs once before all tests in the test suite.

@BeforeSuite

public void beforeSuite() {System.out.println("Runs before all tests in the suite.");}

● @AfterSuite: Runs once after all the tests in the class.

@AfterSuite

public void afterSuite() { System.out.println("Runs after all tests in the suite.");}

4
4 - Selenium Components

04 Integration with Test Frameworks

Summary Table:
Annotation Purpose
@Test Defines a test method.

@BeforeMethod Executes before each test method.

@AfterMethod Executes after each test method.

@BeforeClass Executes once before all test methods in the class

@AfterClass Executes once after all test methods in the class.

@BeforeSuite Executes once before all tests in the suite.

@AfterSuite Executes once after all tests in the suite.


4
4 - Selenium Components

04 Selenium Grid

Selenium Grid is a tool that allows you to execute parallel tests on different browsers,
devices, and operating systems simultaneously. It enables distributed testing, reducing
execution time and testing compatibility across various environments.

Selenium Grid Use Cases

● Reducing test execution time with parallel testing.


● Performing cross-browser and cross-platform compatibility testing.
● Managing the entire test infrastructure from a central Hub.

4
4 - Selenium Components

04 Selenium Grid

Key Concepts of Selenium Grid

● Hub:
○ The central server of Selenium Grid.
○ Receives test commands and routes
them to the appropriate Node.
○ Only one Hub is required.
● Node:
○ Machines connected to the Hub.
○ Hosts browsers where the tests are
executed.
○ Multiple Nodes can be added.

4
4 - Selenium Components

04 Selenium Grid

How It Works

1. Communication with the Hub:


● The RemoteWebDriver sends test
commands to the Hub.
2. Node Selection:
● The Hub assigns the test to an
appropriate Node.
3. Test Execution:
● The Node launches the specified
browser and executes the test.

4
4 - Selenium Components

04 When Should I Use Selenium Grid?

1. When You Need Parallel Test Execution Example Scenario:


● Selenium Grid allows you to run multiple tests
Running over 100 test cases
simultaneously.
simultaneously on different
● It significantly reduces test execution time by
browsers.
running tests in parallel.

2. For Cross-Browser Testing

● To ensure your application works on various Example Scenario:


browsers (Chrome, Firefox, Safari, Edge, etc.) and
Verifying that your web
their versions.
application runs smoothly on
● Selenium Grid is ideal for testing compatibility
both Chrome and Firefox.
across different browsers.

4
4 - Selenium Components

04 When Should Use Selenium Grid?

3. For Cross-Platform Testing Example Scenario:

● To test your application on different operating Testing your application for


systems like Windows, macOS, and Linux. compatibility on both
● Grid allows you to set up Nodes on the required Windows and macOS.
platforms for testing.

4. When You Need Distributed Testing


Example Scenario:
● To execute tests across multiple physical or virtual
machines. Running tests on servers
● The Hub and Node architecture of Selenium Grid located in different
supports distributed test execution. geographic regions.

4
4 - Selenium Components

04 Selenium IDE

Selenium IDE is a test automation


tool in the Selenium ecosystem. It
works as a browser extension and
allows users to record and playback
test cases. It provides a simple,
user-friendly interface that doesn’t
require technical knowledge.

4
4 - Selenium Components

04 Selenium IDE

Key Features of Selenium IDE

1. Record and Playback:


● Automatically records user interactions in the browser.
● Recorded test cases can be replayed at any time.
2. Test Commands (Selenese):
● Selenium IDE uses "Selenese" commands to control test execution.
● Examples include open, click, type, and assert.
3. Platform Independent:
● Operates as a browser extension for popular browsers like Chrome and Firefox.
4. Test Export:
● Tests created in Selenium IDE can be exported as Java, Python, C#, or other Selenium
WebDriver scripts.

4
Useful Information

Example Contents:

https://github.com/nursensinc/RestAssuredExample
https://github.com/nursensinc/SeleniumExample

6
7

50
Java Selenium

Java (Windows - Mac - Linux)

https://www.java.com/tr/download/manual.jsp

Java SE Development Kit 17 (Windows - Mac - Linux)

https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html

IntelliJ IDEA Community Edition (2023.2.5)

https://www.jetbrains.com/idea/download/other.html
6
8
Visual : https://prnt.sc/Ic6Icmd4w6fm

51
THANK YOU
param.com.tr

You might also like