Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sammijss committed Aug 16, 2020
0 parents commit 49968cd
Show file tree
Hide file tree
Showing 25 changed files with 497 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>desktop-app-automation</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
4 changes: 4 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
8 changes: 8 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
9 changes: 9 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
###################################################################################################
# This automation usages 'Cucumber' & 'Winium' Framework to automate the Windows Calculator. #
# #
# How to use? #
# 1: This is Java Maven project #
# 2: Open the 'Runner.java' file #
# 3: Right click and click on 'Run As' -> 'Unit Test' #
# Remark: Use 100% Display Setting instead of 125% for better result. #
###################################################################################################
96 changes: 96 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>

<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">
<modelVersion>4.0.0</modelVersion>

<groupId>desktop-app-automation</groupId>
<artifactId>desktop-app-automation</artifactId>
<version>0.0.1-SNAPSHOT</version>

<name>desktop-app-automation</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.2gis.winium</groupId>
<artifactId>winium-webdriver</artifactId>
<version>0.1.0-1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.2.2</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>6.2.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Binary file added src/main/java/CalculatorAutomation.mp4
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package desktop_app_automation.desktop_app_automation;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
36 changes: 36 additions & 0 deletions src/main/java/features/calculator.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#Author: [email protected]
#Keywords Summary :
#Feature: List of scenarios.
#Scenario: Business rule through list of steps with arguments.
#Given: Some precondition step
#When: Some key actions
#Then: To observe outcomes or validation
#And,But: To enumerate more Given,When,Then steps
#Scenario Outline: List of steps for data-driven as an Examples and <placeholder>
#Examples: Container for s table
#Background: List of steps run before each of the scenarios
#""" (Doc Strings)
#| (Data Tables)
#@ (Tags/Labels):To group Scenarios
#<> (placeholder)
#""
## (Comments)
#Sample Feature Definition Template
@tag
Feature: This feature file will automate the Windows Calculator
I want to use this template for my feature file

@tag1
Scenario: Launch Winium Desktop Driver Exe
When Launch Winium Desktop Driver
Then Validate Winium Desktop Driver Launch

@tag2
Scenario: Launch Windows Calculator Exe
When Launch Windows Calculator
Then Validate Windows Calculator Launch

@tag3
Scenario: Perform Addition For Example 1, 2, 3
When Perform Addition of 1+2+3
Then Validate Addition of 1+2+3
14 changes: 14 additions & 0 deletions src/main/java/runner/Runner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package runner;

import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(
features={"src/main/java/features/calculator.feature"},
glue="stepdefinitions")

public class Runner {
/* Nothing to do here */
}
71 changes: 71 additions & 0 deletions src/main/java/stepdefinitions/CalculatorSteps.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package stepdefinitions;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.winium.DesktopOptions;
import org.openqa.selenium.winium.WiniumDriver;

import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;

public class CalculatorSteps {

private String path = "C:\\Windows\\System32\\calc.exe";
private String driverURL = "http://localhost:9999";
static private WiniumDriver driver;
static private String result;

@When("Launch Windows Calculator")
public void LaunchWindowsCalculator() {
System.out.println("Launching Windows Calculator");

URL url = null;
try {
url = new URL(driverURL);
} catch (MalformedURLException e) {
e.printStackTrace();
System.exit(0);
}
DesktopOptions option = new DesktopOptions();
option.setApplicationPath(path);
option.setLaunchDelay(1000);
driver = new WiniumDriver(url, option);
}

@Then("Validate Windows Calculator Launch")
public void ValidateLaunchWindowsCalculator() {
System.out.println("Windows Calculator Launched Successfully");
}

@When("Perform Addition of 1+2+3")
public void PerformAddition() throws InterruptedException {
System.out.println("Perform Addition of 1+2+3");

Thread.sleep(2000); //Wait for application to launch

WebElement winelement = driver.findElement(By.name("Calculator"));
winelement.click(); //bring the calculator in front

driver.findElement(By.name("One")).click();
driver.findElement(By.name("Plus")).click();
driver.findElement(By.name("Two")).click();
driver.findElement(By.name("Plus")).click();
driver.findElement(By.name("Three")).click();
driver.findElement(By.name("Equals")).click();

result = driver.findElement(By.id("CalculatorResults")).getAttribute("Name");
}

@Then("Validate Addition of 1+2+3")
public void ValidateAdditionResult( ) {
System.out.println("Validate Addition of 1+2+3");
if (result.compareTo("6") != 0) {
System.out.println("Result of 1+2+3 is correct: " + result);
} else {
System.out.println("Result of 1+2+3 is not correct: " + result);
}
}
}
27 changes: 27 additions & 0 deletions src/main/java/stepdefinitions/WiniumDesktopDriverSteps.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package stepdefinitions;

import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;

public class WiniumDesktopDriverSteps {

private String path = System.getProperty("user.dir") + "\\src\\main\\java\\winium\\Winium.Desktop.Driver\\Winium.Desktop.Driver.exe";

@When("Launch Winium Desktop Driver")
public void LaunchWiniumDesktopDriver() {
System.out.println("Launching Winium Desktop Driver");

try {
Runtime.getRuntime().exec(path);
Thread.sleep(2000); //wait to start the exe
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}

@Then("Validate Winium Desktop Driver Launch")
public void ValidateLaunchWiniumDesktopDriver() {
System.out.println("Winium Desktop Driver Launched Successfully");
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package desktop_app_automation.desktop_app_automation;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
5 changes: 5 additions & 0 deletions target/classes/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Manifest-Version: 1.0
Built-By: SSrivastava1
Build-Jdk: 1.8.0_261
Created-By: Maven Integration for Eclipse

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Generated by Maven Integration for Eclipse
#Sun Aug 16 09:25:03 IST 2020
version=0.0.1-SNAPSHOT
groupId=desktop-app-automation
m2e.projectName=desktop-app-automation
m2e.projectLocation=C\:\\Users\\ssrivastava1\\eclipse-workspace\\desktop-app-automation
artifactId=desktop-app-automation
Loading

0 comments on commit 49968cd

Please sign in to comment.