Skip to content

Commit b962230

Browse files
committed
Base solution file
0 parents  commit b962230

Some content is hidden

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

73 files changed

+2180
-0
lines changed

.classpath

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15+
<attributes>
16+
<attribute name="optional" value="true"/>
17+
<attribute name="maven.pomderived" value="true"/>
18+
</attributes>
19+
</classpathentry>
20+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
21+
<attributes>
22+
<attribute name="maven.pomderived" value="true"/>
23+
</attributes>
24+
</classpathentry>
25+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
26+
<attributes>
27+
<attribute name="maven.pomderived" value="true"/>
28+
</attributes>
29+
</classpathentry>
30+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
31+
<attributes>
32+
<attribute name="maven.pomderived" value="true"/>
33+
</attributes>
34+
</classpathentry>
35+
<classpathentry kind="output" path="target/classes"/>
36+
</classpath>

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/

.project

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>com.sampleAutomationFramework</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+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>

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

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
3+
org.eclipse.jdt.core.compiler.compliance=1.5
4+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5+
org.eclipse.jdt.core.compiler.source=1.5

.settings/org.eclipse.m2e.core.prefs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
#Keywords Summary :
3+
#Feature: List of scenarios.
4+
#Scenario: Business rule through list of steps with arguments.
5+
#Given: Some precondition step
6+
#When: Some key actions
7+
#Then: To observe outcomes or validation
8+
#And,But: To enumerate more Given,When,Then steps
9+
#Scenario Outline: List of steps for data-driven as an Examples and <placeholder>
10+
#Examples: Container for s table
11+
#Background: List of steps run before each of the scenarios
12+
#""" (Doc Strings)
13+
#| (Data Tables)
14+
#@ (Tags/Labels):To group Scenarios
15+
#<> (placeholder)
16+
#""
17+
## (Comments)
18+
#Sample Feature Definition Template
19+
@tag
20+
Feature: TurnUpPortalLogin
21+
22+
@Login
23+
Scenario: Check if the user logs into the application successfully
24+
Given I have launched the browser and entered the URL
25+
When I input valid username, password and click on Login button
26+
Then I should see the home page and validate with any of the button name on the home page

Screenshots/Login.png

324 KB
Loading

TestData/TestData.xlsx

7.83 KB
Binary file not shown.

