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

CAP771 Assignments

Uploaded by

adityaagan0312
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)
22 views

CAP771 Assignments

Uploaded by

adityaagan0312
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/ 36

Software Testing Assignments

NAME = ADITYA AGAN.


REGISTRATION NO. = 12303034
ROLL NO. = 18

Assignment1:
Q1) Store and Reuse URL

o Task: Create a Selenium IDE test case that opens "https://omayo.blogspot.com",


stores the current URL in a variable, navigates to a different webpage (e.g.,
"https://www.example.com"), and then returns to the stored URL.
o Hint: Use the store Location command to store the URL and the open command to
navigate back.

Ans:
Explanation:

open navigates to a specified URL.

storeLocation captures the current page's URL into a variable for later use.

Reusing ${storedURL} with open allows the test to return to the original page.

Q2) Store and Verify Text

o Task: Write a Selenium IDE test case that opens "https://omayo.blogspot.com",


stores the text of the "Selenium143" button, navigates to another page (e.g.,
"https://www.google.com"), and then verifies that the stored text is correct by
typing it into the Google search bar.

Ans:
Eplanation:

storeText captures the button's text, saving it as a variable.

type enters this stored text into the Google search bar.

assertValue checks that the typed text is as expected, ensuring that the stored text is correctly used.

Q3) Store and Use Date/Time

o Task: Create a Selenium IDE test case that opens "https://omayo.blogspot.com",


stores the current date and time in a variable, navigates to another page with a text
field (e.g., "https://www.google.com"), and types the stored date and time into that
text field.
o Hint: Use JavaScript in the executeScript command to store the date and time.

Ans:
1. open: The first open command opens "https://omayo.blogspot.com".
2. executeScript: This command executes a JavaScript script to get the current date and time.
The toLocaleString() method returns the current date and time in a readable format. This
value is stored in the storedDateTime variable.
3. open: The second open command opens "https://www.google.com", where we will input
the stored date and time.
4. type: The type command finds the input field with the name attribute q (Google's search
bar) and types the value stored in storedDateTime.

Q4) Store and Select Dropdown Option

o Task: Develop a Selenium IDE test case that opens "https://omayo.blogspot.com",


stores the selected option from the "Drop Down" dropdown menu in a variable,
navigates to another page with a similar dropdown, and selects the stored option.
o Hint: Use storeSelectedValue to capture the selected option and select to choose it on
the other page.

Ans:
1. Open URL: Launch the webpage https://omayo.blogspot.com/.
2. Store Text: Capture the text from an element with id=blogsmenu and store it in a variable
called option.
3. Open Google: Navigate to https://www.google.com.
4. Type: Enter the stored value from the variable ${option} into the input field with name=q.
5. Submit: Execute the form submission associated with the search input.

Q5) Store and Search Table Cell Content

o Task: Write a Selenium IDE test case that opens "https://omayo.blogspot.com",


stores the content of a specific cell from the "Table with no border" table, navigates
to another page (e.g., "https://www.google.com"), and uses that content to perform
a search.
o Hint: Use storeTable to capture the cell content and type to input it into the search
field.
Ans:
1. Open URL:
o Command: open
o Target: https://omayo.blogspot.com/
o Description: This command navigates the browser to the specified blog URL.
2. Store Text:
o Command: storeText
o Target: css=#HTML30 > title
o Value: cell
o Description: This command retrieves the text content from the <title> element
located within the element with the ID HTML30, and stores it in a variable
named cell.
3. Open Google:
o Command: open
o Target: https://www.google.com
o Description: This command directs the browser to navigate to the Google
homepage.
4. Type in Search Box:
o Command: type
o Target: name=q
o Value: ${cell}
o Description: This command inputs the value previously stored in the cell variable
into the Google search box identified by the name=q attribute.
5. Submit Search:
o Command: submit
o Target: name=q
o Description: This command submits the form in which the search box is located,
executing the search with the entered text.
Assignment2:
1. **Write a Selenium IDE script to navigate to "https://omayo.blogspot.com", click on the
"Selenium Tutorial" link, and verify that the resulting page's title contains "Selenium". Document
the steps and the Selenium IDE script.**

2. **Develop a Selenium IDE test case that opens "https://omayo.blogspot.com", stores the page
URL in a variable, and then types that URL into a URL input field on another page (e.g.,
"https://www.example.com"). Provide the script and an explanation of how variables are stored
and accessed.**

