openvidu-test-e2e: headless browsers

pull/669/head
pabloFuente 2021-11-11 16:40:30 +01:00
parent a604865f65
commit 8d40507ccd
4 changed files with 27 additions and 9 deletions

View File

@ -47,9 +47,16 @@ public class ChromeUser extends BrowserUser {
private ChromeUser(String userName, int timeOfWaitInSeconds, ChromeOptions options) {
super(userName, timeOfWaitInSeconds);
String REMOTE_URL = System.getProperty("REMOTE_URL_CHROME");
options.setAcceptInsecureCerts(true);
options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.IGNORE);
if (REMOTE_URL != null) {
options.setHeadless(true);
}
options.addArguments("--disable-infobars");
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);
options.setExperimentalOption("prefs", prefs);
String REMOTE_URL = System.getProperty("REMOTE_URL_CHROME");
if (REMOTE_URL != null) {
log.info("Using URL {} to connect to remote web driver", REMOTE_URL);
try {

View File

@ -2,7 +2,7 @@ package io.openvidu.test.browsers;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -19,16 +19,22 @@ public class EdgeUser extends BrowserUser {
public EdgeUser(String userName, int timeOfWaitInSeconds) {
super(userName, timeOfWaitInSeconds);
String REMOTE_URL = System.getProperty("REMOTE_URL_EDGE");
EdgeOptions options = new EdgeOptions();
options.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
options.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
// 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.put("args", args);
options.setCapability("ms:edgeOptions", map);
String REMOTE_URL = System.getProperty("REMOTE_URL_EDGE");
if (REMOTE_URL != null) {
log.info("Using URL {} to connect to remote web driver", REMOTE_URL);
try {

View File

@ -34,6 +34,8 @@ public class FirefoxUser extends BrowserUser {
public FirefoxUser(String userName, int timeOfWaitInSeconds, boolean disableOpenH264) {
super(userName, timeOfWaitInSeconds);
String REMOTE_URL = System.getProperty("REMOTE_URL_FIREFOX");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setAcceptInsecureCerts(true);
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
@ -51,17 +53,19 @@ public class FirefoxUser extends BrowserUser {
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
String REMOTE_URL = System.getProperty("REMOTE_URL_FIREFOX");
FirefoxOptions options = new FirefoxOptions(capabilities);
if (REMOTE_URL != null) {
options.setHeadless(true);
log.info("Using URL {} to connect to remote web driver", REMOTE_URL);
try {
this.driver = new RemoteWebDriver(new URL(REMOTE_URL), capabilities);
this.driver = new RemoteWebDriver(new URL(REMOTE_URL), options);
} catch (MalformedURLException e) {
e.printStackTrace();
}
} else {
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);

View File

@ -139,6 +139,8 @@ public class OpenViduTestE2e {
if (isRemote(BrowserNames.CHROME)) {
chrome = new GenericContainer<>(DockerImageName.parse("selenium/standalone-chrome:" + CHROME_VERSION))
.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);
chrome.setPortBindings(Arrays.asList("6666:4444"));
} else {
@ -150,7 +152,7 @@ public class OpenViduTestE2e {
firefox = new GenericContainer<>(
DockerImageName.parse("selenium/standalone-firefox:" + FIREFOX_VERSION))
.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"));
} else {
WebDriverManager.firefoxdriver().setup();
@ -170,7 +172,7 @@ public class OpenViduTestE2e {
if (isRemote(BrowserNames.EDGE)) {
edge = new GenericContainer<>(DockerImageName.parse("selenium/standalone-edge:" + EDGE_VERSION))
.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"));
} else {
WebDriverManager.edgedriver().setup();