Skip to content

Commit 45aaa6a

Browse files
authored
Merge pull request #32 from Baaryan/master
APS 13484 Add gradle config with updated gradle-sdk plugin for jbehave
2 parents 99ecbb7 + c640b42 commit 45aaa6a

6 files changed

Lines changed: 95 additions & 3 deletions

File tree

.github/workflows/maven-workflow-run.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
matrix:
2020
java: [ '8', '11', '17' ]
2121
os: [ 'macos-latest', 'windows-latest', 'ubuntu-latest' ]
22+
exclude:
23+
- java: '8'
24+
os: 'macos-latest'
2225
name: JBehave Repo ${{ matrix.Java }} - ${{ matrix.os }} Sample
2326
env:
2427
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
@@ -64,6 +67,12 @@ jobs:
6467
run: |
6568
mvn compile
6669
mvn test -P sample-test
70+
- name: Run gradle task sampleTest
71+
run: |
72+
gradle clean sampleTest
73+
- name: Run gradle task sampleLocalTest
74+
run: |
75+
gradle clean sampleLocalTest
6776
- if: always()
6877
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
6978
id: status-check-completed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ local.log
55
*.iml
66
logs/
77
browserstack.err
8+
bstack_*
9+
build
10+
gradle
11+
.gradle
12+
gradlew*

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,35 @@
66
![JBehave Logo](http://jbehave.org/images/jbehave-logo.png)
77

88

9-
## Setting up a sample test
9+
## Using Maven
10+
### Setting up a sample test
1011

1112
* Clone the repo
1213
* Install dependencies `mvn install`
1314
* Update `browserstack.yml` file inside the root directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
1415

15-
## Running your tests
16+
### Running your tests
1617
* To run a sample parallel test, run `mvn test -P sample-test`
1718
* To run local tests, update your `browserstack.yml` file with `browserstackLocal: true` and run `mvn test -P sample-local-test`
1819

1920
Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
2021

22+
## Using Gradle
23+
24+
### Prerequisites
25+
- If using Gradle, Java v9+ is required.
26+
27+
### Setting up a sample test
28+
29+
* Clone the repo
30+
* Update `browserstack.yml` file inside the root directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
31+
32+
### Running your tests
33+
* To run a sample parallel test, run `gradle sampleTest`
34+
* To run local tests, update your `browserstack.yml` file with `browserstackLocal: true` and run `gradle sampleLocalTest`
35+
36+
Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
37+
2138
## Notes
2239
* You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate)
2340
* To test on a different set of browsers, check out our [platform configurator](https://www.browserstack.com/automate/java#setting-os-and-browser)

build.gradle

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
plugins {
2+
id 'java'
3+
id 'com.browserstack.gradle-sdk' version "1.1.2" // sdk plugin
4+
}
5+
6+
repositories { mavenCentral() }
7+
8+
dependencies {
9+
implementation 'org.seleniumhq.selenium:selenium-java:4.1.0'
10+
implementation 'org.jbehave:jbehave-core:3.10'
11+
implementation 'org.yaml:snakeyaml:2.2'
12+
implementation 'com.browserstack:browserstack-java-sdk:latest.release'
13+
}
14+
15+
group = 'com.browserstack'
16+
version = '1.0-SNAPSHOT'
17+
description = 'jbehave-browserstack'
18+
sourceCompatibility = '1.8'
19+
20+
def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
21+
22+
tasks.withType(JavaCompile) {
23+
options.encoding = 'UTF-8'
24+
}
25+
26+
tasks.withType(Test) {
27+
systemProperties = System.properties
28+
jvmArgs += "-javaagent:${browserstackSDKArtifact.file}"
29+
}
30+
31+
task sampleTest(type: Test) {
32+
useJUnit() {
33+
dependsOn cleanTest
34+
systemProperty('embedder', "com.browserstack.single.SampleEmbedder")
35+
systemProperty('stories', "stories/sample.story")
36+
37+
}
38+
}
39+
40+
task sampleLocalTest(type: Test) {
41+
useJUnit() {
42+
dependsOn cleanTest
43+
systemProperty('embedder', "com.browserstack.local.LocalEmbedder")
44+
systemProperty('stories', "stories/local.story")
45+
}
46+
}

settings.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pluginManagement {
2+
repositories {
3+
mavenCentral()
4+
mavenLocal()
5+
gradlePluginPortal()
6+
}
7+
8+
resolutionStrategy {
9+
eachPlugin {
10+
if (requested.id.id == "com.browserstack.gradle-sdk") {
11+
useModule("com.browserstack:gradle-sdk:1.1.2")
12+
}
13+
}
14+
}
15+
}

src/test/java/com/browserstack/single/pages/BrowserStackPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class BrowserStackPage {
1515

1616
private By firstProductAddToCartButton = By.xpath("//*[@id=\"1\"]/div[4]");
1717

18-
private By cartPane = By.className("float-cart__content");
18+
private By cartPane = By.cssSelector(".float-cart__content");
1919

2020
private By productCartText = By.xpath("//*[@id=\"__next\"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]");
2121

0 commit comments

Comments
 (0)