forked from saranyaeaswaran/SeleniumTesting
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBaseTest.java
More file actions
91 lines (72 loc) · 2.98 KB
/
Copy pathBaseTest.java
File metadata and controls
91 lines (72 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package allTests;
import java.lang.reflect.Method;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
public abstract class BaseTest extends FrameworkUtility {
@BeforeSuite
public void initilizeDriver() throws NoSuchFieldException {
URL = readConfigurationFile("URL");
if(URL.trim().length() > 0){
String browserName = readConfigurationFile("BrowserName");
if (browserName.trim().equalsIgnoreCase("firefox")) {
System.setProperty(FrameworkConstants.FIREFOX_DRIVER_KEY,FrameworkConstants.FIREFOX_DRIVER_PATH);
driver = new FirefoxDriver();
driver.manage().window().maximize();
initObjects();
}else if (browserName.trim().equalsIgnoreCase("chrome")) {
System.setProperty(FrameworkConstants.CHROME_DRIVER_KEY,FrameworkConstants.CHROME_DRIVER_PATH);
driver = new ChromeDriver();
driver.manage().window().maximize();
initObjects();
}else {
System.out.println("Invalid BrowserName");
throw new IllegalStateException("Failed to invoke WebBrowser.Invalid BrowserName..");
}
}
driver.get(URL);
}
/*****************************************************************************************************************/
@AfterSuite
public void quitDrivers() {
driver.quit();
}
/************************************************************************************************************************/
/*
* method.getName() returns the name of the current test method during run time.
* */
@BeforeMethod
public void beforeMethod(Method method) {
}
/****************************************************************************************************************/
@AfterMethod
public void afterMethod(Method method) {
}
/****************************************************************************************************************/
@BeforeClass
public void beforeClass() {
}
/****************************************************************************************************************/
@AfterClass
public void closeApplication(){
}
/****************************************************************************************************************/
/*Initialize objects of JS, jsActions, Actions and WindowActions classes*/
public void initObjects() {
js = (JavascriptExecutor) driver;
jsActions = new JavaScriptActions();
action = new Actions(driver);
Wait = new CustomWait();
WindowHandler = new WindowActions();
AlertHandler = new AlertActions();
KeyboardHandler = new KeyboardActions();
}
}
/*****************************************************************************************************************/