CAP771 Assignments
CAP771 Assignments
Assignment1:
Q1) Store and Reuse URL
Ans:
Explanation:
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.
Ans:
Eplanation:
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.
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.
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.
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.**
• Under the "Selenium Client & WebDriver Language Bindings" section, select the latest stable version.
• 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
• If you haven't installed Eclipse, download and install it from Eclipse Downloads.
• In the Project Explorer (on the left), right-click the newly created project (e.g., SeleniumTest).
2. Go to Build Path:
•
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).
• After adding the JAR files, click OK to close the "Properties for SeleniumTest" window.
• 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:
Verifies if the text of an element matches the Verifies if the text of an element matches the expected
Purpose expected text. text.
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
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.**
• 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.
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.
2. Under the "Selenium Client & WebDriver Language Bindings" section, download the Java version of the Selenium
WebDriver.
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.
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.
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
• You will need to download the ChromeDriver (or any other WebDriver for the browser you want to use) from here.
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.
bash
Copy code
Note: On Linux or macOS, you should use : instead of ; to separate classpath entries.
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:
assertText:
• 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.
• 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.
• 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.