├── .classpath
├── .gitignore
├── .project
├── .settings
├── org.eclipse.core.resources.prefs
├── org.eclipse.jdt.core.prefs
└── org.eclipse.m2e.core.prefs
├── LICENSE
├── README.md
├── Screenshots
└── gmail_login_i_login_with_valid_credential.png
├── pom.xml
├── selenium-cucumber-java-0.0.1.pom
└── src
├── main
└── java
│ ├── appUnderTest
│ └── AndroidCalculator.apk
│ ├── browserConfigs
│ ├── browserstack_android7_chrome.properties
│ ├── browserstack_win10_chrome.properties
│ ├── local_android_app_nexus5.properties
│ ├── local_android_nexus5.properties
│ ├── saucelab_android6_chrome.properties
│ ├── saucelab_android_app.properties
│ ├── saucelab_android_app_nexus.properties
│ ├── saucelab_android_chrome.properties
│ └── saucelab_windows_chrome52.properties
│ └── platformConfigs
│ ├── browserstack.properties
│ └── saucelab.properties
└── test
├── java
├── env
│ ├── DriverUtil.java
│ ├── Hooks.java
│ └── RunCukeTest.java
└── info
│ └── seleniumcucumber
│ └── userStepDefintions
│ └── UserStepDefinitions.java
└── resources
└── features
├── calculator.feature
└── my_first.feature
/.classpath:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | /Screenshots
3 | .classpath
4 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | sc-java-testing
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/test/java=UTF-8
4 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
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.problem.forbiddenReference=warning
12 | org.eclipse.jdt.core.compiler.source=1.8
13 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 selenium-cucumber
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | selenium-cucumber-java-maven
2 | =================
3 |
4 | selenium-cucumber : Automation Testing Using Java
5 |
6 | selenium-cucumber is a behavior driven development (BDD) approach to write automation test script to test Web.
7 | It enables you to write and execute automated acceptance/unit tests.
8 | It is cross-platform, open source and free.
9 | Automate your test cases with minimal coding.
10 | [More Details](http://seleniumcucumber.info/)
11 |
12 | Documentation
13 | -------------
14 | * [Installation](https://github.com/selenium-cucumber/selenium-cucumber-java/blob/master/doc/installation.md)
15 | * [Predefined steps](https://github.com/selenium-cucumber/selenium-cucumber-java/blob/master/doc/canned_steps.md)
16 |
17 | Download a Framework
18 | --------------
19 | * Maven - https://github.com/selenium-cucumber/selenium-cucumber-java-maven-example
20 |
21 | Framework Architecture
22 | --------------
23 | Project-Name
24 | |
25 | |_src/main/java
26 | | |_appUnderTest
27 | | | |_calc.apk
28 | | | |...
29 | | |_browserConfigs
30 | | | |_saucelab_windows_chrome.properties
31 | | | |_browserstack_windows_chrome.properties
32 | | | |...
33 | | |_platformConfigs
34 | | |_saucelab.properties
35 | | |_browserstack.properties
36 | | |...
37 | |_src/main/resources
38 | |_src/test/java
39 | | |_env
40 | | | |_DriverUtil.java
41 | | | |_Hooks.java
42 | | | |_RunCukeTest.java
43 | | |_userStepDefinitions
44 | | | |_loginSteps.java
45 | | | |_signUpSteps.java
46 | | | |...
47 | |_src/test/resources
48 | | |_features
49 | | | |_login.feature
50 | | | |_signUp.feature
51 |
52 | * **src/test/resources/features** - all the cucumber features files (files .feature ext) goes here.
53 | * **src/test/java/userStepDefinition** - you can define step defintion under this package for your feature steps.
54 | * **src/test/java/env** - this package contains cucumber runner (RunCukeTest.java) where you can configure your glue code location (step defintions), define test result output format.(html, json, xml). Hooks where you can configure all before and after test settings Hooks.java, DriverUtil.java contains code for intializing driver instances for respective driver.
55 | * **src/main/java/platformConfigs** - If you want to run your test on saucelab and browserstack platforms, you need to add its configuration such as username, access key here.
56 | * **src/main/java/browserConfig** - When you run your test on remote browser/platform you have to provide capabilities and platform information here.
57 | * **src/main/java/appUnderTest** - If you are testing mobile based application you can keep your app build here.
58 |
59 | Writing a test
60 | --------------
61 |
62 | The cucumber features goes in the `features` library and should have the ".feature" extension.
63 |
64 | You can start out by looking at `features/my_first.feature`. You can extend this feature or make your own features using some of the [predefined steps](doc/canned_steps.md) that comes with selenium-cucumber.
65 |
66 |
67 | Predefined steps
68 | -----------------
69 | By using predefined steps you can automate your test cases more quickly, more efficiently and without much coding.
70 |
71 | The predefined steps are located [here](doc/canned_steps.md)
72 |
73 | Running test
74 | --------------
75 |
76 | Go to your project directory from terminal and hit following commands
77 | * `mvn test (defualt will run on local firefox browser)`
78 | * `mvn test "-Dbrowser=chrome" (to use any other browser)`
79 | * `mvn test -Dcucumber.options="classpath:features/my_first.feature"` to run specific feature.
80 | * `mvn test -Dcucumber.options="–-plugin html:target/result-html"` to generate a HTML report.
81 | * `mvn test -Dcucumber.options="–-plugin json:target/result-json"` to generate a JSON report.
82 |
83 | Running test On remote browser/platform
84 | ---------------------------------------
85 |
86 | To run test on saucelab, browserstack or any other remote browser you need to create browser config file under src/main/java/browserConfig
87 |
88 | To run on saucelab create config file with name preceding with saucelab
89 | - saucelab_windows_chrome.properties
90 | - saucelab_mac_firefox.properties
91 |
92 | * `mvn test "-Dconfig=saucelab_mac_firefox"`
93 |
94 | To run on browserstack create config file with name preceding with browserstack
95 | - browserstack_windows_chrome.properties
96 | - browserstack_mac_firefox.properties
97 |
98 | * `mvn test "-Dconfig=browserstack_mac_firefox"`
99 |
100 | Maven/Gradle Dependency
101 | -----------------------
102 |
103 | See https://jitpack.io/#selenium-cucumber/selenium-cucumber-java .
104 |
105 | License
106 | -------
107 |
108 | (The MIT License)
109 |
110 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
111 |
112 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
113 |
114 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
115 |
--------------------------------------------------------------------------------
/Screenshots/gmail_login_i_login_with_valid_credential.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/selenium-cucumber/selenium-cucumber-java-maven-example/98d5e7b4cadb6acbba8ba42266beffd3b5efc16d/Screenshots/gmail_login_i_login_with_valid_credential.png
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | sc-java-testing
4 | sc-java-testing
5 | 0.0.1-SNAPSHOT
6 |
7 |
8 |
9 | jitpack.io
10 | https://jitpack.io
11 |
12 |
13 |
14 |
15 |
16 |
17 | info.cukes
18 | cucumber-java
19 | 1.2.5
20 |
21 |
22 |
23 |
24 | info.cukes
25 | cucumber-junit
26 | 1.2.5
27 |
28 |
29 |
30 |
31 | junit
32 | junit
33 | 4.12
34 |
35 |
36 |
37 |
38 | org.seleniumhq.selenium
39 | selenium-java
40 | 3.5.2
41 |
42 |
43 |
44 | org.seleniumhq.selenium
45 | selenium-server
46 | 3.5.2
47 |
48 |
49 | com.github.selenium-cucumber
50 | selenium-cucumber-java
51 | 1.0.1-beta
52 |
53 |
54 |
55 |
56 | io.appium
57 | java-client
58 | 5.0.4
59 |
60 |
61 |
62 |
63 |
64 |
65 | org.apache.maven.plugins
66 | maven-compiler-plugin
67 | 3.2
68 |
69 | UTF-8
70 | 1.8
71 | 1.8
72 | -Werror
73 |
74 |
75 |
76 | browser
77 | ${browser}
78 |
79 |
80 | cloud_config
81 | ${cloud_config}
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/selenium-cucumber-java-0.0.1.pom:
--------------------------------------------------------------------------------
1 | pom.xml
--------------------------------------------------------------------------------
/src/main/java/appUnderTest/AndroidCalculator.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/selenium-cucumber/selenium-cucumber-java-maven-example/98d5e7b4cadb6acbba8ba42266beffd3b5efc16d/src/main/java/appUnderTest/AndroidCalculator.apk
--------------------------------------------------------------------------------
/src/main/java/browserConfigs/browserstack_android7_chrome.properties:
--------------------------------------------------------------------------------
1 | name=GooglePixelTest
2 | device=Google Pixel
3 | realMobile=true
4 | os_version=7.1
5 | browser=Android
--------------------------------------------------------------------------------
/src/main/java/browserConfigs/browserstack_win10_chrome.properties:
--------------------------------------------------------------------------------
1 | name=Windows10ChromeTest
2 | browser=Chrome
3 | browser_version=62.0
4 | os=Windows
5 | os_version=10
6 | resolution=1024x768
--------------------------------------------------------------------------------
/src/main/java/browserConfigs/local_android_app_nexus5.properties:
--------------------------------------------------------------------------------
1 | deviceName=Nexus5
2 | platformName=android
3 | platformVersion=7.0
4 | app=AndroidCalculator.apk
5 | udid=192.168.49.101:5555
--------------------------------------------------------------------------------
/src/main/java/browserConfigs/local_android_nexus5.properties:
--------------------------------------------------------------------------------
1 | deviceName=Nexus5
2 | platformName=android
3 | platformVersion=7.0
4 | browserName=Chrome
5 | udid=2454f24e
--------------------------------------------------------------------------------
/src/main/java/browserConfigs/saucelab_android6_chrome.properties:
--------------------------------------------------------------------------------
1 | name=Android-Test
2 | appiumVersion=1.6.4
3 | deviceName=Android Emulator
4 | deviceOrientation=portrait
5 | browserName=Chrome
6 | platformVersion=6.0
7 | platformName=Android
--------------------------------------------------------------------------------
/src/main/java/browserConfigs/saucelab_android_app.properties:
--------------------------------------------------------------------------------
1 | name=CalcTest
2 | appiumVersion=1.6.4
3 | deviceName=Android GoogleAPI Emulator
4 | deviceOrientation=portrait
5 | platformVersion=7.0
6 | platformName=Android
7 | app=sauce-storage:AndroidCalculator.apk
--------------------------------------------------------------------------------
/src/main/java/browserConfigs/saucelab_android_app_nexus.properties:
--------------------------------------------------------------------------------
1 | name=Android-Test
2 | appiumVersion=1.6.4
3 | deviceName=Android Emulator
4 | deviceOrientation=portrait
5 | app=sauce-storage:AndroidCalculator.apk
6 | platformVersion=6.0
7 | platformName=Android
--------------------------------------------------------------------------------
/src/main/java/browserConfigs/saucelab_android_chrome.properties:
--------------------------------------------------------------------------------
1 | name=CalcTest
2 | appiumVersion=1.6.4
3 | deviceName=Android GoogleAPI Emulator
4 | deviceOrientation=portrait
5 | platformVersion=7.0
6 | platformName=Android
7 | browserName=chrome
--------------------------------------------------------------------------------
/src/main/java/browserConfigs/saucelab_windows_chrome52.properties:
--------------------------------------------------------------------------------
1 | name=Win10-Chrome49
2 | platform=Windows 10
3 | browserName=Chrome
4 | version=49.0
5 |
--------------------------------------------------------------------------------
/src/main/java/platformConfigs/browserstack.properties:
--------------------------------------------------------------------------------
1 | username=your_username
2 | access_key=your_access_key
3 | url=@hub-cloud.browserstack.com/wd/hub
4 | protocol=http
--------------------------------------------------------------------------------
/src/main/java/platformConfigs/saucelab.properties:
--------------------------------------------------------------------------------
1 | username=your_username
2 | access_key=your_access_key
3 | url=@ondemand.saucelabs.com:80/wd/hub
4 | protocol=http
--------------------------------------------------------------------------------
/src/test/java/env/DriverUtil.java:
--------------------------------------------------------------------------------
1 | package env;
2 |
3 | import java.io.BufferedInputStream;
4 | import java.io.BufferedOutputStream;
5 | import java.io.File;
6 | import java.io.FileInputStream;
7 | import java.io.IOException;
8 | import java.io.InputStream;
9 | import java.net.HttpURLConnection;
10 | import java.net.MalformedURLException;
11 | import java.net.URL;
12 | import java.net.URLConnection;
13 | import java.util.Base64;
14 | import java.util.Enumeration;
15 | import java.util.Properties;
16 | import java.util.concurrent.TimeUnit;
17 |
18 | import org.openqa.selenium.By;
19 | import org.openqa.selenium.NoSuchSessionException;
20 | import org.openqa.selenium.SessionNotCreatedException;
21 | import org.openqa.selenium.WebDriver;
22 | import org.openqa.selenium.WebElement;
23 | import org.openqa.selenium.chrome.ChromeDriver;
24 | import org.openqa.selenium.chrome.ChromeOptions;
25 | import org.openqa.selenium.edge.EdgeDriver;
26 | import org.openqa.selenium.firefox.FirefoxDriver;
27 | import org.openqa.selenium.firefox.FirefoxOptions;
28 | import org.openqa.selenium.remote.DesiredCapabilities;
29 | import org.openqa.selenium.remote.ErrorHandler;
30 | import org.openqa.selenium.remote.RemoteWebDriver;
31 | import org.openqa.selenium.safari.SafariDriver;
32 | import org.openqa.selenium.support.ui.ExpectedConditions;
33 | import org.openqa.selenium.support.ui.WebDriverWait;
34 |
35 | import io.appium.java_client.android.AndroidDriver;
36 | import io.appium.java_client.ios.IOSDriver;
37 |
38 | public class DriverUtil {
39 | public static long DEFAULT_WAIT = 20;
40 | protected static WebDriver driver=null;
41 | static String currentPath = System.getProperty("user.dir");
42 | static Properties prop = new Properties();
43 | static DesiredCapabilities capability=null;
44 |
45 | public static DesiredCapabilities getCapability(InputStream input) {
46 | DesiredCapabilities capability = new DesiredCapabilities();
47 | try {
48 | prop.load(input);
49 | if(prop.containsKey("app")) {
50 | String appName = prop.getProperty("app");
51 | if(!appName.contains("sauce-storage")) {
52 | String appPath = currentPath+"/src/main/java/appUnderTest/"+appName;
53 | prop.setProperty("app", appPath);
54 | }
55 | }
56 |
57 | // set capabilities
58 | Enumeration