Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jochen-testingbot committed Mar 8, 2024
1 parent ddde557 commit 8ab2950
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 51 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Java CI with Maven

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin' # Use Temurin distribution (formerly AdoptOpenJDK)
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2
- name: Build with Maven
run: mvn -B clean test -P single
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ local.log
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
hs_err_pid*
**/.DS_Store
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[![Build Status](https://travis-ci.org/testingbot/java-junit-example.svg?branch=master)](https://travis-ci.org/testingbot/java-junit-example)

## TestingBot - Java & JUnit

TestingBot provides an online grid of browsers and mobile devices to run Automated tests on via Selenium WebDriver.
Expand Down Expand Up @@ -27,4 +25,4 @@ You will see the test result in the [TestingBot Dashboard](https://testingbot.co
### Resources
##### [TestingBot Documentation](https://testingbot.com/support/getting-started/junit.html)
##### [SeleniumHQ Documentation](http://www.seleniumhq.org/docs/)
##### [SeleniumHQ Documentation](https://www.selenium.dev/documentation/)
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@

<test.file></test.file>
<config.file>default</config.file>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<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.12</version>
<version>4.13.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<version>2.15.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
<version>4.18.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
Expand Down
9 changes: 2 additions & 7 deletions src/test/java/com/testingbot/SingleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ public class SingleTest extends TestingBotJUnitTest {

@Test
public void test() throws Exception {
driver.get("https://www.google.com/ncr");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("TestingBot");
element.submit();
Thread.sleep(5000);

assertEquals("TestingBot - Google Search", driver.getTitle());
driver.get("https://testingbot.com");
assertTrue(driver.getTitle().contains("TestingBot"));
}
}
6 changes: 3 additions & 3 deletions src/test/java/com/testingbot/TestingBotJUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ public void setUp() throws Exception {
Iterator it = envCapabilities.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
capabilities.setCapability(pair.getKey().toString(), pair.getValue());
}

Map<String, String> commonCapabilities = (Map<String, String>) config.get("capabilities");
it = commonCapabilities.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
if(capabilities.getCapability(pair.getKey().toString()) == null){
capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
capabilities.setCapability(pair.getKey().toString(), pair.getValue());
}
}

Expand All @@ -83,7 +83,7 @@ public void setUp() throws Exception {
secret = (String) config.get("secret");
}

driver = new RemoteWebDriver(new URL("http://"+key+":"+secret+"@"+config.get("server")+"/wd/hub"), capabilities);
driver = new RemoteWebDriver(new URL("https://"+key+":"+secret+"@"+config.get("server")+"/wd/hub"), capabilities);
}

@After
Expand Down
18 changes: 10 additions & 8 deletions src/test/resources/conf/mobile.conf.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{
"server": "hub.testingbot.com",
"key": "TESTINGBOT_KEY",
"secret": "TESTINGBOT_SECRET",
"key": "TB_KEY",
"secret": "TB_SECRET",

"capabilities": {
"build": "junit-testingbot",
"name": "single_test"
"tb:options": {
"build": "junit-testingbot",
"name": "parallel_test"
}
},

"environments": [{
"app": "tb://f0862ada623e611f530a65f5",
"deviceName": "Pixel 2",
"version": "7.1",
"platformName": "Android"
"appium:app": "https://testingbot.com/appium/sample.apk",
"appium:deviceName": "Pixel 2",
"appium:version": "7.1",
"appium:platformName": "Android"
}]
}
22 changes: 12 additions & 10 deletions src/test/resources/conf/parallel.conf.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{
"server": "hub.testingbot.com",
"key": "TESTINGBOT_KEY",
"secret": "TESTINGBOT_SECRET",
"key": "TB_KEY",
"secret": "TB_SECRET",

"capabilities": {
"build": "junit-testingbot",
"name": "parallel_test"
"tb:options": {
"build": "junit-testingbot",
"name": "parallel_test"
}
},

"environments": [{
"browser": "chrome",
"platform": "WIN10",
"version": "latest"
"browserName": "chrome",
"platformName": "WIN10",
"browserVersion": "latest"
},{
"browser": "firefox",
"platform": "WIN10",
"version": "latest"
"browserName": "firefox",
"platformName": "SONOMA",
"browserVersion": "latest"
}]
}
16 changes: 9 additions & 7 deletions src/test/resources/conf/single.conf.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"server": "hub.testingbot.com",
"key": "TESTINGBOT_KEY",
"secret": "TESTINGBOT_SECRET",
"key": "TB_KEY",
"secret": "TB_SECRET",

"capabilities": {
"build": "junit-testingbot",
"name": "single_test"
"tb:options": {
"build": "junit-testingbot",
"name": "single_test"
}
},

"environments": [{
"browser": "chrome",
"platform": "WIN10",
"version": "latest"
"browserName": "chrome",
"platformName": "WIN10",
"browserVersion": "latest"
}]
}

0 comments on commit 8ab2950

Please sign in to comment.