0% found this document useful (0 votes)
2 views14 pages

STQA 2 Ajy

This document outlines practical exercises for B.Tech. students in Computer Science and Engineering, focusing on using Selenium for web testing and Python for data management. It includes detailed steps for creating test suites, automating login processes, counting objects on web pages, and updating student records in Excel. The document emphasizes the advantages and disadvantages of using Selenium and Python, along with conclusions on enhancing testing efficiency and data management accuracy.

Uploaded by

work.jaythoriya
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 views14 pages

STQA 2 Ajy

This document outlines practical exercises for B.Tech. students in Computer Science and Engineering, focusing on using Selenium for web testing and Python for data management. It includes detailed steps for creating test suites, automating login processes, counting objects on web pages, and updating student records in Excel. The document emphasizes the advantages and disadvantages of using Selenium and Python, along with conclusions on enhancing testing efficiency and data management accuracy.

Uploaded by

work.jaythoriya
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/ 14

COMPUTER SCIENCE AND ENGINEERING

FACULTY OF ENGINEERING AND TECHNOLOGY


STQA (203105396) B.Tech. 7th SEM

Practical - 7
AIM: Using Selenium IDE, Write a test suite containing minimum 4 test cases
DESCRIPTION:

This experiment focuses on using Selenium IDE to automate web testing. The goal is to create a
test suite with at least four test cases, checking key functions like login and form submission. By
automating these, the experiment aims to catch bugs early and ensure reliable software
performance. The test suite will verify that the web app works as expected under different
conditions

TEST CASES:

1. Test Case: Login Functionality

• Objective: Verify that users can log in with valid credentials.


• Steps: Open login page > Enter valid username and password > Click 'Login.
• Expected Result: User is redirected to the dashboard.

2. Test Case: Invalid Login

• Objective: Check behavior with invalid login credentials.


• Steps: Open login page > Enter invalid username or password > Click 'Login'.
• Expected Result: Display an error message: "Invalid credentials".

3. Test Case: Form Submission

• Objective: Validate that a user can submit a form with all required fields.
• Steps: Navigate to form page > Fill in the required fields > Click 'Submit'.
• Expected Result: Confirmation message appears: "Form submitted successfully".

4. Test Case: Logout Functionality

• Objective: Verify that users can log out successfully.


• Steps: Log in > Click 'Logout' button.
• Expected Result: User is redirected to the login page.

ENROLLMENT NO: 210305124005 28


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

Steps to create a test suite with Selenium IDE:


• Install Selenium IDE
• Add Selenium IDE as a browser extension (available for Chrome and Firefox).

• Create a New Test Suite:


• Open Selenium IDE.
• Click on "Create a new project" and name the project.
• Create a new test suite by clicking the "Test Suites" tab and selecting "Add Test
Suite."

• Record Test Cases:


• Click on "Record a new test in the current project."
• Open the target web application in the browser and perform the desired steps (e.g.,
login, form submission, etc.).
• Selenium will record your actions and generate test steps automatically.

• Save and Organize Test Cases:


• Stop the recording once your actions are complete.
• Name and save the test case within the test suite. Repeat the process for at least four
test cases.

• Run the Test Suite:


• Once all test cases are recorded, click the "Run All" button to execute the test suite.
• Selenium IDE will run all test cases, and you can view the results in the log panel.

ADVANTAGES:
• User-Friendly: Selenium IDE offers a simple, record-and-playback feature, making it
accessible even to testers with minimal coding skills.
• Quick Test Creation: Tests can be created rapidly by recording user interactions with the
application.
• Open Source: Selenium IDE is free, making it a cost-effective option for automating web
testing.
• Cross-Browser Support: It can execute tests across different browsers like Chrome,
Firefox, etc., ensuring cross-browser compatibility.
• No Setup Required: Easy to install as a browser extension, it requires no complex setup
to start using.

ENROLLMENT NO: 210305124005 29


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

DISADVANTAGES:
• Limited to Web Applications: Selenium IDE can only test web applications and not
desktop or mobile applications.
• Maintenance Effort: Recorded test scripts can be fragile and require constant maintenance
if the web application's UI changes frequently.
• No Support for Complex Logic: It's less flexible for handling advanced logic, conditional
statements, or loops, compared to Selenium WebDriver.
• Not Ideal for Large Projects: For large, scalable projects, Selenium IDE can become
cumbersome as it lacks powerful features like custom programming and data-driven
testing.
• Limited Debugging Features: Debugging capabilities are more basic, making it difficult
to handle complex failures during test runs.

