<repo_name>Shona2501/OrangeHRM<file_sep>/basicPrograms/FirstProgram.java
package basicPrograms;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class FirstProgram {

	// Note: ctrl+shift+o: To import many classes at same time
	public static void main(String[] args) throws Exception 
	{
		
		// Step1: Select Browser
		// System.setProperty("Key","value");
		// system: class and setProperty("key","value"): Method 
		// Key: BrowserName
		// Value: BrowserPath
		
		System.setProperty("webdriver.chrome.driver", "C:\\Users\\Sonali\\Desktop\\Automation\\BrowserExtenssion\\chromedriver.exe"); // "name of driver--> key", "value --> path ---> "
		
		// Step2: Create an object of WebDriver class with ChromeDriver Constructor
		
		WebDriver driver= new ChromeDriver();
		
		//wait
		Thread.sleep(5000);
		
		// maximize screen
		driver.manage().window().maximize();
		
		Thread.sleep(2000);
		
		// open or access url
		driver.get("https://www.google.com");
		
		// close browser
		driver.close();

	}

}
<file_sep>/basicPrograms/DropDown_FA.java
package basicPrograms;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;


public class DropDown_FA {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		
		System.setProperty("webdriver.chrome.driver", "C:\\Users\\Sonali\\Desktop\\Automation\\BrowserExtenssion\\chromedriver.exe");
		WebDriver driver = new ChromeDriver();
		Thread.sleep(5000);
		driver.manage().window().maximize();
		
		//URL
		driver.get("http://frontaccounting.squadinfotech.in/");
		
		System.out.println("\n\n LoginPage Title:"+driver.getTitle()); // display login page title name
		Thread.sleep(2000);
		
		//user-name
		driver.findElement(By.xpath("//*[@id=\"_page_body\"]/form/center[1]/table/tbody/tr[3]/td[2]/input")).sendKeys("frontuser1");
		//Password
		driver.findElement(By.xpath("//*[@id=\"_page_body\"]/form/center[1]/table/tbody/tr[4]/td[2]/input")).sendKeys("frontuser1");
		Thread.sleep(2000);
		
		//Dropdown: TagName should be  <select>
		// Step1: Select DropDwon --> Create object of select class
		Select s= new Select(driver.findElement(By.xpath("//*[@id=\"_page_body\"]/form/center[1]/table/tbody/tr[5]/td[2]/select"))); // dropdown value
		
		//Step2: Select Content of the dropdown
		//s.selectByIndex(2);
		//s.selectByvalue("2");
		s.selectByVisibleText("Squad_MT_OL_09");
		Thread.sleep(2000);
		
		// Login button
		driver.findElement(By.xpath("//*[@id=\"_page_body\"]/form/center[2]/input")).click(); // which dropdown you have to select that dropdown value
		
		System.out.println("\n\n HomePage Title:"+driver.getTitle()); // display home page title name

		
		//Logout button
		driver.findElement(By.xpath("/html/body/table[1]/tbody/tr/td/table[1]/tbody/tr/td/table/tbody/tr/td/table[2]/tbody/tr[1]/td[3]/a[5]")).click(); //Example of absolute xPath
		Thread.sleep(2000);
		
		System.out.println("\n\n LogoutPage Title:"+driver.getTitle()); // display logout page title name

		
		//close browser
		driver.close();

	}

}
<file_sep>/keyword_Driven/ReadExcelClass.java
package keyword_Driven;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.WebDriver;

public class ReadExcelClass {
	
