Software Testing Lab
Software Testing Lab
DEPARTMENT OF MCA
II SEMESTER
NAME
USN
2020-21
NHCE Page 1
2020-21 20MCAL29 INH20MC001
DEPARTMENT OF MCA
CERTIFICATE
---------------------------------------- --------------------------------------------
------------------------------------ --------------------------------------------
Date of Examination:
NHCE Page 2
2020-21 20MCAL29 INH20MC001
INDEX
Sl.
Program Date Page No.
No.
NHCE Page 3
2020-21 20MCAL29 INH20MC001
Command Table
Command: Command column describes name of command
Target: Target column describes Target element id or name or Xpath
Value: Value column describes Value of an element
NHCE Page 4
2020-21 20MCAL29 INH20MC001
Recording
✓ During recording, Selenium-IDE will automatically insert commands into
your test case based on your actions
✓ Typically, this will include:
▪ clicking a link - click or click at commands
▪ entering values - type command
▪ selecting options from a drop-down listbox - select command
▪ clicking checkboxes or radio buttons - click command
✓ You will see a context menu showing verify and/or assert commands
Editing
✓ Insert Command Right-click and select Insert Command
✓ Insert Comment Comments may be added to make your test case more
readable
✓ Edit a Command or Comment Select the line to be changed ,edit it using
the Command, Target, Value and Comment fields
Running Test Cases
✓ Run a Test Case
Click the Run button to run the currently displayed test case
✓ Run a Test Suite
Click the Run All button to run all the test cases in the currently loaded
test suite
✓ Pause and Star
The Pause button can be used to stop the test case while it is running
The icon of this button then changes to indicate the run is paused
To continue click it again, or click the Run button
✓ Stop in the Middle
-You can set a breakpoint in the test case to cause it to stop on a
particular command
-Select a command, right-click, and from the context menu select
Toggle Breakpoint
✓ Start from the Middle
-You can tell the IDE to begin running from a specific command in the
NHCE Page 6
2020-21 20MCAL29 INH20MC001
Selenese
Selenium commands known as SELENESE Sequence of selenese forms test
script Types of Selenese Actions
• Commands that do user action like click, sendKeys Accesors
• Examine / access the current state of application-under test
Assertions
• Verify/validate the expected results
• Few commands comes with parameters (They are optional and
depends on the command)
NHCE Page 7
2020-21 20MCAL29 INH20MC001
• Open
Opens a page using a URL
• Click
Performs a click operation, and optionally waits for a new page to load
• Verify Title/assert Title
Verifies an expected page title
• Verify Text Present
Verifies expected text is somewhere on the page
• Verify Element Present
Verifies an expected UI element, as defined by its HTML tag, is present on
from here
• Verify Text
NHCE Page 8
2020-21 20MCAL29 INH20MC001
Verifies expected text and its corresponding HTML tag are present on the
page
• Verify Table
Verifies a table’s expected contents
Test Scenario
✓ Launch way2sms
✓ Type Phone number
✓ Type Password
✓ Click Login
✓ After Page Load Verify text
✓ logout
NHCE Page 9
2020-21 20MCAL29 INH20MC001
NHCE Page 10
2020-21 20MCAL29 INH20MC001
i) Environment Variables
OK Cancel
k) Click OK
Paste
c:\programfiels\java\jdk18.0_20\bin;
C:\> D:
D:\> java
D:\> javac
NHCE Page 11
2020-21 20MCAL29 INH20MC001
c) Click Search.
e) Go to Eclipse.org.site
g) Click Download
r) Switch to Workspace
s) Other
NHCE Page 12
2020-21 20MCAL29 INH20MC001
a) Eclipse
b) File
c) New
i) Click Finish
j) Project Created
Note:-
2. Properties
3. Java Compiler
1. Libraries
NHCE Page 13
2020-21 20MCAL29 INH20MC001
5. Click Finish
6. Click Ok
b) New
c) Package
e) Click Finish
b) New
c) Class
g) Click Finish
NHCE Page 14
2020-21 20MCAL29 INH20MC001
a) Goto Google
c) Go to seleniumhq.org site
f) Extract Download
i) Properties
k) Libraries
n) click Ok
NHCE Page 15
2020-21 20MCAL29 INH20MC001
NHCE Page 16
2020-21 20MCAL29 INH20MC001
Thread.sleep(5000);
driver.close();
}
}
Output:
NHCE Page 17
2020-21 20MCAL29 INH20MC001
NHCE Page 18
2020-21 20MCAL29 INH20MC001
System.setProperty("webdriver.chrome.driver","C://Selenium//chromedriver.exe");
OUTPUT
NHCE Page 19
2020-21 20MCAL29 INH20MC001
package Webdrivercommand;
import java.io.FileInputStream;
import java.io.IOException;
import jxl.Sheet;
import jxl.Workbook;
NHCE Page 20
2020-21 20MCAL29 INH20MC001
import jxl.read.biff.BiffException;
public class ReadExcelFile
{
public void readExcel() throws BiffException,IOException
{
String Filepath="C:\\Users\\Mamatha\\Desktop\\sampledoc1.xls";
FileInputStream fs=new FileInputStream(Filepath);
Workbook wb = Workbook.getWorkbook(fs);
Sheet sh=wb.getSheet("Sheet1");
int total_no_of_rows=sh.getRows();
int total_no_of_columns=sh.getColumns();
for(int row=0;row<total_no_of_rows;row++)
{
for(int col=0;col<total_no_of_columns;col++)
{
System.out.print(sh.getCell(col,row).getContents() +"\t");
}
System.out.println();
}
}
public static void main(String args[]) throws BiffException,IOException
{
ReadExcelFile DT=new ReadExcelFile();
DT.readExcel();
}
NHCE Page 21
2020-21 20MCAL29 INH20MC001
}
OUTPUT
NHCE Page 22
2020-21 20MCAL29 INH20MC001
NHCE Page 23
2020-21 20MCAL29 INH20MC001
NHCE Page 24
2020-21 20MCAL29 INH20MC001
NHCE Page 25
2020-21 20MCAL29 INH20MC001
driver.findElement(By.id("userName")).sendKeys("[email protected]");
Thread.sleep(5000);
driver.findElement(By.name("address1")).sendKeys("chennaifasf");
Thread.sleep(5000);
driver.findElement(By.name("city")).sendKeys("chennai");
Thread.sleep(5000);
driver.findElement(By.name("state")).sendKeys("TN");
Thread.sleep(5000);
driver.findElement(By.name("postalCode")).sendKeys("5000221");
Thread.sleep(5000);
Select s=newSelect((driver.findElement(By.name("country"))));
List <WebElement>listOptionDropdown = s.getOptions();
Int dropdownCount = listOptionDropdown.size();
System.out.println("Total Number of item count in dropdown list = " +
dropdownCount);
s.selectByVisibleText("INDIA");
Thread.sleep(5000);
driver.findElement(By.id("email")).sendKeys("[email protected]");
Thread.sleep(5000);
driver.findElement(By.name("password")).sendKeys("Madhvaraj");
Thread.sleep(5000);
driver.findElement(By.name("confirmPassword")).sendKeys("Madhvaraj");
Thread.sleep(5000);
driver.close();
}
NHCE Page 26
2020-21 20MCAL29 INH20MC001
OUTPUT
NHCE Page 27
2020-21 20MCAL29 INH20MC001
driver.navigate().refresh();
String refreshurl=driver.getCurrentUrl();
System.out.println(refreshurl);
Thread.sleep(5000);
driver.navigate().to("https://seleniummaster.com/llc/");
String tourl1=driver.getCurrentUrl();
System.out.println(tourl1);
Thread.sleep(5000);
driver.manage().window().maximize();
Thread.sleep(5000);
driver.close();
}
}
OUTPUT
NHCE Page 29
2020-21 20MCAL29 INH20MC001
NHCE Page 30
2020-21 20MCAL29 INH20MC001
driver.findElement(By.cssSelector("[name='email_create']")).sendKeys("mk34
[email protected]");
driver.findElement(By.xpath("//button[@name=\"SubmitCreate\"]")).click();
driver.findElement(By.xpath("//input[@id=\"id_gender1\"]")).click();
driver.findElement(By.name("customer_firstname")).sendKeys("Test User");
driver.findElement(By.name("customer_lastname")).sendKeys("Vsoft");
driver.findElement(By.id("passwd")).sendKeys("PKR@PKR");
driver.findElement(By.id("firstname")).sendKeys("Test User");
driver.findElement(By.id("lastname")).sendKeys("Vsoft");
driver.findElement(By.id("company")).sendKeys("Vsoft");
driver.findElement(By.id("address1")).sendKeys("Test 81/1,2nd cross");
driver.findElement(By.id("city")).sendKeys("XYZ");
WebElement statedropdown=driver.findElement(By.name("id_state"));
Select oSelect=new Select(statedropdown);
oSelect.selectByValue("4");
driver.findElement(By.name("postcode")).sendKeys("51838");
WebElement countrydropDown=driver.findElement(By.name("id_country"));
Select oSelectC=new Select(countrydropDown);
oSelectC.selectByVisibleText("United States");
driver.findElement(By.id("phone_mobile")).sendKeys("234567890");
driver.findElement(By.xpath("//input[@name=\"alias\"]")).clear();
driver.findElement(By.xpath("//input[@name=\"alias\"]")).sendKeys("Office")
;
driver.findElement(By.name("submitAccount")).click();
NHCE Page 31
2020-21 20MCAL29 INH20MC001
String
userText=driver.findElement(By.xpath("//*[@id=\"header\"]/div[2]/div/div/nav
/div[1]/a")).getText();
if(userText.contains("Vsoft"))
{
System.out.println("User Verified,Test case Passed");
}
else
{
System.out.println("User Verification Failed,Test case Failed");
}
}
}
OUTPUT
NHCE Page 32
2020-21 20MCAL29 INH20MC001
NHCE Page 33