TYCS Manual STQA

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

TYCS Manual STQA (USCSP5032)

1) Install Selenium IDE and create a test suite containing a minimum of 4 test cases for different
web page formats (e.g., HTML, XML, JSON, etc.).

2) Conduct a test suite for two different websites using Selenium IDE. Perform various actions
like clicking links, filling forms, and verifying content.

3) Install Selenium Server (Selenium RC) and demonstrate its usage by executing a script in Java
or PHP to automate browser actions.

4 )Write a program using Selenium WebDriver to automate the login process on a specific web
page. Verify successful login with appropriate assertions.

5) Write a program using Selenium WebDriver to update 10 student records in an Excel file.
Perform data manipulation and verification.

6) Write a program using Selenium WebDriver to select the number of students who have
scored more than 60 in any one subject (or all subjects). Perform data extraction and analysis.

7) Write a program using Selenium WebDriver to provide the total number of objects present or
available on a web page. Perform object identification and counting.

8) Write a program using Selenium WebDriver to get the number of items in a list or combo box
on a web page. Perform element identification and counting.

9 )Write a program using Selenium WebDriver to count the number of checkboxes on a web
page, including checked and unchecked counts. Perform checkbox identification and counting.

10) Perform load testing on a web application using JMeter. Generate and analyze load
scenarios. Additionally, explore bug tracking using Bugzilla as a tool for logging and tracking
software defects.
Practical no.1
Aim:- Install Selenium IDE and create a test suite containing a minimum of 4 test cases for
different web page formats (e.g., HTML, XML, JSON, etc.).

What is Selenium?
Selenium is an open-source suite of tools and libraries that is used for browser automation.
Selenium us used to:

 It allows users to test their websites functionally on different browsers.


 Perform Cross browser testing to check if the website functions consistently across
different browsers.

It provides a single interface that lets you write test scripts in programming languages like Ruby,
Java, NodeJS, PHP, Perl, Python, JavaScript, and C#, among others. Selenium is very extensible
and can be integrated with other tools and frameworks like TestNG, JUnit, Cucumber, etc.

Importance of Testing in Selenium


Manual testing can be time-consuming and prone to human errors. Selenium Automation allows
tests to be executed quickly and accurately, reducing the likelihood of human mistakes and
ensuring consistent test results.

Selenium allows developers and testers to automate the testing of web applications across
different browsers and platforms.

1. Language Support: Selenium allows you to create test scripts in different languages
like Ruby, Java, PHP, Perl, Python, JavaScript, and C#, among others.

2. Browser Support: Selenium enables you to test your website on different browsers such
as Google Chrome, Mozilla Firefox, Microsoft Edge, Safari, Internet Explorer (IE), etc.

3. Scalability: Automated testing with Selenium can easily scale to cover a wide range of test
cases, scenarios, and user interactions. This scalability ensures maximum test coverage of the
application’s functionality.

4. Reusable Test Scripts: Selenium allows testers to create reusable test scripts that can be
used across different test cases and projects. This reusability saves time and effort in test
script creation and maintenance.

5. Parallel Testing: Selenium supports parallel test execution, allowing multiple tests to run
concurrently. This helps reduce the overall testing time, making the development process
more efficient.
6. Documentation and Reporting: Selenium provides detailed test execution logs and reports,
making it easier to track test results and identify areas that require attention.

7. User Experience Testing: Selenium can simulate user interactions and behavior, allowing
testers to assess the user experience and ensure that the application is intuitive and user-
friendly.

8. Continuous Integration and Continuous Deployment (CI/CD): Selenium can be


integrated into CI/CD pipelines to automate the testing of each code change. This integration
helps identify and address issues earlier in the development cycle, allowing for faster and
more reliable releases.

Components of Selenium

Selenium Suite has 4 components namely:

1. Selenium IDE

2. Selenium RC

3. Selenium WebDriver

4. Selenium Grid

Selenium IDE

Steps to perfom:-

o Launch Firefox browser.