	public void readExcel(WebDriver driver) throws Exception
	{
		FileInputStream file= new FileInputStream("C:\\Users\\Sonali\\Desktop\\Automation\\POI.xlsx");
		XSSFWorkbook w= new XSSFWorkbook(file);
		XSSFSheet s= w.getSheet("KeywordDriven");
		
		int rowSize=s.getLastRowNum();
		System.out.println("No of Keywords: "+rowSize);
		
		OperationalClass o= new OperationalClass();
		
		for (int i=1; i<=rowSize; i++) 
		{
			// Store keywords
			String key = s.getRow(i).getCell(0).getStringCellValue();
			System.out.println(key);
			
			if(key.equals("MaximizeWindow"))
			{
				o.maximize(driver);
			}
			else if(key.equals("OpenApplication"))
			{
				o.url(driver);
			}
			else if(key.equals("EnterUsername"))
			{
				o.enterUsername(driver, "Admin");
			}
			else if(key.equals("EnterPassword"))
			{
				o.enterPassword(driver, "<PASSWORD>");
			}
			else if(key.equals("ClickOnLoginButton"))
			{
				o.clickOnLogin(driver);
			}
			else if(key.equals("ClickOnWelcomeAdmin"))
			{
				o.clickOnWelcomeAdmin(driver);
				Thread.sleep(2000);
			}
		
			else if(key.equals("ClickOnLogoutButton"))
			{
				o.clickOnLogout(driver);
			}
			else if(key.equals("CloseBrowser"))
			{
				o.closeBrowser(driver);
			}
		}
		
	}

}
<file_sep>/testNG/A.java
package testNG;

import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

public class A {
	
	 @BeforeTest
	  public void beforeTest() 
	 {
		 System.out.println("Client-A");
	  }
	
  @Test
  public void parallel_A() 
  {
	  System.out.println("Developer-A");
  }
 
  @AfterTest
  public void afterTest() 
  {
	  System.out.println("Tester-A");
  }

}
<file_sep>/hybridDemo/ReadExcelClass.java
package hybridDemo;

public class ReadExcelClass {

}
<file_sep>/testNG/DataDriven_OrangeHRM.java
package testNG;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import pom_PageObjectModel.FA_POM;
import pom_PageObjectModel.OrangeHRM_POM;

public class DataDriven_OrangeHRM {
	
	WebDriver driver;
	
	 @BeforeTest
	  public void beforeTest() throws Exception 
	  {
		  System.setProperty("webdriver.chrome.driver", "C:\\Users\\Sonali\\Desktop\\Automation\\BrowserExtenssion\\chromedriver.exe");
		  driver=new ChromeDriver();
		  Thread.sleep(5000);
		  driver.manage().window().maximize();
		  Thread.sleep(5000);
	  }
	
  @Test(dataProvider = "dp", priority= 2)
  public void fA(String username, String password) throws Exception 
  {
	  FA_POM f= new FA_POM();
	  
	  f.url(driver);
	  Thread.sleep(2000);
	  f.enterUsername(driver, username);
	  Thread.sleep(2000);
	  f.enterPassword(driver, <PASSWORD>);
	  Thread.sleep(2000);
	  f.selectCompany(driver, 0);
	  f.clickOnLogin(driver);
	  Thread.sleep(2000);
	  f.clickOnLogout(driver);
	  
  }
  
  @Test(dataProvider = "dp", priority= 1)
  public void orangeHRM(String username, String password) throws Exception 
  {
	  OrangeHRM_POM o= new OrangeHRM_POM();
	  
	  o.url(driver);
	  Thread.sleep(2000);
	  o.enterUsername(driver, username);
	  Thread.sleep(2000);
	  o.enterPassword(driver, password);
	  Thread.sleep(2000);
	  o.clickOnLogin(driver);
	  Thread.sleep(2000);
	  o.clickOnWelcomeAdmin(driver);
	  Thread.sleep(2000);
	  o.clickOnLogout(driver);
	  
  }
  
  
  //Create your own DataProvider Annotation
//  @DataProvider
//  public Object[][] dp1()
//  {
//	  return new Object[][] {
//		  
//	  };
//  }

  @DataProvider
  public Object[][] dp() {
    return new Object[][] {
      new Object[] { "Admin", "admin123" },
      new Object[] { "frontuser1", "frontuser1" },
      new Object[] { "Admin", "admin@123" },
      new Object[] { "sys", "system" },
      new Object[] { "Admin", "admin123" },
      new Object[] { "frontuser1", "frontuser1" },
    };
  }
 

