Name: - Shivam Sharma Roll No: - 08: - Index - HTML
Name: - Shivam Sharma Roll No: - 08: - Index - HTML
Roll No: - 08
Practical .1
AIM: Install Selenium IDE. Write a test suite containing minimum 4 test cases for
different
formats.
REQUIREMENTS:
1) Just google “Selenium IDE chrome” and click on the first link. Add the “Selenium IDE”
extension to your browser.
2) For testing, we need a test case suite, so we create a WebApplication in NetBeans IDE.
File > New Project > Java Web > Web Application > Add GlassFish Server > Finish.
3) In index.html, we write the following code for “ARITHMETIC OPERATIONS” test case suite:
---index.html---
<html>
<head>
<title>prac1</title>
<script language="javascript">
function addition()
{
var num1=parseInt(document.arithmetic.n1.value);
var num2=parseInt(document.arithmetic.n2.value);
var result=num1+num2;
document.arithmetic.res.value=result;
}
function subtraction()
{
var num1=parseInt(document.arithmetic.n1.value);
var num2=parseInt(document.arithmetic.n2.value);
var result=num1-num2;
document.arithmetic.res.value=result;
}
function multiplication(
{
var num1=parseInt(document.arithmetic.n1.value);
var num2=parseInt(document.arithmetic.n2.value);
var result=num1*num2;
document.arithmetic.res.value=result;
}
function division()
{
var num1=parseInt(document.arithmetic.n1.value);
var num2=parseInt(document.arithmetic.n2.value);
var result=num1/num2;
document.arithmetic.res.value=result;
}
</script>
</head>
<body>
<h1 align="center"> Arithmetic Operations </h1>
<form name="arithmetic">
<table border="1" align="center">
<tr>
<td>Number 1: </td>
<td><input type="text" name="n1" size="20"></td>
</tr>
<tr>
<td>Number 2: </td>
<td><input type="text" name="n2" size="20"></td>
</tr>
<tr>
<td colspan=2>
<input type="button" name="add" value="Add"
onclick="javascript:addition();">
<input type="button" name="sub"
value="Subtract" onclick="javascript:subtraction();">
<input type="button" name="mul"
value="Multiply"
onclick="javascript:multiplication();">
<input type="button" name="div"
value="Divide" onclick="javascript:division();">
</td>
</tr>
<td colspan="2">Result is: <input type="text" name="res" size="20"
value=""></td>
</tr>
</table>
</form>
</body>
</html>
4) Create a JSP file “newjsp.jsp” with a link to the created HTML file.
---newjsp.jsp---
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body align="center">
<h1>Test Cases IDE</h1>
<a href="index.html">Arithmetic Operations</a>
</body>
</html>
5) Run this JSP file from NetBeans. It will then open up in a browser.
Then from the browser, open the link:
A new tab will be opened, maximize that tab(this tab is your working tab for recording):
Click on Stop Recording:
Just as you stop your recording, you’ll be prompted to Name your new test,
we’ll make our new test as “addition”:
We’ll be prompted to paste our URL again, then click Start Recording:
NOTE THAT each clicks are recorded:
NOTE2: Paste here the URL again if the Glassfish Error occurs between any test case:
Now create 3 more test cases(subtraction, multiplication, division). Then “Run all tests”:
6) Finish!
REQUIREMENTS:
1) Just google “Selenium IDE chrome” and click on the first link. Add the “Selenium IDE”
extension to your browser.
2) For testing, we’ll choose “redbus.in” as our first website. We’ll be checking
some Selenium IDE Commands like assertText, verifyTitle, storeText, echo.
Detailed info for several commands are provided at
https://ui.vision/docs/selenium-ide .
Now google “redbus.in”.
Copy the URL of the page and open “Selenium IDE” extension:
A new tab will be opened, maximize that tab(this tab is your working
tab for recording):
Now we’ll make use of command verifyTitle.
(This command verifies title of the webpage and keeps on continuing the
execution.) So anywhere on the window, do Right Click> select Selenium
IDE> click Verify Title:
Now after filling the FROM, TO, ONWARD DATE, we proceed further by clicking on
Search Buses: (make sure not to do unnecessary clicks)
Now we’ll make use of command assertText.
(This command verifies particular text of the webpage and stops the execution of
testcase if the match isn’t found.)
So, we want to make sure that our automated testcase chooses our specified
Bus Provider.
To ensure that, here we do Right Click over the name of the bus provider>
then select Selenium IDE> and click Assert Text :
After clicking OK, we can see how the target is automatically mapped to
the css attribute of the page, and our price is stored:
Now we’ll make use of command echo.
(This command is used to display text(comments, notes) and/or the stored
value of variables in the log area of Selenium IDE.)
Here we’ll display the price of the ticket from the variable “price” that we stored
during the use of storeText command.
To create a new command, we just click onto the next line and enter our command:
We’ll enter the Command name echo, & Value ${price} because we are calling the
created variable “price” from this command:
Now we’ll Run current test:
After the test gets completed, we can see the echo: 350 in the log area of
Selenium IDE showing the output of the echo command.
Here we can see how 350 is stored in variable “price” by storeText
command, and that variable is then called by the echo command, which is
then returning the value fetched from the page:
3) Finish!
(Assert and verify commands are both useful for verifying condition match or not. The
difference is that verify command will verify the condition and if it’s not match, it will
give error message in Log area and the macro(testcase) continues to run. With the
assert command, if the condition does not match then it will stop remaining
macro(testcase) execution in the selenium IDE software testing tool.)