3. **Create a Selenium IDE script that demonstrates the use of the pause, refresh,
storeElementText, and storeValue commands. The script should pause for 5 seconds, refresh the
page, store the text of a specific element and the value of an input field, and log them to the
console. Provide the script and output screenshots.**
4. **Write a Selenium IDE test case that verifies the presence of a specific image on
"https://omayo.blogspot.com" using the verifyElementPresent command. Save this test case in
a test suite and document the steps. Compare the verifyElementPresent command with the
assertElementPresent command, explaining the differences with examples.**
5. **Set up Selenium WebDriver in your local environment. Write a script in a programming language of
your choice (e.g., Python, Java) that opens "https://omayo.blogspot.com", sets the browser dimensions
to 1280x720, and prints the current browser dimensions. Include the complete code and setup
instructions.**
6. **Describe the process of including Selenium JAR files in an IntelliJ IDEA project. Provide a step-by-
step guide with screenshots. Explain why these JAR files are necessary for Selenium WebDriver
scripts.**

Step 1: Download Selenium WebDriver JAR Files

1. Download Selenium WebDriver:

• Visit the official Selenium website: Selenium Downloads.

• Under the "Selenium Client & WebDriver Language Bindings" section, select the latest stable version.

• Download the Selenium Java binding (e.g., selenium-java-x.xx.x.zip).

2. Extract the JAR Files:

• Once downloaded, extract the ZIP file to a location on your system. Inside, you'll find a number
of .jar files, such as:

• selenium-api-x.xx.x.jar

• selenium-chrome-driver-x.xx.x.jar

• selenium-support-x.xx.x.jar

• selenium-java-x.xx.x.jar

• Other related JAR files depending on the version.

Step 2: Create a New Java Project in Eclipse

1. Open Eclipse IDE:

• If you haven't installed Eclipse, download and install it from Eclipse Downloads.

2. Create a New Java Project:


• Open Eclipse and go to File > New > Java Project.

• Enter a project name (e.g., SeleniumTest) and click Finish.

Step 3: Add JAR Files to the Project Build Path

1. Right-click on Your Project:

• In the Project Explorer (on the left), right-click the newly created project (e.g., SeleniumTest).

2. Go to Build Path:

• Select Build Path > Configure Build Path.


3. Add External JARs:

• In the "Properties for SeleniumTest" window, select the Libraries tab.

• Click on Add External JARs... on the right.


4. Select Selenium JAR Files:

• Navigate to the location where you extracted the Selenium JAR files (from Step 1).

• Select all the JAR files inside the folder (e.g., selenium-java-x.xx.x.jar, selenium-chrome-driver-
x.xx.x.jar, selenium-support-x.xx.x.jar).

• Click Open to add them to the project.


5. Click OK:

• After adding the JAR files, click OK to close the "Properties for SeleniumTest" window.

Step 4: Verify the Selenium JAR Files are Added

1. Check the Project Structure:

• In the Project Explorer, expand your project (SeleniumTest).

• Under Referenced Libraries, you should see all the JAR files listed, indicating that they have been successfully
added to the project.

7. **Create a Selenium IDE script that opens "https://omayo.blogspot.com", stores the value of an input
field using the storeValue command, and then logs that value to the console. Document the steps and
script.**
8. **Write a Selenium IDE script to navigate to "https://omayo.blogspot.com", click on the "Subscribe"
button, and verify that a specific alert message is displayed. Document the steps and the Selenium IDE
script.**

9. **Develop a Selenium IDE test case that opens "https://omayo.blogspot.com", stores the text of a
heading in a variable, and then types that text into a form input field on the same page. Provide the
script and an explanation of how variables are stored and accessed.**
10. **Create a Selenium IDE script that demonstrates the use of the pause, refresh, storeTitle, and
storeAttribute commands. The script should pause for 4 seconds, refresh the page, store the page title
and an attribute value of a specific element, and log them to the console. Provide the script and output
screenshots.**
11. **Write a Selenium IDE test case that verifies the presence of a specific button on
"https://omayo.blogspot.com" using the verifyElementVisible command. Save this test case in a test
suite and document the steps. Compare the verifyElementVisible command with the
assertElementVisible command, explaining the differences with examples.**

12. **Set up Selenium WebDriver in your local environment. Write a script in a programming language
of your choice (e.g., Python, Java) that opens "https://omayo.blogspot.com", sets the browser
dimensions to 800x600, and prints the current browser dimensions. Include the complete code and
setup instructions.**
13. **Describe the process of including Selenium JAR files in a NetBeans project. Provide a step-by-step
guide with screenshots. Explain why these JAR files are necessary for Selenium WebDriver scripts.**

14. **Create a Selenium IDE script that opens "https://omayo.blogspot.com", stores the text content of
a paragraph element using the storeText command, and then logs that text to the console. Document
the steps and script.**
15. **Write a Selenium IDE script to navigate to "https://omayo.blogspot.com", click on the "Blogger"
link, and verify that the resulting page's title is "Blogger". Document the steps and the Selenium IDE
script.**