  @AfterTest
  public void afterTest() {
	  
	  driver.close();
  }

}
<file_sep>/basicPrograms/LoginUsing_Xpath_DialogBox.java
package basicPrograms;

import javax.swing.JOptionPane;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class LoginUsing_Xpath_DialogBox {
	//Note: X-path:XML path: Extensible Markup Language
	//Types of X-path:
	//1) Absolute XPath: It starts with ROOT NODE and its prefix is '/'
	//2) Relative XPath: It shows with CURRENT NODE and its prefix is '//'
	 	//Syntax: //TagName[@PropertyName= 'PropertyValue']
		//For Example: //input[@type='Submit']


	public static void main(String[] args) throws Exception {
		
		System.setProperty("webdriver.chrome.driver", "C:\\Users\\Sonali\\Desktop\\Automation\\BrowserExtenssion\\chromedriver.exe");
		WebDriver driver = new ChromeDriver();
		Thread.sleep(2000);
		driver.manage().window().maximize();
		
		driver.get("https://opensource-demo.orangehrmlive.com/index.php/auth/login");
		
		// DataType variable = class.method("message");
		String unm=JOptionPane.showInputDialog("Enter Username"); 
		driver.findElement(By.xpath("//*[@id=\"txtUsername\"]")).sendKeys(unm);
		
		String pwd=JOptionPane.showInputDialog("Enter Password");
		driver.findElement(By.xpath("//*[@id=\"txtPassword\"]")).sendKeys(pwd);
		
		driver.findElement(By.xpath("//*[@id=\"btnLogin\"]")).click();
		
		driver.findElement(By.xpath("//*[@id=\"welcome\"]")).click();
		Thread.sleep(2000);
		
		driver.findElement(By.xpath("//*[@id=\"welcome-menu\"]/ul/li[2]/a")).click();
		
		driver.close();



		
}

}
<file_sep>/poi/WriteData.java
package poi;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class WriteData {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		
		FileInputStream file= new FileInputStream("C:\\Users\\Sonali\\Desktop\\Automation\\POI.xlsx");
		XSSFWorkbook w= new XSSFWorkbook(file);
	//XSSFSheet s= w.createSheet("WriteData"); // When first time creating executing a program
	XSSFSheet s= w.getSheet("WriteData"); // After executing the sheet for first time and for edit the sheet we use getSheet method
		
		XSSFRow r1= s.createRow(0);
		r1.createCell(0).setCellValue("Sonali");
		r1.createCell(1).setCellValue("Ingle");
		r1.createCell(2).setCellValue("Chembur");
		
		XSSFRow r2= s.createRow(2);
		r2.createCell(0).setCellValue("Name");
		r2.createCell(1).setCellValue("Location");
		r2.createCell(2).setCellValue("Stream");
		r2.createCell(3).setCellValue("Year");
		r2.createCell(4).setCellValue("marks");
		
		XSSFRow r3= s.createRow(3);
		r3.createCell(0).setCellValue("Anna");
		r3.createCell(1).setCellValue("USA");
		r3.createCell(2).setCellValue("Comps");
		r3.createCell(3).setCellValue("2018");
		r3.createCell(4).setCellValue("89");
	
		FileOutputStream out=new FileOutputStream("C:\\Users\\Sonali\\Desktop\\Automation\\POI.xlsx");
		w.write(out);

	}

}
<file_sep>/dataBaseTesting/DBTesting.java
package dataBaseTesting;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DBTesting {
	
	// Connection -> Create connection between DB and Selenium
	// Driver Manager ----> Provide Connection
	//Statement ----> Execute SQL Commands
	// ResultSet -> Final Output -----> SELECT * FROM TABLENAME

	public static void main(String[] args) throws SQLException {


		// Step1: Create object of connection class
		Connection c = DriverManager.getConnection("jdbc:mysql://db4free.net:3306/testing_squad", "sonali_admin", "sonali123");
		
		//Step 2: Create object of Statement class
		Statement s= c.createStatement();
		
		// INSERT DATA ---> INSERT(DML)
		//s.execute("INSERT INTO Testing VALUES (101, 'sonali')");
//		s.execute("INSERT INTO Testing VALUES (102, 'Alice')");
//		s.execute("INSERT INTO Testing VALUES (103, 'john')");
//		s.execute("INSERT INTO Testing VALUES (104, 'liaz')");
//		s.execute("INSERT INTO Testing VALUES (105, 'lee')");
		
		//ADD coloumn -> ALTER (DDL)
	//	s.execute("ALTER TABLE Testing ADD Location CHARACTER (100)");
		//s.execute("ALTER TABLE Testing ADD Marks VARCHAR (10)");
		
		//UPDATE LOCATION -----> UPDATE (DDL)
//		s.execute("UPDATE Testing SET Location = 'India' WHERE ID=101");
//		s.execute("UPDATE Testing SET Location = 'USA' WHERE ID=102");
//		s.execute("UPDATE Testing SET Location = 'UK' WHERE ID=103");
//		s.execute("UPDATE Testing SET Location = 'Paris' WHERE ID=104");
//		s.execute("UPDATE Testing SET Location = 'America' WHERE ID=105");

		// CHANGE COLUMN NAME ---> ALTER(DDL)
	//	s.execute("ALTER TABLE Testing CHANGE Location ADDRESS CHARACTER(50)");
		
		//DELETE COLUMN -------> ALTER (DDL)
	//	s.execute("ALTER TABLE Testing DROP COLUMN Marks");
		
		// DELETE ROW ----> ALTER(DDL)
		//s.execute("DELETE FROM Testing WHERE ID=102");
		
		//RENAME TABLE NAME------> RENAME (DDL)
		//s.execute("RENAME TABLE TESTING TO TESTING_SONALI");
		
		// TRUNCATE (DDL) ----> delete whole data 
	//	s.execute("TRUNCATE TABLE TESTING_SONALI");
		
		// DELETE STRUCTURE OF TABLE ----> DROP(DDL)
		//s.execute("DROP TABLE TESTING");
		
		
		// Step 3: Create object of ResultSet
		ResultSet rs=s.executeQuery("SELECT * FROM TESTING_SONALI ORDER BY ID");
		
		
		// Step 4: Loop
		while(rs.next()==true)
		{
			int id=rs.getInt(1);
			String name = rs.getString(2);
			//String loc= rs.getString(3);
			
			System.out.println(id + "\t\t"+ name );
			
		}
		
	}

}
<file_sep>/basicPrograms/MouseHover_OrangeHRM.java
package basicPrograms;

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;