o Click on the Selenium icon present on the top right corner on your browser.
o It will launch the default interface of Selenium IDE.
o Enter the project name as "Manual Test".
o Enter the test case name as "Search Test".
o Click on the command text box present on the Test Script Editor Box.

o Modify the properties of First command as:

o Command : open
o Target : https://www.google.co.in
o During execution of the test case, this command will load the Google search engine web
page on your Firefox browser

Features of Selenium IDE

There are several features provided in the IDE under the toolbar, using which one can control the
execution of test cases

1. Speed Control – Helps control the speed of test cases


2. Run All – Allows execution of the entire Test Suite
3. Run – Runs the currently selected test
4. Pause/Resume – Allows a user to pause and resume a particular test case
5. Step – Helps step into each specific command in the test script
6. Rollup – Helps group all the Selenese Commands together and make them execute as a
single operation
The features keep on getting eliminated or added depending on the usage of different versions of
Selenium IDE extensions.
Practical no.2
Aim:- Conduct a test suite for two different websites using Selenium IDE. Perform various
actions like clicking links, filling forms, and verifying content.

It is used to test the two different websites using Selenium IDE and we observe the clicking and
filling form and verifying the content

E-commerce websites are the most complex and intricate websites out there. This is due to their
navigation, product categorization, preview functionalities, and key features like payment
gateway integrations.
So it is non-negotiable while developing eCommerce websites to undergo rigorous testing,
ensuring all the functionalities work together in harmony without affecting the user experience.

Now that we have the different types of testing applicable, it’s time to delve into the sample test
cases for ecommerce website. To create practical test cases for ecommerce website, one must
understand the structure of a typical site.
There are many features in an eCommerce website – hero carousel/slider, search, filter, product
details, payments, checkout, etc. each having a pre-defined functionality.
For example, Every search bar should show relevant results, i.e., searching for electronics should
show all categories like mobiles, TVs, cameras, etc.
General Test Cases

 The user should be able to navigate to all the pages in the website
 There should be a fallback page for any page load errors
 Verify that all the links and banners work properly
 Search results should be displayed with the most relevant item being shown first
 All data related to the product – title, price, images, and description are all visible clearly
 Maintain a session for each user and test verify the session times out after a while
Practical no.3

Aim:- Write a program using Selenium WebDriver to automate the login process on a specific
web page. Verify successful login with appropriate assertions.

Login Automation using Selenium Webdriver

 Download and Install JDK(Java Development Kit)


 Install Eclipse from the official website
 Download the Selenium Java Client version
 Configure the drivers depending on the browser. The example here will be using a chrome driver
for Chrome

Steps for Login Automation using Selenium WebDriver


Before performing automation testing for the login functionality, there are a couple of basic steps
that need to be followed for the test case to be written:

1. Create a Selenium WebDriver instance


2. Configure browser if required
3. Navigate to the required web page
4. Locate the relevant web element
5. Perform action on the web element
6. Verify and validate the action
Now let’s walk through each of these steps in detail.
1. Create a Selenium WebDriver instance
To launch the website in the desired browser, set the system properties to the path of the driver
for the required browser. This example will use ChromeDriver for Login Automation using
Selenium Webdriver. The syntax for the same will be:
Webdriver driver = new ChromeDriver();

System.setProperty("webdriver.chrome.driver", "Path of the chrome driver");


2. Configure the Web browser
Usually, the web page will be in a minimized format when the test case is run. Maximize the
browser for a clear picture of the test cases executed. Use the command below to do the same:
driver.manage.window.maximize();

3. Navigate to the web URL


Open the browser with the desired URL. Use the command below to open the URL in the desired
instantiated browser:
driver.get("https://www.browserstack.com/users/sign_in");

4. Locating the Web Element


Locators are an essential part of every Selenium script as they identify the elements that the test
script will interact with to replicate user actions.
Practical No.4
Aim:-Write a program using Selenium WebDriver to provide the total number of objects present
or available on a web page. Perform object identification and counting.

The total number of links in a page can be counted with the help of findElements() method. The
logic is to return a list of web elements with tag name anchor, then getting the size of that list.

