45 Hrishikesh STQA
45 Hrishikesh STQA
45 Hrishikesh STQA
: 45
Practical No. 1
Aim: Take a review and write test cases for any known application.
Test Scenarios of Facebook
1.Verify that user can set profile pic uploaded from his or her
computer.
2.Verify that user can set profile pic uploaded from mobile.
3.Verify that uer can set profile pic from photos present on his facbook
account’s photo section.
4.Verify that user can set profile from webcam or mobile camera.
5.Verify that user can set cover pic uploaded from his or her computer.
6.Verify that user can set cover pic uploaded from mobile.
7.Verify that user can set cover pic from photos present on his facbook
account’s photo section.
8.Verify that user can set cover from webcam or mobile camera.
9.Verify that uploading image of unsupported type should lead to error
message.
10. Verify that uploading image of size exceeding maximum
allowed size should lead to error message.
11. Verify that uploading image of size less than the allowed
minimum size should lead to error message.
12. Verify that uploading image of larger dimension than permitted
should lead to error message.
13. Verify that uploading image of smaller dimension than
permitted should lead to error message.
14. Verify that change in profile pic should get reflected in each
post/comment of the user’s timeline.
15. Verify that user can add/edit their account information
displayed to other users.
16. Verify that users can post text in their timeline and the same
gets displyed to their friends.
17. Verify that users can post images in their timeline and the same
gets displyed to their friends.
18. Verify that users can post links with or without preview in their
timeline and the same gets displayed to their friends.
19. Verify that user can tag friends in their posts.
20. Verify that users can see the all the post in their timeline.
1
Hrishikesh Rane Roll no.: 45
21. Verify that users can see comments, likes and reactions in the
posts present in their timeline.
22. Verify that users can post comments, like and react to the posts
present in their timeline.
Test scenarios
2
Hrishikesh Rane Roll no.: 45
Practical No. 2
Aim: Implement Web Drivers on Chrome & Firefox Browsers.
Selenium Installation
Go to the Java Downloads Page and click on the option for Java Platform (JDK).
In the next page, select the Accept License Agreement radio button, accept it and click the
download link against your matching system configuration.
You can run the installer once the download is over and follow onscreen instructions.
o Go to start and search for ‘System’
o Click on ‘System’
o Click on ‘Advanced system settings’
o Click on ‘Environment Variables’ under ‘Advanced’ tab as shown below:
3
Hrishikesh Rane Roll no.: 45
Next, under system variables choose new and enter the variable name as ‘JAVA_HOME’ and
the full path to Java installation directory as per your system as shown below:
Below figure depicts the configuration of environment variable name and value.
4
Hrishikesh Rane Roll no.: 45
Next thing that you have to do is to configure your environment variables. Let’s see how to
do that. Here, you have to edit the path of the system variable as shown below.
Under ‘Variable value’, at the end of the line, enter the following path – %JAVA_HOME
%bin;
Now, you can click ‘OK’ and you are done.
Now to cross-check the installation, just run following command in cmd – java -version. It
should display the installed version of Java in your system.
Install Eclipse
Navigate to the following URL – https://www.eclipse.org/downloads/ and select the
download link depending on your system architecture – (32 Bit or 64 Bit) and download it.
5
Hrishikesh Rane Roll no.: 45
Once the download is over, extract the zipped file and save it to any directory. The root folder
is the eclipse.
6
Hrishikesh Rane Roll no.: 45
Now, the last step is to install Selenium. Let’s see how to install selenium and configure it in
your system.
The download should get started for ‘selenium-server-standalone-x.y.z.jar’. Save this JAR in
“C:Selenium”.
Next, you have to download Selenium Java Client. In the same downloads page, scroll down
and you will find a section called Selenium Client and WebDriver Language. Now, click on
Download link under Java as shown below.
7
Hrishikesh Rane Roll no.: 45
Next, you have to download Chrome Driver for Google Chrome and Gecko Driver if you are
using Mozilla Firefox.
In the same downloads page, scroll further down and you will find third-party drivers section.
There you will find options for downloading gecko driver and chrome driver as shown in the
below figure.
In the next page, you will find the latest version available. You can choose that and download
based on your system configuration. You can refer the below image for your OS
configuration.
8
Hrishikesh Rane Roll no.: 45
You can simply download the driver, extract the zip file and save it in any location. Similarly,
you can download the latest version of gecko driver and save it if you are using the Mozilla
browser.
Next, you can simply create a new project in Eclipse IDE and add all the external selenium
jar files from selenium lib directory.
9
Hrishikesh Rane Roll no.: 45
Next, you should add referenced libraries to your project. Click on your project -> Build
Path -> Configure Build Path and add external JARs as shown in the figure.
10
Hrishikesh Rane Roll no.: 45
11
Hrishikesh Rane Roll no.: 45
Program:
package day1;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromed
river.exe");
WebDriver wd=new ChromeDriver();
wd.get("https://www.google.com");
}
}
Output:
12
Hrishikesh Rane Roll no.: 45
Practical No. 3
Aim: Demonstrate handling multiple frames in selenium
Program:
package day1;
import java.util.Scanner;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
System.out.println("Choice");
int ch=sc.nextInt();
sc.close();
switch(ch)
case 1:
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_
win32\\chromedriver.exe");
wd=new ChromeDriver();
break;
case 2:
System.setProperty("webdriver.gecko.driver","E:\\Software\\geckodriver-
v0.30.0-win64\\geckodriver.exe");
wd=new FirefoxDriver();
break;
13
Hrishikesh Rane Roll no.: 45
default:
System.out.println("Invalid Browser");
if(wd!=null)
wd.get("http://google.com");
Output:
14
Hrishikesh Rane Roll no.: 45
15
Hrishikesh Rane Roll no.: 45
Practical No. 4
Aim: Implement Browser command and navigation Commands.
Program:
package day2;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
16
Hrishikesh Rane Roll no.: 45
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
//System.setProperty("webdriver.gecko.driver","D:\\Selenium\\geckodriver.exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.findElement(By.id("txtUsername")).sendKeys("admin");
wd.findElement(By.id("txtPassword")).sendKeys("admin123");
wd.findElement(By.xpath("//*[@id=\"btnLogin\"]")).click();
Thread.sleep(2000);
wd.navigate().back();
Thread.sleep(2000);
wd.navigate().forward();
wd.navigate().to("https://opensource-demo.orangehrmlive.com/");
wd.navigate().refresh();
Output:
17
Hrishikesh Rane Roll no.: 45
18
Hrishikesh Rane Roll no.: 45
19
Hrishikesh Rane Roll no.: 45
Practical No. 5
Aim: Implement the find element command
Program:
package day1;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.findElement(By.id("txtUsername")).sendKeys("admin");
wd.findElement(By.name("txtPassword")).sendKeys("admin123");
wd.findElement(By.className("button")).click();
//act.moveToElement(wd.findElement(By.className("firstLevelMenu"))).perform();
//act.moveToElement(wd.findElement(By.id("menu_recruitment_viewRecruitmentModule")
)).perform();
20
Hrishikesh Rane Roll no.: 45
List<WebElement> menu=wd.findElements(By.className("firstLevelMenu"));
for(int i=0;i<=menu.size()-1;i++)
System.out.println(menu.get(i).getText());
act.moveToElement(menu.get(i)).perform();
wd.findElement(By.partialLinkText("Welcome")).click();
wd.findElement(By.linkText("Logout")).click();
wd.close();
Output:
21
Hrishikesh Rane Roll no.: 45
22
Hrishikesh Rane Roll no.: 45
Practical No. 6
Aim: Demonstrate the Locator(id,css selector, path)
1. Id
Program:
package day1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.findElement(By.id("txtUsername")).sendKeys("admin");
wd.findElement(By.name("txtPassword")).sendKeys("admin123");
wd.findElement(By.className("button")).click();
wd.findElement(By.linkText("Welcome Palak")).click();
Thread.sleep(2000);
wd.findElement(By.linkText("Logout")).click();
23
Hrishikesh Rane Roll no.: 45
Output:
24
Hrishikesh Rane Roll no.: 45
2. CSS Selector
Program:
package day1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.findElement(By.cssSelector("input#txtUsername")).sendKeys("admin");
wd.findElement(By.cssSelector("input[type=Password]")).sendKeys("admin123");
wd.findElement(By.cssSelector("input.button")).click();
25
Hrishikesh Rane Roll no.: 45
Output:
26
Hrishikesh Rane Roll no.: 45
3. Path
Program:
package day1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.findElement(By.xpath("/html/body/div[1]/div/div[3]/div[2]/div[2]/form/div[2]/input")).sendKeys
("admin");
wd.findElement(By.xpath("//*[@id=\"txtPassword\"]")).sendKeys("admin123");
wd.findElement(By.className("button")).click();
27
Hrishikesh Rane Roll no.: 45
Output:
28
Hrishikesh Rane Roll no.: 45
Practical No. 7
Aim: Demonstrate synchronization in selenium.
Implicit wait
Program:
package day1;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
29
Hrishikesh Rane Roll no.: 45
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.ex
e");
WebDriver wd=new ChromeDriver();
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
wd.findElement(By.id("txtUsername")).sendKeys("admin");
wd.findElement(By.name("txtPassword")).sendKeys("admin123");
wd.findElement(By.className("button")).click();
wd.findElement(By.partialLinkText("Welcome")).click();
wd.findElement(By.linkText("Logout")).click();
}
Output:
30
Hrishikesh Rane Roll no.: 45
Explicit wait
Program:
package day1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
31
Hrishikesh Rane Roll no.: 45
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.findElement(By.id("txtUsername")).sendKeys("admin");
wd.findElement(By.name("txtPassword")).sendKeys("admin123");
wd.findElement(By.className("button")).click();
wd.findElement(By.partialLinkText("Welcome Paul")).click();
wt.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Logout")));
wd.findElement(By.linkText("Logout")).click();
Output:
32
Hrishikesh Rane Roll no.: 45
Practical No. 8
Aim: Demonstrate different types of alerts
Program:
package day1;
33
Hrishikesh Rane Roll no.: 45
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("http://frontaccounting.squadinfotech.in/index.php");
wd.findElement(By.name("user_name_entry_field")).sendKeys("frontuser1");
wd.findElement(By.name("password")).sendKeys("frontuser1");
s.selectByVisibleText("Squad_MT_OL-50");
wd.findElement(By.name("SubmitUser")).click();
wd.findElement(By.linkText("Direct Delivery")).click();
wd.findElement(By.id("CancelOrder")).click();
//Thread.sleep(2000);
Alert alt=wd.switchTo().alert();
alt.accept();
//alt.dismiss();
Output:
34
Hrishikesh Rane Roll no.: 45
Practical No. 9
35
Hrishikesh Rane Roll no.: 45
Aim:
Demonstrate:
a) Handling Drop Down,
b) List Boxes
package day1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://blazedemo.com/");
s.selectByIndex(1);
s.selectByValue("Boston");
s.selectByVisibleText("San Diego");
36
Hrishikesh Rane Roll no.: 45
Output:
37
Hrishikesh Rane Roll no.: 45
38
Hrishikesh Rane Roll no.: 45
b) List Boxes
Program:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("E:\\MCA_SEM3\\Selenium\\Multi.html");
if(s.isMultiple())
s.selectByIndex(1);
s.selectByValue("3");
s.selectByVisibleText("Ferrari");
Thread.sleep(2000);
s.deselectAll();
Multi.html
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
39
Hrishikesh Rane Roll no.: 45
<title>Multiple</title>
</head>
<body>
<h1>Demo MultiSelect</h1>
<option value="1">Ford</option>
<option value="2">Audi</option>
<option value="3">Bugatti</option>
<option value="4">Ferrari</option>
</select>
</body>
</html>
Output:
40
Hrishikesh Rane Roll no.: 45
Practical No. 10
Aim:
Demonstrate:
1. Command Button,
2. Radio buttons & text boxes.
3. Waits command in selenium
1. Command Button
Program:
package day1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.findElement(By.id("txtUsername")).sendKeys("admin");
wd.findElement(By.name("txtPassword")).sendKeys("admin123");
wd.findElement(By.className("button")).click();
wd.findElement(By.linkText("Welcome Palak")).click();
Thread.sleep(2000);
wd.findElement(By.linkText("Logout")).click();
41
Hrishikesh Rane Roll no.: 45
Output:
42
Hrishikesh Rane Roll no.: 45
43
Hrishikesh Rane Roll no.: 45
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.ex
e");
WebDriver wd= new ChromeDriver();
wd.get("C:\\Users\\ajitg\\eclipse-workspace\\WebProgram\\src\\day2\\radio.html");
wd.findElement(By.xpath("//input[@value='Mr']")).click();
}
Radio.html
<html>
<head>
<body>
<input type="radio" name'"group1" value="Mr">Mr<tr>
<input type="radio" name'"group1" value="Miss">Miss<tr>
<input type="radio" name'"group1" value="Mrs">Mrs
</body>
</html>
44
Hrishikesh Rane Roll no.: 45
Output:
45
Hrishikesh Rane Roll no.: 45
Textbox.java
package day1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.findElement(By.id("txtUsername")).sendKeys("admin");
wd.findElement(By.name("txtPassword")).sendKeys("admin123");
46
Hrishikesh Rane Roll no.: 45
Output:
47
Hrishikesh Rane Roll no.: 45
package day1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.findElement(By.id("txtUsername")).sendKeys("admin");
wd.findElement(By.name("txtPassword")).sendKeys("admin123");
48
Hrishikesh Rane Roll no.: 45
Output:
49
Hrishikesh Rane Roll no.: 45
Practical No. 11
Aim: Demonstrate action classes in Selenium
Program:
package day1;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://www.saucedemo.com/");
wd.findElement(By.id("user-name")).sendKeys("standard_user");
wd.findElement(By.id("password")).sendKeys("secret_sauce");
wd.findElement(By.id("login-button")).click();
wd.findElement(By.id("react-burger-menu-btn")).click();
for(int i=0;i<=menu.size()-1;i++)
System.out.println(menu.get(i).getText());
act.moveToElement(menu.get(i)).perform();
//wd.close();
50
Hrishikesh Rane Roll no.: 45
Output:
51
Hrishikesh Rane Roll no.: 45
Program:
package day1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.ex
e");
act.moveToElement(wd.findElement(By.id("menu_recruitment_viewRecruitmentModule"))).perform
();
52
Hrishikesh Rane Roll no.: 45
Output:
53
Hrishikesh Rane Roll no.: 45
Program:
package day1;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.findElement(By.id("txtUsername")).sendKeys("admin");
wd.findElement(By.name("txtPassword")).sendKeys("admin123");
wd.findElement(By.className("button")).click();
54
Hrishikesh Rane Roll no.: 45
List<WebElement> menu=wd.findElements(By.className("firstLevelMenu"));
for(int i=0;i<=menu.size()-1;i++)
System.out.println(menu.get(i).getText());
act.moveToElement(menu.get(i)).perform();
wd.findElement(By.partialLinkText("Welcome")).click();
wd.findElement(By.linkText("Logout")).click();
wd.close();
Output:
55
Hrishikesh Rane Roll no.: 45
Practical No. 12
Aim: Installation of TestNg , running testNg and TestNg annotations
Installtion TestNg
Go to Eclipse click on Help Menu
And Choose Eclipse Marketplace….
56
Hrishikesh Rane Roll no.: 45
Program:
DemoAnnotations
package TestNG;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.AfterSuite;
@Test
System.out.println("Test 1");
57
Hrishikesh Rane Roll no.: 45
@BeforeMethod
System.out.println("Before Method");
@AfterMethod
System.out.println("After Method");
@BeforeClass
System.out.println("Before Class");
@AfterClass
System.out.println("After Class");
@BeforeTest
System.out.println("Before Test");
58
Hrishikesh Rane Roll no.: 45
@AfterTest
System.out.println("After Test");
@BeforeSuite
System.out.println("Before Suite");
@AfterSuite
System.out.println("After Suite");
Output:
59
Hrishikesh Rane Roll no.: 45
DemoAnnotations1
package TestNG;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.AfterSuite;
60
Hrishikesh Rane Roll no.: 45
@BeforeMethod
public void beforeMethod()
{
System.out.println("Before Method");
}
@AfterMethod
public void afterMethod()
{
System.out.println("After Method");
}
@BeforeClass
public void beforeClass()
{
System.out.println("Before Class");
}
@AfterClass
public void afterClass()
{
System.out.println("After Class");
}
@BeforeTest
public void beforeTest()
{
System.out.println("Before Test");
}
@AfterTest
public void afterTest()
{
System.out.println("After Test");
}
@BeforeSuite
public void beforeSuite()
{
System.out.println("Before Suite");
}
@AfterSuite
61
Hrishikesh Rane Roll no.: 45
}
Output:
DataOHM
package TestNG;
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
62
Hrishikesh Rane Roll no.: 45
import org.testng.annotations.DataProvider;
@Test(dataProvider = "dp")
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
wd.findElement(By.id("txtUsername")).sendKeys(u);//locator id
wd.findElement(By.name("txtPassword")).sendKeys(p);//locater name
wd.findElement(By.className("button")).click();//locator className
try {
wd.findElement(By.partialLinkText("Welcome")).click();//locator
partiallinkText
wd.findElement(By.linkText("Logout")).click();//locator linkText
System.out.println("Pass");
} catch (Exception e) {
System.out.println("Fail");
@DataProvider
};
Output:
63
Hrishikesh Rane Roll no.: 45
64
Hrishikesh Rane Roll no.: 45
65
Hrishikesh Rane Roll no.: 45
DemoAssertFA
package TestNG;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
@Test
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("http://frontaccounting.squadinfotech.in/index.php");
Assert.assertEquals(actualTitle, expectedTitle);
Output:
66
Hrishikesh Rane Roll no.: 45
DemoCheck
package TestNG;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://mail.rediff.com/cgi-bin/login.cgi");
Assert.assertTrue(sts);
67
Hrishikesh Rane Roll no.: 45
Output:
68
Hrishikesh Rane Roll no.: 45
DemoDataProvider
package TestNG;
import org.testng.annotations.Test;
import org.testng.annotations.DataProvider;
@Test(dataProvider = "dp")
@DataProvider
}}
Output:
69
Hrishikesh Rane Roll no.: 45
DemoOHM
package TestNG;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
WebDriver wd;
@BeforeSuite
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd = new ChromeDriver();
@BeforeClass
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.findElement(By.id("txtUsername")).sendKeys("admin");//locator id
wd.findElement(By.name("txtPassword")).sendKeys("admin123");//locater name
wd.findElement(By.className("button")).click();//locator className
70
Hrishikesh Rane Roll no.: 45
@Test(priority = 2)
wd.findElement(By.id("menu_pim_viewMyDetails")).click();
@Test(priority = 1)
wd.findElement(By.id("menu_pim_viewPimModule")).click();
@AfterClass
wd.findElement(By.partialLinkText("Welcome")).click();//locator partiallinkText
Thread.sleep(2000);
wd.findElement(By.linkText("Logout")).click();//locator linkText
@AfterSuite
wd.quit();
71
Hrishikesh Rane Roll no.: 45
Output:
72
Hrishikesh Rane Roll no.: 45
73
Hrishikesh Rane Roll no.: 45
Practical No. 13
Aim: Demonstrate data driven Framework.
First Create DemoExcel (.xlsx) in selenium folder
Give Sheet name WriteOHM and write username and password
Program:
WriteData
package day2;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
74
Hrishikesh Rane Roll no.: 45
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
XSSFCell pw=rw.getCell(1);
wd.findElement(By.id("txtUsername")).sendKeys(un.toString());
wd.findElement(By.id("txtPassword")).sendKeys(pw.toString());
wd.findElement(By.id("btnLogin")).click();
wd.findElement(By.linkText("Welcome shruti")).click();
Thread.sleep(2000);
wd.findElement(By.linkText("Logout")).click();
75
Hrishikesh Rane Roll no.: 45
Output:
76
Hrishikesh Rane Roll no.: 45
ValidData
In that DemoExcel File add new Sheet
Give name WriteDataOHM and
Add Wrong username and password and
Put empty result Column
Program:
package day2;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.concurrent.TimeUnit;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
77
Hrishikesh Rane Roll no.: 45
wd.get("https://opensource-demo.orangehrmlive.com/");
wd.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
XSSFCell pw=rw.getCell(1);
XSSFCell res=rw.createCell(2);
wd.findElement(By.id("txtUsername")).sendKeys(un.toString());
wd.findElement(By.id("txtPassword")).sendKeys(pw.toString());
wd.findElement(By.id("btnLogin")).click();
try {
wd.findElement(By.partialLinkText("Welcome shruti")).click();
wd.findElement(By.linkText("Logout")).click();
System.out.println("Logged in successfully");
res.setCellValue("Valid");
} catch(Exception e) {
System.out.println("logged in Fail");
res.setCellValue("Invalid");
fis.close();
wb.write(fos);
wd.close(); }
78
Hrishikesh Rane Roll no.: 45
Output:
79
Hrishikesh Rane Roll no.: 45
80
Hrishikesh Rane Roll no.: 45
Practical No. 14
Aim: Demonstrate Validation testing
First Create DemoExcel (.xlsx) in selenium folder
Give Sheet name WriteOHM and write username and password
Program:
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
81
Hrishikesh Rane Roll no.: 45
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("https://opensource-demo.orangehrmlive.com/");
XSSFCell pw=rw.getCell(1);
82
Hrishikesh Rane Roll no.: 45
Output:
83
Hrishikesh Rane Roll no.: 45
DemoAssert
Program:
package TestNG;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
@Test
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32\\chromedriver.
exe");
wd.get("http://frontaccounting.squadinfotech.in/index.php");
Assert.assertEquals(actualTitle, expectedTitle);
Output:
84
Hrishikesh Rane Roll no.: 45
DemoWindowHandling
Program:
package day1;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
System.setProperty("webdriver.chrome.driver","E:\\Software\\chromedriver_win32
\\chromedriver.exe");
wd.get("http://frontaccounting.squadinfotech.in/index.php");
wd.findElement(By.name("user_name_entry_field")).sendKeys("frontuser1");
wd.findElement(By.name("password")).sendKeys("frontuser1");
s.selectByVisibleText("Squad_MT_OL-50");
wd.findElement(By.name("SubmitUser")).click();
wd.findElement(By.xpath("/html/body/table[1]/tbody/tr/td/table[1]/tbody/tr/td/div
[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td[1]/a[1]")).click();
85
Hrishikesh Rane Roll no.: 45
wd.findElement(By.xpath("/html/body/table[1]/tbody/tr/td/table[1]/tbody/tr/td/div
[2]/form/center[1]/table/tbody/tr/td[2]/table/tbody/tr[1]/td[2]/a")).click();
for(String W:allwin)
wd.switchTo().window(W);
System.out.println(wd.getTitle());
if(!(W.equals(Pid)))
Select ss = new
Select(wd.findElement(By.id("customer_id")));
ss.selectByIndex(0);
wd.manage().window().maximize();
wd.close();
wd.switchTo().window(Pid);
wd.findElement(By.linkText("Logout")).click();
wd.close();
Output:
86
Hrishikesh Rane Roll no.: 45
Practical No. 15
Aim: Perform regression testing
Theory:
What is Regression Testing?
REGRESSION TESTING is defined as a type of software testing to confirm that a
recent program or code change has not adversely affected existing features.
Regression Testing is nothing but a full or partial selection of already executed test
cases which are re-executed to ensure existing functionalities work fine.
This testing is done to make sure that new code changes should not have side effects
on the existing functionalities. It ensures that the old code still works once the latest code
changes are done.
87
Hrishikesh Rane Roll no.: 45
88