public class MouseHover_OrangeHRM {

	public static void main(String[] args) throws Exception {
		// Launch browser
		System.setProperty("webdriver.chrome.driver", "C:\\Users\\Sonali\\Desktop\\Automation\\BrowserExtenssion\\chromedriver.exe");
		WebDriver driver= new ChromeDriver();
		Thread.sleep(5000);
		driver.manage().window().maximize();
		
		// URL
		driver.get("https://opensource-demo.orangehrmlive.com/index.php/auth/login");
		
		// USername
		driver.findElement(By.xpath("//*[@id=\"txtUsername\"]")).sendKeys("Admin");
		
		//Password
		driver.findElement(By.xpath("//*[@id=\"txtPassword\"]")).sendKeys("<PASSWORD>");
		
		//Login
		driver.findElement(By.xpath("//*[@id=\"btnLogin\"]")).click();
		
		//********* Mouse Hover***********
		//Step 1: Create object of Actions class
		Actions a = new Actions(driver);
		
		//Step 2: Create list with WebElement
		List<WebElement> ls=driver.findElements(By.xpath("//*[@id=\"mainMenuFirstLevelUnorderedList\"]/li"));
		
		//Step 3: Store last Module in one variable
		int size= ls.size();
		System.out.println("Number of Modules: "+size);
		
		
		// Step 3: Loop
		for(int i=1; i<=size; i++)
		{
			// wait
			Thread.sleep(2000);
			
			// Display Module name
			System.out.println(driver.findElement(By.xpath("//*[@id=\"mainMenuFirstLevelUnorderedList\"]/li["+i+"]")).getText());
			
			// Perform Mouse hover
			a.moveToElement(driver.findElement(By.xpath("//*[@id=\"mainMenuFirstLevelUnorderedList\"]/li["+i+"]"))).click().perform();
		}
		

	}

}
<file_sep>/testNG/FA_ParallelTesting.java
package testNG;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import pom_PageObjectModel.FA_POM;