Count Total Number of Web Elements in a Page

To count the total number of web elements in the web page using Selenium for Java, find
elements using XPath with expression to match any web
element. driver.findElements(By.xpath("//*")) returns a list containing all the web elements
present in the web page. Call size() on this list, and it returns the number of elements in the web
page.
The following is a simple code snippet to get the total number of elements in the web page.

List<WebElement> elements = driver.findElements(By.xpath("//*"));

int elementsCount = elements.size();

To address the issue of counting elements in a dynamic list, there are two solutions to consider.

involves using WebDriverWait and ExpectedConditions based on your code trials.

Alternatively, suggests creating a list of elements in your table by selecting a row with

the appropriate selector, and then using the FindElements() method in Selenium to

return a List of web elements. The xpath of the first form element in the HTML should be used as
Valid_Xpath.Count number of a class objects created in Java, The idea is to use static member in

the class to count objects. A static member is shared by all objects of the class, all static data is

initialized to zero when the first object is created if no other initialization is present,

And constructor and static member function can only access static data member
Practical no 5
Write a program using Selenium WebDriver to update 10 student records in an Excel file.
Perform data manipulation and verification.

Selenium is a widely-used open-source testing framework for web applications. It


offers a practical method for automating web browsers and carrying out numerous
testing activities. In Selenium test automation, knowing how to read data from Excel
in Selenium is a regular requirement. Apache POI (Poor Obfuscation Implementation)
is a popular Java API that provides support for reading and writing Microsoft Office
file formats, including Excel.

What is Apache POI?

Apache POI (Poor Obfuscation Implementation) is a powerful Java API developed by the
Apache Software Foundation. It offers assistance with Excel, Word, and PowerPoint file types as
well as reading, writing, and editing other Microsoft Office file formats. To generate, alter, and
extract data from Office documents, Java developers can use Apache POI to communicate
programmatically with various file formats.
Since working with Excel files is Apache POI's primary goal, it is a popular option for data-
driven testing in automation frameworks like Selenium. It gives developers access to a wide
range of classes and interfaces that abstract away the underlying file formats and lets them
manipulate Excel workbooks, worksheets, rows, and cells in a variety of ways.

Create an Instance of the Workbook Class and Create a New Excel File.

Code

Workbook workbook = new XSSFWorkbook();


Sheet sheet = workbook.createSheet("Sheet1");

Explanation In this step, you create a new instance of the Workbook class, specifically
the XSSFWorkbook implementation for .xlsx files. This creates a new in-memory workbook
object. Then, you create a new sheet within the workbook using the createSheet() method and
provide a name for the sheet, such as Sheet1.

2. Create Rows and Cells and Write the Data.

Code

Row row = sheet.createRow(0);


cell.setCellValue("Hello, World!");

Explanation Here, you create a Row object within the sheet using the createRow() method,
passing the row index as the parameter. In this example, we create a row at index 0. Then, you
create a Cell object within the row using the createCell() method and pass the cell index as the
parameter.

In this case, we create a cell at index 0 of the row. Finally, you set the cell value using
the setCellValue() method. You can provide any desired value, such as Hello, World!.

3. Create a File Output Stream and Write the Workbook Data to a File.

Code

FileOutputStream file = new FileOutputStream("path/to/excel/file.xlsx");


workbook.write(file);

Explanation In this step, you create a FileOutputStream object to specify the file where you
want to write the data. You provide the file path as a parameter. Then, you use
the write() method of the Workbook class to write the workbook data to the file specified by
the FileOutputStream object.

4. Close the Workbook and File Output Stream.

Code

workbook.close();
file.close();

Explanation Finally, after writing the data, you need to close the workbook and the
FileOutputStream to release system resources.

Remember to handle exceptions and perform appropriate error handling as necessary. You can
add try-catch blocks to handle IOExceptions that may occur during file operations.

By following these steps, you can successfully write data to an Excel file in Selenium using
Apache POI. This can be useful for scenarios such as populating test data, generating reports, or
creating data-driven test cases in your automation scripts.

You might also like