pom.xml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.sampleAutomationFramework</groupId>
4+
<artifactId>com.sampleAutomationFramework</artifactId>
5+
<version>0.0.1-SNAPSHOT</version>
6+
7+
<dependencies>
8+
9+
<dependency>
10+
<groupId>org.seleniumhq.selenium</groupId>
11+
<artifactId>selenium-java</artifactId>
12+
<version>2.53.1</version>
13+
</dependency>
14+
15+
<dependency>
16+
<groupId>junit</groupId>
17+
<artifactId>junit</artifactId>
18+
<version>4.12</version>
19+
<scope>test</scope>
20+
</dependency>
21+
22+
<dependency>
23+
<groupId>info.cukes</groupId>
24+
<artifactId>cucumber-junit</artifactId>
25+
<version>1.2.4</version>
26+
<scope>test</scope>
27+
</dependency>
28+
29+
<dependency>
30+
<groupId>info.cukes</groupId>
31+
<artifactId>cucumber-java</artifactId>
32+
<version>1.2.4</version>
33+
</dependency>
34+
35+
<dependency>
36+
<groupId>org.testng</groupId>
37+
<artifactId>testng</artifactId>
38+
<version>6.13.1</version>
39+
<scope>test</scope>
40+
</dependency>
41+
42+
<dependency>
43+
<groupId>org.apache.httpcomponents</groupId>
44+
<artifactId>httpclient</artifactId>
45+
<version>4.5.2</version>
46+
</dependency>
47+
48+
<dependency>
49+
<groupId>net.sourceforge.jexcelapi</groupId>
50+
<artifactId>jxl</artifactId>
51+
<version>2.6.12</version>
52+
</dependency>
53+
54+
<dependency>
55+
<groupId>org.apache.poi</groupId>
56+
<artifactId>poi</artifactId>
57+
<version>3.9</version>
58+
</dependency>
59+
60+
<dependency>
61+
<groupId>org.apache.poi</groupId>
62+
<artifactId>poi-ooxml</artifactId>
63+
<version>3.9</version>
64+
</dependency>
65+
66+
<dependency>
67+
<groupId>log4j</groupId>
68+
<artifactId>log4j</artifactId>
69+
<version>1.2.17</version>
70+
</dependency>
71+
72+
<dependency>
73+
<groupId>info.cukes</groupId>
74+
<artifactId>cucumber-junit</artifactId>
75+
<version>1.2.4</version>
76+
<scope>test</scope>
77+
</dependency>
78+
79+
<dependency>
80+
<groupId>info.cukes</groupId>
81+
<artifactId>cucumber-java</artifactId>
82+
<version>1.2.4</version>
83+
</dependency>
84+
85+
<dependency>
86+
<groupId>info.cukes</groupId>
87+
<artifactId>cucumber-testng</artifactId>
88+
<version>1.1.5</version>
89+
</dependency>
90+
91+
92+
</dependencies>
93+
94+
95+
96+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package cucumberStepDefinitionPackage;
2+
3+
import cucumber.api.java.en.Given;
4+
import cucumber.api.java.en.Then;
5+
import cucumber.api.java.en.When;
6+
import helperPackage.BrowserFactory;
7+
import pagesPackage.HomePage;
8+
import pagesPackage.LoginPage;
9+
10+
public class loginStepDefinition {
11+
12+
@Given("^I have launched the browser and entered the URL$")
13+
public void i_have_launched_the_browser_and_entered_the_URL() throws Throwable {
14+
//Initiate driver and launch url
15+
BrowserFactory.startBrowser("chrome");
16+
}
17+
18+
@When("^I input valid username, password and click on Login button$")
19+
public void i_input_valid_username_password_and_click_on_Login_button() throws Throwable {
20+
//Initiate PO for login page
21+
LoginPage login_page = new LoginPage();
22+
23+
//perform login steps
24+
login_page.loginSteps();
25+
}
26+
27+
@Then("^I should see the home page and validate with any of the button name on the home page$")
28+
public void i_should_see_the_home_page_and_validate_with_any_of_the_button_name_on_the_home_page() throws Throwable {
29+
//Initiate PO for home page and validate
30+
HomePage home_page = new HomePage();
31+
home_page.validateHomePage();
32+
33+
//quit the instance of driver
34+
BrowserFactory.driver.quit();
35+
}
36+
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package cucumberTestPackage;
2+
3+
import org.junit.runner.RunWith;
4+
5+
import cucumber.api.CucumberOptions;
6+
import cucumber.api.junit.Cucumber;
7+
8+
@RunWith(Cucumber.class)
9+
@CucumberOptions(features="Cucumber Feature Files",glue={"cucumberStepDefinitionPackage"})
10+
public class cucumberTestClass {
11+
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package helperPackage;
2+
3+
import org.openqa.selenium.WebDriver;
4+
import org.openqa.selenium.chrome.ChromeDriver;
5+
import org.openqa.selenium.firefox.FirefoxDriver;
6+
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
7+
import org.openqa.selenium.ie.InternetExplorerDriver;
8+
import org.testng.annotations.Parameters;
9+
10+
import utilityPackage.ConfigReader;
11+
12+
13+
public class BrowserFactory {
14+
15+
//Global driver
16+
public static WebDriver driver;
17+
18+
//@Parameters("browserName")
19+
//A custom method to choose the browser on which the test need to be executed
20+
public static void startBrowser(String browserName)
21+
{
22+
//choose Firefox browser
23+
if (browserName.equalsIgnoreCase("firefox"))
24+
{
25+
driver = new FirefoxDriver();
26+
}
27+
//choose Chrome browser
28+
else if (browserName.equalsIgnoreCase("chrome"))
29+
{
30+
System.setProperty("webdriver.chrome.driver", ConfigReader.getChromePath());
31+
driver = new ChromeDriver();
32+
}
33+
//choose IE browser
34+
else if (browserName.equalsIgnoreCase("ie"))
35+
{
36+
System.setProperty("webdriver.chrome.driver", ConfigReader.getChromePath());
37+
driver = new InternetExplorerDriver();
38+
}
39+
//choose Headless browser
40+
if (browserName.equalsIgnoreCase("headless"))
41+
{
42+
driver = new HtmlUnitDriver();
43+
}
44+
45+
//maximize browser
46+
driver.manage().window().maximize();
47+
48+
//launch the url
49+
driver.get(ConfigReader.getURL());
50+
51+
}
52+
53+
}
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package pagesPackage;
2+
3+
import java.util.concurrent.TimeUnit;
4+
5+
import org.openqa.selenium.By;
6+
import org.openqa.selenium.WebElement;
7+
import org.openqa.selenium.support.FindBy;
8+
import org.openqa.selenium.support.How;
9+
import org.openqa.selenium.support.PageFactory;
10+
11+
import helperPackage.BrowserFactory;
12+
13+
public class HomePage {
14+
15+
//POM constructor
16+
public HomePage()
17+
{
18+
PageFactory.initElements(BrowserFactory.driver, this);
19+
}
20+
21+
//Add new Job button
22+
@FindBy(how = How.ID, using = "addnewjob")
23+
static WebElement addJobButton;
24+
25+
//Method to check if home page is displayed
26+
public void validateHomePage()
27+
{
28+
//Verification
29+
BrowserFactory.driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
30+
31+
boolean verifyMsg = addJobButton.isDisplayed();
32+
33+
if(verifyMsg == true)
34+
{
35+
System.out.println("Test Pass, login successful");
36+
}
37+
else
38+
{
39+
System.out.println("Test Fail, login failed");
40+
41+
}
42+
}
43+
44+
45+
46+
}

0 commit comments

Comments
 (0)