public class FA_ParallelTesting {
	
	WebDriver driver;
	
	@BeforeTest
	public void beforeTest() 
	{
		System.setProperty("webdriver.chrome.driver", "C:\\Users\\Sonali\\Desktop\\Automation\\BrowserExtenssion\\chromedriver.exe");
		driver= new ChromeDriver();
		driver.manage().window().maximize();
		
	}	
	
  @Test
  public void fA() throws Exception 
  {
	  FA_POM f= new FA_POM();
	  
	  f.url(driver);
	  Thread.sleep(2000);
	  f.enterUsername(driver, "Admin");
	  f.enterPassword(driver, "<PASSWORD>");
	  f.selectCompany(driver, 0);
	  f.clickOnLogin(driver);
	    
  }
 

  @AfterTest
  public void afterTest() 
  {
	  driver.close();
  }

}
<file_sep>/testNG/OrangeHRM_ParallelTesting.java
package testNG;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import pom_PageObjectModel.OrangeHRM_POM;

public class OrangeHRM_ParallelTesting {
	 
WebDriver driver;
	
	@BeforeTest
	public void beforeTest() throws Exception 
	{
		System.setProperty("webdriver.chrome.driver", "C:\\Users\\Sonali\\Desktop\\Automation\\BrowserExtenssion\\chromedriver.exe");
		driver= new ChromeDriver();
		driver.manage().window().maximize();
		Thread.sleep(2000);
	}	
	
  @Test
  public void oRangeHRM() throws Exception 
  {
	  OrangeHRM_POM o= new OrangeHRM_POM();
	  
	  o.url(driver);
	  Thread.sleep(2000);
	  o.enterUsername(driver, "Admin");
	  Thread.sleep(2000);
	  o.enterPassword(driver, "<PASSWORD>");
	  Thread.sleep(2000);
	  o.clickOnLogin(driver);
	  Thread.sleep(2000);
	  o.clickOnWelcomeAdmin(driver);
	  Thread.sleep(2000);
	  o.clickOnLogout(driver);
	  
	  
	    
  }
 

  @AfterTest
  public void afterTest() 
  {
	  driver.close();
  }

}
<file_sep>/basicPrograms/MultipleDropDown_BlazeDemo.java
package basicPrograms;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;

public class MultipleDropDown_BlazeDemo {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		
		System.setProperty("webdriver.chrome.driver", "C:\\Users\\Sonali\\Desktop\\Automation\\BrowserExtenssion\\chromedriver.exe");
		WebDriver driver = new ChromeDriver();
		
		Select s;  // Globally Declaration
		
		Thread.sleep(5000);
		driver.manage().window().maximize();
		
		//URL
		driver.get("https://blazedemo.com/");
		Thread.sleep(2000);
		
		//DropDown 1:
		s = new Select(driver.findElement(By.xpath("/html/body/div[3]/form/select[1]")));
		s.selectByIndex(5);
		Thread.sleep(2000);
		
		//DropDown 2:
		s= new Select(driver.findElement(By.xpath("/html/body/div[3]/form/select[2]")));
		s.selectByValue("New York");
		Thread.sleep(2000);
		
		//Find Flight Button
		driver.findElement(By.xpath("/html/body/div[3]/form/div/input")).click();
		Thread.sleep(2000);
		
		// CLose Browser
		driver.close();
		

	}

}