16. **Develop a Selenium IDE test case that opens "https://omayo.blogspot.com", stores the inner
HTML of a div element in a variable, and then types that HTML into an editor input field on another page
(e.g., "https://www.tinymce.com"). Provide the script and an explanation of how variables are stored
and accessed.**
17. **Create a Selenium IDE script that demonstrates the use of the pause, refresh,
storeWindowHandle, and storeAlert commands. The script should pause for 2 seconds, refresh the page,
store the window handle and an alert message, and log them to the console. Provide the script and
output screenshots.**

18. **Write a Selenium IDE test case that verifies the presence of specific text within a table on
"https://omayo.blogspot.com" using the verifyText command. Save this test case in a test suite and
document the steps. Compare the verifyText command with the assertText command, explaining the
differences with examples.**

Comparison:

Feature verifyText assertText

Verifies if the text of an element matches the Verifies if the text of an element matches the expected
Purpose expected text. text.

Does not stop the execution of the test. Instead, it


Behavior on logs a failure but continues with the rest of the test Immediately stops the execution of the test case if the
Failure case. text does not match, logging a failure.

Used when you want to continue the test even if a Used when the text match is crucial for the test to
text match fails. Ideal for non-critical verifications proceed. If the text does not match, the test is
Use Case where failure doesn't need to halt the entire test. considered failed, and further execution is stopped.
Feature verifyText assertText

Ends the test case if there is a mismatch. The failure


Error Allows the test case to continue running, even if the is immediately reported, and no further commands are
Handling text mismatch occurs. executed.

verifyText might be used in a test to check if a label assertText is used when the text of an element is
or message appears correctly but you don't want it critical to the functionality being tested. A mismatch
Example to stop the entire test if the text is slightly different. in the text means the test cannot continue.

19. **Set up Selenium WebDriver in your local environment. Write a script in a programming language
of your choice (e.g., Python, Java) that opens "https://omayo.blogspot.com", sets the browser
dimensions to 1366x768, and prints the current browser dimensions. Include the complete code and
setup instructions.**
20. **Describe the process of including Selenium JAR files in a Visual Studio Code project. Provide a
step-by-step guide with screenshots. Explain why these JAR files are necessary for Selenium WebDriver
scripts.**

Step 1: Set Up Your Java Environment

Before starting, ensure you have the following:

• Java Development Kit (JDK) installed. You can download it from the official Java website.

• Visual Studio Code installed. Download it from the official VS Code website.

• Java Extension Pack installed in VS Code to support Java development. You can install it directly from VS Code’s
marketplace.

Step 2: Create a New Java Project

1. Open Visual Studio Code.

2. Open the Command Palette (Ctrl+Shift+P) and type Java: Create Java Project.

3. Select "Create Java Project" from the options, and choose No Build Tools.

4. Select a folder where you want to create the project and enter the project name.

5. VS Code will create the necessary project structure.

Step 3: Download Selenium JAR Files

1. Visit the Selenium Downloads Page: https://www.selenium.dev/downloads/.

2. Under the "Selenium Client & WebDriver Language Bindings" section, download the Java version of the Selenium
WebDriver.

3. After downloading, extract the ZIP file to a location on your system.


4. Inside the extracted folder, locate the selenium-java-x.x.x folder. This folder contains all the necessary JAR files for
Selenium WebDriver.

Step 4: Add Selenium JAR Files to Your Project

1. In Visual Studio Code, go to your project folder.

2. Inside your project folder, create a new folder named "lib". This folder will hold the JAR files.

3. Copy all the JAR files from the selenium-java-x.x.x folder you extracted earlier and paste them into the lib folder you
just created.

Step 5: Configure Your Project to Use the JAR Files

Now you need to configure VS Code to include the JAR files in your project classpath:

1. In VS Code, open the Explorer view and right-click on the project folder.

2. Click on New File and create a file named lib.classpath.

3. In the lib.classpath file, write the following content (you need to specify the paths to your JAR files):

Replace selenium-java-x.x.x.jar with the actual version of the JAR file you downloaded.

Step 6: Create a Java File and Write Your First Selenium Script

1. Inside your project folder, create a new file named TestSelenium.java.

2. In the TestSelenium.java file, write the following code:

• You will need to download the ChromeDriver (or any other WebDriver for the browser you want to use) from here.

Step 7: Run Your Selenium Script

1. Ensure that the Java Development Kit (JDK) is properly installed and available in your system's PATH.

