Skip to content

Commit f58ed9c

Browse files
author
Mayur Shah
committed
initial commit
0 parents  commit f58ed9c

File tree

90 files changed

+3267
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+3267
-0
lines changed

.classpath

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="KeywordDrivenFramework"/>
5+
<classpathentry kind="src" path="Page Object Model"/>
6+
<classpathentry excluding="src/|KeywordDrivenFramework/|Page Object Model/|resource/" kind="src" path=""/>
7+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
8+
<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
9+
<classpathentry kind="lib" path="lib/byte-buddy-1.7.5.jar"/>
10+
<classpathentry kind="lib" path="lib/client-combined-3.6.0.jar"/>
11+
<classpathentry kind="lib" path="lib/commons-codec-1.10.jar"/>
12+
<classpathentry kind="lib" path="lib/commons-collections4-4.1.jar"/>
13+
<classpathentry kind="lib" path="lib/commons-exec-1.3.jar"/>
14+
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
15+
<classpathentry kind="lib" path="lib/gson-2.8.0.jar"/>
16+
<classpathentry kind="lib" path="lib/guava-23.0.jar"/>
17+
<classpathentry kind="lib" path="lib/httpclient-4.5.3.jar"/>
18+
<classpathentry kind="lib" path="lib/httpcore-4.4.6.jar"/>
19+
<classpathentry kind="lib" path="lib/jna-4.1.0.jar"/>
20+
<classpathentry kind="lib" path="lib/jna-platform-4.1.0.jar"/>
21+
<classpathentry kind="lib" path="lib/junit-4.12.jar"/>
22+
<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
23+
<classpathentry kind="lib" path="lib/log4j-api-2.9.1.jar"/>
24+
<classpathentry kind="lib" path="lib/log4j-core-2.9.1.jar"/>
25+
<classpathentry kind="lib" path="lib/poi-3.17.jar"/>
26+
<classpathentry kind="lib" path="lib/curvesapi-1.04.jar"/>
27+
<classpathentry kind="lib" path="lib/poi-excelant-3.17.jar"/>
28+
<classpathentry kind="lib" path="lib/poi-ooxml-3.17.jar"/>
29+
<classpathentry kind="lib" path="lib/poi-ooxml-schemas-3.17.jar"/>
30+
<classpathentry kind="lib" path="lib/poi-scratchpad-3.17.jar"/>
31+
<classpathentry kind="lib" path="lib/xmlbeans-2.6.0.jar"/>
32+
<classpathentry kind="lib" path="lib/commons-io-2.6.jar"/>
33+
<classpathentry kind="output" path="bin"/>
34+
</classpath>

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Compiled class file
2+
*.class
3+
4+
# Log file
5+
*.log
6+
log*.txt
7+
8+
# BlueJ files
9+
*.ctxt
10+
11+
# Mobile Tools for Java (J2ME)
12+
.mtj.tmp/
13+
14+
# Package Files #
15+
#*.jar#
16+
*.war
17+
*.ear
18+
*.zip
19+
*.tar.gz
20+
*.rar
21+
22+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23+
hs_err_pid*
24+
25+
test-output
26+
27+
test-output/
28+
29+
bin
30+
31+
bin/
32+
33+
test-output*
34+
bin*
35+
test-output/*
36+
bin/*

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>OnlineAutomation</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

.settings/org.eclipse.jdt.core.prefs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package com.softwaretestingboard.config;
2+
3+
import static com.softwaretestingboard.examples.execution.DriverScript.OR;
4+
5+
import java.util.concurrent.TimeUnit;
6+
7+
import org.openqa.selenium.By;
8+
import org.openqa.selenium.WebDriver;
9+
import org.openqa.selenium.chrome.ChromeDriver;
10+
import org.openqa.selenium.edge.EdgeDriver;
11+
import org.openqa.selenium.firefox.FirefoxDriver;
12+
import org.openqa.selenium.remote.DesiredCapabilities;
13+
14+
import com.softwaretestingboard.examples.execution.DriverScript;
15+
import com.softwaretestingboard.utility.Log;
16+
17+
public class ActionKeywords {
18+
19+
public static WebDriver driver;
20+
21+
public static void openBrowser(String object, String data) {
22+
Log.info("Opening Browser");
23+
try {
24+
if (data.equals("Mozilla")) {
25+
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
26+
capabilities.setCapability("marionette", false);
27+
driver = new FirefoxDriver();
28+
Log.info("Mozilla browser started");
29+
} else if (data.equals("IE")) {
30+
31+
String exePath = "C:\\Users\\HEMANT\\Desktop\\Softwares\\selenium-java-3.4.0\\MicrosoftEdgeDriver\\MicrosoftWebDriver.exe";
32+
System.out.println("launching Microsoft Edge browser");
33+
System.setProperty("webdriver.edge.driver", exePath);
34+
35+
// launching Microsoft Edge Driver
36+
37+
driver = new EdgeDriver();
38+
39+
Log.info("Internet Edge browser started");
40+
} else if (data.equals("Chrome")) {
41+
// Dummy Code, Implement you own code
42+
String exePath = "C:\\Users\\HEMANT\\Desktop\\Softwares\\selenium-java-3.4.0\\chromedriver_win32\\chromedriver.exe";
43+
System.setProperty("webdriver.chrome.driver", exePath);
44+
driver = new ChromeDriver();
45+
Log.info("Chrome browser started");
46+
}
47+
48+
int implicitWaitTime = (10);
49+
driver.manage().timeouts().implicitlyWait(implicitWaitTime, TimeUnit.SECONDS);
50+
} catch (Exception e) {
51+
Log.info("Not able to open the Browser --- " + e.getMessage());
52+
DriverScript.bResult = false;
53+
}
54+
}
55+
56+
public static void navigate(String object, String data) {
57+
try {
58+
Log.info("Navigating to URL");
59+
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
60+
driver.get(Constants.URL);
61+
} catch (Exception e) {
62+
Log.info("Not able to navigate --- " + e.getMessage());
63+
DriverScript.bResult = false;
64+
}
65+
}
66+
67+
public static void click(String object, String data) {
68+
try {
69+
Log.info("Clicking on Webelement " + object);
70+
driver.findElement(By.xpath(OR.getProperty(object))).click();
71+
} catch (Exception e) {
72+
Log.error("Not able to click --- " + e.getMessage());
73+
DriverScript.bResult = false;
74+
}
75+
}
76+
77+
public static void input(String object, String data) {
78+
try {
79+
Log.info("Entering the text in " + object);
80+
driver.findElement(By.xpath(OR.getProperty(object))).sendKeys(data);
81+
} catch (Exception e) {
82+
Log.error("Not able to Enter UserName --- " + e.getMessage());
83+
DriverScript.bResult = false;
84+
}
85+
}
86+
87+
public static void waitFor(String object, String data) throws Exception {
88+
try {
89+
Log.info("Wait for 5 seconds");
90+
Thread.sleep(5000);
91+
} catch (Exception e) {
92+
Log.error("Not able to Wait --- " + e.getMessage());
93+
DriverScript.bResult = false;
94+
}
95+
}
96+
97+
public static void closeBrowser(String object, String data) {
98+
try {
99+
Log.info("Closing the browser");
100+
driver.quit();
101+
} catch (Exception e) {
102+
Log.error("Not able to Close the Browser --- " + e.getMessage());
103+
DriverScript.bResult = false;
104+
}
105+
}
106+
107+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.softwaretestingboard.config;
2+
3+
public class Constants {
4+
5+
//System Variables
6+
public static final String URL = "http://demo.ohrm.softwaretestingboard.com/symfony/web/index.php/auth/login";
7+
public static final String Path_TestData = "C://Users//HEMANT//workspace//OnlineAutomation//KeywordDrivenFramework//dataEngine//DataEngine.xlsx";
8+
public static final String Path_OR = "C://Users//HEMANT//workspace//OnlineAutomation//KeywordDrivenFramework//config//OR.txt";
9+
public static final String File_TestData = "DataEngine.xlsx";
10+
public static final String KEYWORD_FAIL = "FAIL";
11+
public static final String KEYWORD_PASS = "PASS";
12+
13+
//Data Sheet Column Numbers
14+
public static final int Col_TestCaseID = 0;
15+
public static final int Col_TestScenarioID =1 ;
16+
public static final int Col_PageObject =4 ;
17+
public static final int Col_ActionKeyword =5 ;
18+
public static final int Col_RunMode =2 ;
19+
public static final int Col_Result =3 ;
20+
public static final int Col_DataSet =6 ;
21+
public static final int Col_TestStepResult =7 ;
22+
23+
// Data Engine Excel sheets
24+
public static final String Sheet_TestSteps = "Test Steps";
25+
public static final String Sheet_TestCases = "Test Cases";
26+
27+
// Test Data
28+
public static final String UserName = "hemant";
29+
public static final String Password = "hemant@123";
30+
31+
32+
33+
34+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Home Page Objects
2+
btn_MyAccount=.//*[@id='account']/a
3+
btn_LogOut=.//*[@id='account_logout']/a
4+
5+
6+
# Login Page Object
7+
txtbx_UserName=.//*[@id='txtUsername']
8+
txtbx_Password=.//*[@name='txtPassword']
9+
btn_LogIn=.//*[@id='btnLogin']
Binary file not shown.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package com.softwaretestingboard.examples.execution;
2+
3+
import java.io.FileInputStream;
4+
import java.lang.reflect.Method;
5+
import java.util.Properties;
6+
7+
import com.softwaretestingboard.config.ActionKeywords;
8+
import com.softwaretestingboard.config.Constants;
9+
import com.softwaretestingboard.utility.ExcelUtilsKey;
10+
import com.softwaretestingboard.utility.Log;
11+
12+
public class DriverScript {
13+
14+
public static Properties OR;
15+
public static ActionKeywords actionKeywords;
16+
public static String sActionKeyword;
17+
public static String sPageObject;
18+
public static Method method[];
19+
20+
public static int iTestStep;
21+
public static int iTestLastStep;
22+
public static String sTestCaseID;
23+
public static String sRunMode;
24+
public static String sData;
25+
public static boolean bResult;
26+
27+
public DriverScript() throws NoSuchMethodException, SecurityException {
28+
actionKeywords = new ActionKeywords();
29+
method = actionKeywords.getClass().getMethods();
30+
}
31+
32+
public static void main(String[] args) throws Exception {
33+
ExcelUtilsKey.setExcelFile(Constants.Path_TestData);
34+
// DOMConfigurator.configure("log4j.xml");
35+
String Path_OR = Constants.Path_OR;
36+
FileInputStream fs = new FileInputStream(Path_OR);
37+
OR = new Properties(System.getProperties());
38+
OR.load(fs);
39+
40+
DriverScript startEngine = new DriverScript();
41+
startEngine.execute_TestCase();
42+
43+
}
44+
45+
private void execute_TestCase() throws Exception {
46+
// This will return the total number of test cases mentioned in the Test
47+
// cases sheet of DataEngine.xlsx
48+
int iTotalTestCases = ExcelUtilsKey.getRowCount(Constants.Sheet_TestCases);
49+
// This loop will execute number of times equal to Total number of test
50+
// cases sheet of DataEngine.xlsx
51+
for (int iTestcase = 1; iTestcase < iTotalTestCases; iTestcase++) {
52+
bResult = true;
53+
// This is to get the Test case name from the Test Cases sheet
54+
sTestCaseID = ExcelUtilsKey.getCellData(iTestcase, Constants.Col_TestCaseID, Constants.Sheet_TestCases);
55+
// This is to get the value of the Run Mode column for the current
56+
// test case
57+
sRunMode = ExcelUtilsKey.getCellData(iTestcase, Constants.Col_RunMode, Constants.Sheet_TestCases);
58+
if (sRunMode.equals("Yes")) {
59+
// This is the condition statement on RunMode value
60+
Log.startTestCase(sTestCaseID);
61+
// Only if the value of Run Mode is 'Yes', this part of code
62+
// will execute
63+
iTestStep = ExcelUtilsKey.getRowContains(sTestCaseID, Constants.Col_TestCaseID,
64+
Constants.Sheet_TestSteps);
65+
66+
iTestLastStep = ExcelUtilsKey.getTestStepsCount(Constants.Sheet_TestSteps, sTestCaseID, iTestStep);
67+
bResult = true;
68+
// This loop will execute number of times equal to Total number
69+
// of test steps
70+
for (; iTestStep < iTestLastStep; iTestStep++) {
71+
sActionKeyword = ExcelUtilsKey.getCellData(iTestStep, Constants.Col_ActionKeyword,
72+
Constants.Sheet_TestSteps);
73+
sPageObject = ExcelUtilsKey.getCellData(iTestStep, Constants.Col_PageObject,
74+
Constants.Sheet_TestSteps);
75+
sData = ExcelUtilsKey.getCellData(iTestStep, Constants.Col_DataSet, Constants.Sheet_TestSteps);
76+
execute_Actions();
77+
if (bResult == false) {
78+
ExcelUtilsKey.setCellData(Constants.KEYWORD_FAIL, iTestcase, Constants.Col_Result,
79+
Constants.Sheet_TestCases);
80+
Log.endTestCase(sTestCaseID);
81+
break;
82+
}
83+
}
84+
if (bResult == true) {
85+
ExcelUtilsKey.setCellData(Constants.KEYWORD_PASS, iTestcase, Constants.Col_Result,
86+
Constants.Sheet_TestCases);
87+
Log.endTestCase(sTestCaseID);
88+
}
89+
}
90+
}
91+
}
92+
93+
private static void execute_Actions() throws Exception {
94+
95+
for (int i = 0; i < method.length; i++) {
96+
97+
if (method[i].getName().equals(sActionKeyword)) {
98+
method[i].invoke(actionKeywords, sPageObject, sData);
99+
if (bResult == true) {
100+
ExcelUtilsKey.setCellData(Constants.KEYWORD_PASS, iTestStep, Constants.Col_TestStepResult,
101+
Constants.Sheet_TestSteps);
102+
break;
103+
} else {
104+
ExcelUtilsKey.setCellData(Constants.KEYWORD_FAIL, iTestStep, Constants.Col_TestStepResult,
105+
Constants.Sheet_TestSteps);
106+
ActionKeywords.closeBrowser("", "");
107+
break;
108+
}
109+
}
110+
}
111+
}
112+
113+
}

0 commit comments

Comments
 (0)