mirror of https://github.com/OpenVidu/openvidu.git
openvidu-test-e2e: headless browsers
parent
a604865f65
commit
8d40507ccd
|
@ -47,9 +47,16 @@ public class ChromeUser extends BrowserUser {
|
||||||
|
|
||||||
private ChromeUser(String userName, int timeOfWaitInSeconds, ChromeOptions options) {
|
private ChromeUser(String userName, int timeOfWaitInSeconds, ChromeOptions options) {
|
||||||
super(userName, timeOfWaitInSeconds);
|
super(userName, timeOfWaitInSeconds);
|
||||||
|
|
||||||
|
String REMOTE_URL = System.getProperty("REMOTE_URL_CHROME");
|
||||||
|
|
||||||
options.setAcceptInsecureCerts(true);
|
options.setAcceptInsecureCerts(true);
|
||||||
options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.IGNORE);
|
options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.IGNORE);
|
||||||
|
|
||||||
|
if (REMOTE_URL != null) {
|
||||||
|
options.setHeadless(true);
|
||||||
|
}
|
||||||
|
|
||||||
options.addArguments("--disable-infobars");
|
options.addArguments("--disable-infobars");
|
||||||
options.setExperimentalOption("excludeSwitches", new String[] { "enable-automation" });
|
options.setExperimentalOption("excludeSwitches", new String[] { "enable-automation" });
|
||||||
|
|
||||||
|
@ -58,7 +65,6 @@ public class ChromeUser extends BrowserUser {
|
||||||
prefs.put("profile.default_content_setting_values.media_stream_camera", 1);
|
prefs.put("profile.default_content_setting_values.media_stream_camera", 1);
|
||||||
options.setExperimentalOption("prefs", prefs);
|
options.setExperimentalOption("prefs", prefs);
|
||||||
|
|
||||||
String REMOTE_URL = System.getProperty("REMOTE_URL_CHROME");
|
|
||||||
if (REMOTE_URL != null) {
|
if (REMOTE_URL != null) {
|
||||||
log.info("Using URL {} to connect to remote web driver", REMOTE_URL);
|
log.info("Using URL {} to connect to remote web driver", REMOTE_URL);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package io.openvidu.test.browsers;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -19,16 +19,22 @@ public class EdgeUser extends BrowserUser {
|
||||||
public EdgeUser(String userName, int timeOfWaitInSeconds) {
|
public EdgeUser(String userName, int timeOfWaitInSeconds) {
|
||||||
super(userName, timeOfWaitInSeconds);
|
super(userName, timeOfWaitInSeconds);
|
||||||
|
|
||||||
|
String REMOTE_URL = System.getProperty("REMOTE_URL_EDGE");
|
||||||
|
|
||||||
EdgeOptions options = new EdgeOptions();
|
EdgeOptions options = new EdgeOptions();
|
||||||
options.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
|
options.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
|
||||||
options.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
|
options.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
|
||||||
// When upgrading to selenium 4.0.0 options.addArguments will make this easier
|
// When upgrading to selenium 4.0.0 options.addArguments will make this easier
|
||||||
List<String> args = Arrays.asList("use-fake-ui-for-media-stream", "use-fake-device-for-media-stream");
|
List<String> args = new ArrayList<>();
|
||||||
|
args.add("use-fake-ui-for-media-stream");
|
||||||
|
args.add("use-fake-device-for-media-stream");
|
||||||
|
if (REMOTE_URL != null) {
|
||||||
|
args.add("headless");
|
||||||
|
}
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("args", args);
|
map.put("args", args);
|
||||||
options.setCapability("ms:edgeOptions", map);
|
options.setCapability("ms:edgeOptions", map);
|
||||||
|
|
||||||
String REMOTE_URL = System.getProperty("REMOTE_URL_EDGE");
|
|
||||||
if (REMOTE_URL != null) {
|
if (REMOTE_URL != null) {
|
||||||
log.info("Using URL {} to connect to remote web driver", REMOTE_URL);
|
log.info("Using URL {} to connect to remote web driver", REMOTE_URL);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -34,6 +34,8 @@ public class FirefoxUser extends BrowserUser {
|
||||||
public FirefoxUser(String userName, int timeOfWaitInSeconds, boolean disableOpenH264) {
|
public FirefoxUser(String userName, int timeOfWaitInSeconds, boolean disableOpenH264) {
|
||||||
super(userName, timeOfWaitInSeconds);
|
super(userName, timeOfWaitInSeconds);
|
||||||
|
|
||||||
|
String REMOTE_URL = System.getProperty("REMOTE_URL_FIREFOX");
|
||||||
|
|
||||||
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
|
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
|
||||||
capabilities.setAcceptInsecureCerts(true);
|
capabilities.setAcceptInsecureCerts(true);
|
||||||
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
|
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
|
||||||
|
@ -51,17 +53,19 @@ public class FirefoxUser extends BrowserUser {
|
||||||
|
|
||||||
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
|
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
|
||||||
|
|
||||||
String REMOTE_URL = System.getProperty("REMOTE_URL_FIREFOX");
|
FirefoxOptions options = new FirefoxOptions(capabilities);
|
||||||
|
|
||||||
if (REMOTE_URL != null) {
|
if (REMOTE_URL != null) {
|
||||||
|
options.setHeadless(true);
|
||||||
log.info("Using URL {} to connect to remote web driver", REMOTE_URL);
|
log.info("Using URL {} to connect to remote web driver", REMOTE_URL);
|
||||||
try {
|
try {
|
||||||
this.driver = new RemoteWebDriver(new URL(REMOTE_URL), capabilities);
|
this.driver = new RemoteWebDriver(new URL(REMOTE_URL), options);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info("Using local web driver");
|
log.info("Using local web driver");
|
||||||
this.driver = new FirefoxDriver(new FirefoxOptions(capabilities));
|
this.driver = new FirefoxDriver(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.driver.manage().timeouts().setScriptTimeout(timeOfWaitInSeconds, TimeUnit.SECONDS);
|
this.driver.manage().timeouts().setScriptTimeout(timeOfWaitInSeconds, TimeUnit.SECONDS);
|
||||||
|
|
|
@ -139,6 +139,8 @@ public class OpenViduTestE2e {
|
||||||
if (isRemote(BrowserNames.CHROME)) {
|
if (isRemote(BrowserNames.CHROME)) {
|
||||||
chrome = new GenericContainer<>(DockerImageName.parse("selenium/standalone-chrome:" + CHROME_VERSION))
|
chrome = new GenericContainer<>(DockerImageName.parse("selenium/standalone-chrome:" + CHROME_VERSION))
|
||||||
.withSharedMemorySize(2147483648L).withFileSystemBind("/opt/openvidu", "/opt/openvidu")
|
.withSharedMemorySize(2147483648L).withFileSystemBind("/opt/openvidu", "/opt/openvidu")
|
||||||
|
.withEnv(Map.of("START_XVFB", "false", "SE_NODE_OVERRIDE_MAX_SESSIONS", "true",
|
||||||
|
"SE_NODE_MAX_SESSIONS", "2"))
|
||||||
.withExposedPorts(4444).waitingFor(waitBrowser);
|
.withExposedPorts(4444).waitingFor(waitBrowser);
|
||||||
chrome.setPortBindings(Arrays.asList("6666:4444"));
|
chrome.setPortBindings(Arrays.asList("6666:4444"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -150,7 +152,7 @@ public class OpenViduTestE2e {
|
||||||
firefox = new GenericContainer<>(
|
firefox = new GenericContainer<>(
|
||||||
DockerImageName.parse("selenium/standalone-firefox:" + FIREFOX_VERSION))
|
DockerImageName.parse("selenium/standalone-firefox:" + FIREFOX_VERSION))
|
||||||
.withSharedMemorySize(2147483648L).withFileSystemBind("/opt/openvidu", "/opt/openvidu")
|
.withSharedMemorySize(2147483648L).withFileSystemBind("/opt/openvidu", "/opt/openvidu")
|
||||||
.withExposedPorts(4444).waitingFor(waitBrowser);
|
.withEnv(Map.of("START_XVFB", "false")).withExposedPorts(4444).waitingFor(waitBrowser);
|
||||||
firefox.setPortBindings(Arrays.asList("6667:4444"));
|
firefox.setPortBindings(Arrays.asList("6667:4444"));
|
||||||
} else {
|
} else {
|
||||||
WebDriverManager.firefoxdriver().setup();
|
WebDriverManager.firefoxdriver().setup();
|
||||||
|
@ -170,7 +172,7 @@ public class OpenViduTestE2e {
|
||||||
if (isRemote(BrowserNames.EDGE)) {
|
if (isRemote(BrowserNames.EDGE)) {
|
||||||
edge = new GenericContainer<>(DockerImageName.parse("selenium/standalone-edge:" + EDGE_VERSION))
|
edge = new GenericContainer<>(DockerImageName.parse("selenium/standalone-edge:" + EDGE_VERSION))
|
||||||
.withSharedMemorySize(2147483648L).withFileSystemBind("/opt/openvidu", "/opt/openvidu")
|
.withSharedMemorySize(2147483648L).withFileSystemBind("/opt/openvidu", "/opt/openvidu")
|
||||||
.withExposedPorts(4444).waitingFor(waitBrowser);
|
.withEnv(Map.of("START_XVFB", "false")).withExposedPorts(4444).waitingFor(waitBrowser);
|
||||||
edge.setPortBindings(Arrays.asList("6669:4444"));
|
edge.setPortBindings(Arrays.asList("6669:4444"));
|
||||||
} else {
|
} else {
|
||||||
WebDriverManager.edgedriver().setup();
|
WebDriverManager.edgedriver().setup();
|
||||||
|
|
Loading…
Reference in New Issue