2. In Visual Studio Code, open the Terminal (Ctrl + `) and navigate to your project folder.

3. To compile your Java file, run:

bash

Copy code

javac -cp "lib/*" TestSelenium.java

4. To run your script, use:

java -cp ".;lib/*" TestSelenium

Note: On Linux or macOS, you should use : instead of ; to separate classpath entries.

Why are Selenium JAR Files Necessary?

Selenium JAR files are Java libraries that contain all the necessary classes and methods that allow Selenium to interact with
different web browsers. These JAR files include classes for:

• WebDriver: Classes that allow interaction with the web browser, such as ChromeDriver, FirefoxDriver, etc.

• WebElement: Classes to interact with web page elements like buttons, text fields, links, etc.

• Browser Automation: Methods for automating browser actions like clicking, typing, navigating, etc.
• Selenium Support: Additional libraries for handling waits, assertions, and other testing tasks.Without including these
JAR files, you will not have access to the Selenium WebDriver API, and your script won't be able to control the web
browser.
Assignment3:
1. Scenario: Handling Popups

• Question: You are testing a website that offers the option to open content in a popup window. Write a test
case using Selenium IDE to navigate to omayo.blogspot.com, click the “Open a popup window” button,
and verify that the popup window opens. Then switch to the new popup window, verify the page title, and
close the popup.
• Hint: You will need to store the window handle of the main page, switch to the popup window, and return
to the main page after closing the popup.
2. Scenario: Form Input Automation

• Question: On the omayo.blogspot.com page, there is a textbox under the "TextBox with default text"
section. Write a test case that stores the default value of the textbox, replaces it with a new value ("Alice"),
and uses this new value in the "TextArea with some text" section on the same page. Verify that the value is
correctly copied from the textbox to the textarea.
• Hint: Use the storeValue command to capture the value from the textbox and then type it into the
textarea.
3. Scenario: Verifying Text and Page Title

• Question: Create a test that navigates to omayo.blogspot.com, verifies the page title using the
storeTitle command, and checks whether the text "PracticeAutomationHere" is present on the page
using verifyText. Save the test case in a test suite and ensure it runs without stopping even if the text is
missing.
• Hint: Use verifyText so the test does not stop if the text is not found and focus on adding the test case
to a suite.
4. Scenario: Conditional Test with verifyText and assertText

• Question: You're tasked with verifying if the "PracticeAutomationHere" text is present on the
omayo.blogspot.com page. Write two different test cases, one using verifyText and the other using
assertText, to check for this text. Explain what happens in both cases if the text is missing.
• Hint: Test both verifyText (non-interruptive) and assertText (interruptive) to understand their
behaviors in handling absent text.

verifyText:

• What Happens if Text is Present:


• If the h1 tag on https://example.com contains the text "Welcome to Example", the test will pass
the verifyText step, and the test will continue with the next command
(opening https://anotherpage.com).
• What Happens if Text is Missing:
• If the text "Welcome to Example" is missing or does not match the expected value,
the verifyText command will log a failure (as a mismatch) but will continue executing the rest of
the commands. In this case, it will open https://anotherpage.com after the failure.
• Result: The test case will not stop, but you will get a failure report for the verifyText check.

assertText:

• What Happens if Text is Present:


• If the h1 tag on https://example.com contains the text "Welcome to Example", the test will pass
the assertText step, and it will continue with the next command
(opening https://anotherpage.com).
• What Happens if Text is Missing:
• If the text "Welcome to Example" is missing or does not match the expected value,
the assertText command will log a failure and immediately stop the execution of the test case.
As a result, the open https://anotherpage.com command will not be executed, and the test will be
considered failed at that point.
• Result: The test will stop immediately, and no further steps will be performed after the failure.

5. Scenario: Refresh and Page State Validation

• Question: The client reports that refreshing the page causes some issues with retaining data. Automate a
test case where you navigate to omayo.blogspot.com, enter a value into the textbox under "TextBox with
default text", refresh the page, and check if the entered value is retained or reset.

6. Scenario: Storing and Validating Webpage Elements

• Question: You need to extract specific text from the "Sample Page" section on the left side of
omayo.blogspot.com. Write a test case to store the text "This is a sample page" using the storeText
command, and then use this text later in the test to verify that it is correctly echoed in the test log.
• Hint: Use storeText to save the text and echo to display it in the log.
7. Scenario: Button Click and Verification

• Question: On omayo.blogspot.com, there is a button under the "Button" section labeled "Search". Write a
test case to click this button and verify whether a new action or page transition occurs after the click.
Capture the URL of the new page and validate it.
• Hint: Use storeLocation after the click event to capture the new URL and compare it to the expected
URL.

8. Scenario: Handling Dropdown Menus

• Question: There's a dropdown menu labeled "DropDown1" on omayo.blogspot.com. Write a test case that
selects the option "doc 3" from the dropdown and verifies that this option is correctly selected.
• Hint: Use the select command to choose the value from the dropdown and verify it using the
assertSelectedValue command.

You might also like