Base Class

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

package BasePackage;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;

public class BaseClass {

public WebDriver driver;

@Parameters({"browser","URL"})
@BeforeTest
public void InitialDriver(String browsername,String Site) throws IOException
{

/*
* Properties pro = new Properties(); FileInputStream fis = new
FileInputStream(
* "./property/data.properties"); pro.load(fis);
*/

if (browsername.equalsIgnoreCase("Chrome")) {

System.setProperty("webdriver.chrome.driver",
"./Drivers/chromedriver.exe");

driver = new ChromeDriver(options);


}

else if (browsername.equalsIgnoreCase("IE")) {

System.setProperty("webdriver.ie.driver",
"./Drivers/IEDriverServer.exe");
driver = new InternetExplorerDriver();

} else if (browsername.equalsIgnoreCase("Firefox")) {
System.setProperty("webdriver.gecko.driver",
"./Drivers/geckodriver.exe");
driver = new InternetExplorerDriver();

driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

driver.manage().window().maximize();
driver.get(URL)

@AfterTest
public void closedriver() {

driver.close();
driver.quit();
}

You might also like