CONCLUSION:
In conclusion, automating the login process for a specific web page using Selenium provides a
powerful means of enhancing testing efficiency and accuracy in web applications. By simulating
user interactions, Selenium facilitates thorough validation of authentication mechanisms, ensuring
reliability in user experience. Despite the challenges of maintenance and potential performance
concerns, the benefits of cross-browser compatibility, open-source accessibility, and integration
with various programming languages make Selenium a valuable tool in the realm of software
testing. This endeavor not only strengthens understanding of automated testing practices but also
contributes to the overall quality assurance efforts in web development.

ENROLLMENT NO: 210305124005 30


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

Practical - 8
AIM: Install Selenium server and demonstrate it using a script in Java/PHP
DESCRIPTION:
This experiment involves installing the Selenium server to facilitate automated web testing using
Java or PHP. The primary objective is to set up the server environment that allows for the execution
of Selenium scripts, enabling interaction with web browsers for automated testing. The
demonstration includes writing a simple script to automate a web task, showcasing how Selenium
can be leveraged to enhance testing efficiency and accuracy. This project serves as an introduction
to using Selenium for browser automation, illustrating its capabilities in streamlining testing
processes in software development.

STEPS:
Step 1: Install Selenium Server
1. Download Selenium Server:
• Visit the Selenium downloads page.
• Download the latest version of Selenium Server (usually a .jar file).

2. Install Java:
• Ensure that you have Java installed on your system. You can check this by
running java -version in the command line. If it's not installed, download and
install the Java Development Kit (JDK) from the Oracle website or adopt
OpenJDK.

3. Start Selenium Server:


• Open a command line or terminal window.
• Navigate to the directory where the selenium-server-standalone-X.Y.Z.jar file is
located
• Run the following command: java -jar selenium-server-standalone-X.Y.Z.jar

Step 2: Demonstrate Using a Script


(Using Java Script)
1. Set Up Your Java Environment:
• Create a new Java project and include the Selenium Java Client Library in your
project. You can download it from the Selenium downloads page.

ENROLLMENT NO: 210305124005 31


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

2. Sample Java Code:

(Using PHP Script)


1. Set Up Your PHP Environment:
• Install PHP and Composer on your system.
• Use Composer to install the PHP WebDriver library.
• Run: composer require php-webdriver/webdriver

ENROLLMENT NO: 210305124005 32


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

2. Sample Java Code:

CONCLUSION:

By following these steps, you can successfully install Selenium Server and create a script in either
Java or PHP to demonstrate its capabilities. This setup allows you to automate browser interactions
and conduct testing efficiently.

ENROLLMENT NO: 210305124005 33


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

Practical - 9
AIM: Write and test a program to login a specific web page
DESCRIPTION:

This task focuses on writing and testing a program that automates the login process for a specific
web page using Selenium WebDriver. The objective is to develop a script that launches a web
browser, navigates to the login page, enters the required credentials, and submits the login form.
By verifying successful login through checks such as page titles or URLs, this program aims to
streamline the testing process for web applications, ensuring reliability and efficiency in user
authentication scenarios.

Steps to Achieve the Aim:

1. Select a Web Page:

• Choose a specific web page that requires login (e.g., a demo site or a personal
project).

2. Set Up Environment:

• Install necessary tools (e.g., Selenium WebDriver for your chosen programming
language).
• Set up the development environment (Java/PHP/Python, etc.).

3. Write the Login Script:

• Use Selenium to automate the login process. The script should include:
o Launching the browser.
o Navigating to the login page.
o Locating the username and password fields.
o Entering credentials and submitting the form.

4. Test the Script:

• Run the script and verify that it successfully logs in.


• Include error handling to manage failed logins or incorrect credentials.

5. Validate the Result:

• After logging in, confirm that you are redirected to the appropriate dashboard or
landing page.

ENROLLMENT NO: 210305124005 34


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

CODE:

ENROLLMENT NO: 210305124005 35


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

ADVANTAGES:

• Browser Automation: Selenium automates browser actions, making it easier to simulate


