From 8ab2950f898a69c2d3aa2d500c50583037cef59d Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 8 Mar 2024 09:20:33 +0100 Subject: [PATCH] update tests --- .github/workflows/test.yml | 24 +++++++++++++++++++ .gitignore | 3 ++- .travis.yml | 7 ------ README.md | 4 +--- pom.xml | 10 ++++---- src/test/java/com/testingbot/SingleTest.java | 9 ++----- .../com/testingbot/TestingBotJUnitTest.java | 6 ++--- src/test/resources/conf/mobile.conf.json | 18 +++++++------- src/test/resources/conf/parallel.conf.json | 22 +++++++++-------- src/test/resources/conf/single.conf.json | 16 +++++++------ 10 files changed, 68 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3f67dd8 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/.gitignore b/.gitignore index 1a10370..38a67dc 100644 --- a/.gitignore +++ b/.gitignore @@ -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* \ No newline at end of file +hs_err_pid* +**/.DS_Store \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3a81a49..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: java - -jdk: - - openjdk8 - -scripts: - - mvn test -P single diff --git a/README.md b/README.md index 7ba444e..6ebee01 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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/) \ No newline at end of file +##### [SeleniumHQ Documentation](https://www.selenium.dev/documentation/) \ No newline at end of file diff --git a/pom.xml b/pom.xml index 73f5191..7d682f9 100644 --- a/pom.xml +++ b/pom.xml @@ -16,25 +16,25 @@ default - 1.6 - 1.6 + 1.7 + 1.7 junit junit - 4.12 + 4.13.2 commons-io commons-io - 1.3.2 + 2.15.1 org.seleniumhq.selenium selenium-java - 3.141.59 + 4.18.1 com.googlecode.json-simple diff --git a/src/test/java/com/testingbot/SingleTest.java b/src/test/java/com/testingbot/SingleTest.java index 596abbe..3b96597 100644 --- a/src/test/java/com/testingbot/SingleTest.java +++ b/src/test/java/com/testingbot/SingleTest.java @@ -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")); } } diff --git a/src/test/java/com/testingbot/TestingBotJUnitTest.java b/src/test/java/com/testingbot/TestingBotJUnitTest.java index fd2ca30..058f7f5 100644 --- a/src/test/java/com/testingbot/TestingBotJUnitTest.java +++ b/src/test/java/com/testingbot/TestingBotJUnitTest.java @@ -61,7 +61,7 @@ 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 commonCapabilities = (Map) config.get("capabilities"); @@ -69,7 +69,7 @@ public void setUp() throws Exception { 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()); } } @@ -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 diff --git a/src/test/resources/conf/mobile.conf.json b/src/test/resources/conf/mobile.conf.json index 6e270de..4d58cac 100644 --- a/src/test/resources/conf/mobile.conf.json +++ b/src/test/resources/conf/mobile.conf.json @@ -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" }] } diff --git a/src/test/resources/conf/parallel.conf.json b/src/test/resources/conf/parallel.conf.json index f5bc368..d0173d4 100644 --- a/src/test/resources/conf/parallel.conf.json +++ b/src/test/resources/conf/parallel.conf.json @@ -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" }] } diff --git a/src/test/resources/conf/single.conf.json b/src/test/resources/conf/single.conf.json index 778de3b..db64773 100644 --- a/src/test/resources/conf/single.conf.json +++ b/src/test/resources/conf/single.conf.json @@ -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" }] }