Skip to content

Commit

Permalink
allow run gradle test with selenoid hub (CP 22.1) (#4536)
Browse files Browse the repository at this point in the history
* chore:remove webdriver manager (#4030)

* run gradle test in selenium hub (#4532)
  • Loading branch information
ZheSun88 authored Sep 29, 2023
1 parent 19af020 commit 1c89380
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
1 change: 0 additions & 1 deletion vaadin-platform-gradle-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ dependencies {

testImplementation 'com.vaadin:vaadin-testbench'
testImplementation 'junit:junit:4.13'
testImplementation 'io.github.bonigarcia:webdrivermanager:4.4.0'

providedCompile 'javax.servlet:javax.servlet-api:3.1.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,44 @@
*/
package com.vaadin.platform.gradle.test;

import java.io.File;

import org.junit.Before;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.vaadin.testbench.IPAddress;
import com.vaadin.testbench.parallel.ParallelTest;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.junit.BeforeClass;
import java.io.File;
import com.vaadin.testbench.parallel.SauceLabsIntegration;

public abstract class AbstractPlatformTest extends ParallelTest {

public static final int SERVER_PORT = Integer
.parseInt(System.getProperty("serverPort", "8080"));

static String hostName;
static boolean isSauce;
static boolean isHub;
static boolean isLocal;

static Logger getLogger() {
return LoggerFactory.getLogger(AbstractPlatformTest.class);
}

@BeforeClass
public static void setupClass() {
String sauceKey = System.getProperty("sauce.sauceAccessKey");
String hubHost = System.getProperty("com.vaadin.testbench.Parameters.hubHostname");
if ((sauceKey == null || sauceKey.isEmpty()) && (hubHost == null || hubHost.isEmpty())) {
String driver = System.getProperty("webdriver.chrome.driver");
if (driver == null || !new File(driver).exists()) {
WebDriverManager.chromedriver().setup();
}
}
isSauce = SauceLabsIntegration.isConfiguredForSauceLabs();
String hubHost = System
.getProperty("com.vaadin.testbench.Parameters.hubHostname");
isHub = !isSauce && hubHost != null && !hubHost.isEmpty();

hostName = isHub ? IPAddress.findSiteLocalAddress() : "localhost";
getLogger().info("Running Tests app-url=http://{}:{} mode={}", hostName,
SERVER_PORT,
isSauce ? "SAUCE (user:" + SauceLabsIntegration.getSauceUser() + ")"
: isHub ? "HUB (hub-host:" + hubHost + ")"
: "LOCAL (chromedriver)");
}

@Before
Expand Down Expand Up @@ -69,7 +85,6 @@ protected int getDeploymentPort() {
* @return the host name of development server
*/
protected String getDeploymentHostname() {
return "localhost";
return hostName;
}

}

0 comments on commit 1c89380

Please sign in to comment.