user interactions like logging in, which is essential for testing web applications.
• Open Source: Being open source, Selenium is free to use, allowing organizations to
implement testing solutions without incurring licensing costs.
• Rich Ecosystem: Selenium integrates well with testing frameworks (like JUnit, TestNG)
and tools for reporting and continuous integration, enhancing the testing process.
• Support for Multiple Languages: Selenium supports various programming languages
(Java, Python, C#, PHP, etc.), making it accessible to a wider audience of developers and
testers.

DISADVANTAGES:

• Maintenance Overhead: Selenium scripts can require frequent updates due to changes in
the web application's UI, leading to ongoing maintenance costs.
• Limited Support for Dynamic Content: Handling dynamic web elements (like AJAX)
can be challenging and may require additional code for waits and synchronization.
• Steeper Learning Curve: While Selenium is powerful, it may have a steeper learning
curve for those new to programming or automated testing, requiring familiarity with coding
concepts.
• Performance: Selenium tests can be slower compared to other testing methods, especially
for extensive test suites, due to the overhead of launching browsers and executing scripts.

CONCLUSION:

In conclusion, automating the login process for a specific web page using Selenium provides a
powerful means of enhancing testing efficiency and accuracy in web applications. By simulating
user interactions, Selenium facilitates thorough validation of authentication mechanisms, ensuring
reliability in user experience. Despite the challenges of maintenance and potential performance
concerns, the benefits of cross-browser compatibility, open-source accessibility, and integration
with various programming languages make Selenium a valuable tool in the realm of software
testing. This endeavor not only strengthens understanding of automated testing practices but also
contributes to the overall quality assurance efforts in web development.

ENROLLMENT NO: 210305124005 36


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

Practical - 10
AIM: Write and test a program to provide total number of objects present / available
on the page.
DESCRIPTION:

This practical focuses on writing and testing a program that counts the total number of specific
objects present on a web page using Selenium WebDriver. The objective is to develop a script that
navigates to a designated web page, locates the desired objects (such as images, links, or buttons),
and accurately counts them. By automating this process, the program enhances efficiency in data
extraction and analysis while providing valuable insights into the web page's content structure.

STEPS:
1. Select a Web Page:
• Choose a specific web page where you want to count the objects (e.g., images,
buttons, or any specific HTML elements).

2. Set Up Environment:
• Install necessary tools (e.g., Selenium WebDriver).
• Set up the development environment (Java/PHP/Python, etc.).

3. Write the Counting Script:


• Use Selenium to navigate to the web page.
• Locate the objects of interest using appropriate locators (e.g., tags, classes).
• Count the number of objects found on the page.

4. Test the Script:


• Run the script and verify the counted total matches the expected number of
objects.
• Handle any exceptions or errors.

5. Output the Result:


• Display the total number of objects on the console or log file.

ENROLLMENT NO: 210305124005 37


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

CODE:

CONCLUSION:

In conclusion, developing a program to count the total number of specific objects on a web page
using Selenium WebDriver exemplifies the power of automation in web data extraction. This
project successfully demonstrates how Selenium can be utilized to streamline the counting process,
providing accurate insights into a web page's structure and content. By automating this task, we
enhance efficiency and reliability, allowing for quicker data analysis and decision-making. The
skills acquired through this endeavor not only reinforce the principles of web scraping but also lay
a solid foundation for future projects involving automated testing and data collection.

ENROLLMENT NO: 210305124005 38


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

Practical - 11
AIM: Write and test a program to update 10 student records into table into Excel
file.
DESCRIPTION:

This project focuses on creating a Python program that updates student records in an Excel file
using the panda’s library. The program reads existing data, modifies the records for 10 students
with new details such as name, age, and grade, and saves the updates back to the file. By
automating this process, the program improves data management efficiency and accuracy,
showcasing the effectiveness of Python for handling Excel data.

STEPS:
1. Set Up Environment:
• Make sure you have pandas and openpyxl installed.
• Install them via pip: pip install pandas openpyxl

2. Create an Excel File (if not already created):


• Create an Excel file with a sheet named "Students" and set up the columns as
needed (e.g., ID, Name, Age, Grade).

3. Write the Program:


• Use Python to read the existing records, update them, and save the changes back
to the Excel file.

DATA:

ENROLLMENT NO: 210305124005 39


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

CODE:

ENROLLMENT NO: 210305124005 40


COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

EXPLANATION OF THE CODE:

• Load the Excel File: The program starts by loading the existing Excel file containing the
student records.
• Display Current Records: It prints the current records to provide a reference before
updating.
• Update Records: A dictionary named updates holds the new details for each student. The
program iterates through this dictionary and updates the corresponding records in the
DataFrame.
• Save Changes: After updating, the program saves the changes back to the same Excel file.
• Display Updated Records: Finally, it prints the updated records to verify that the changes
were made successfully.

CONCLUSION

In conclusion, this project successfully demonstrates the automation of updating student records
in an Excel file using Python and the panda’s library. By implementing a program that efficiently
reads, modifies, and saves data, we enhance data management processes while ensuring accuracy
and consistency in record-keeping. The ability to automate such tasks not only saves time but also
reduces the likelihood of human error, showcasing the practical applications of Python for data
manipulation. This project serves as a valuable step towards mastering data handling techniques
and reinforces the importance of automation in modern data management.

ENROLLMENT NO: 210305124005 41

You might also like