FirefoxUser.java 1.99 KB
Newer Older
1
/*
2
 * (C) Copyright 2017-2019 OpenVidu (https://openvidu.io/)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

18
package io.openvidu.test.browsers;
pabloFuente's avatar
pabloFuente committed
19

20 21 22
import java.net.MalformedURLException;
import java.net.URL;

pabloFuente's avatar
pabloFuente committed
23 24 25
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.remote.DesiredCapabilities;
26
import org.openqa.selenium.remote.RemoteWebDriver;
pabloFuente's avatar
pabloFuente committed
27 28 29

public class FirefoxUser extends BrowserUser {

30 31
	public FirefoxUser(String userName, int timeOfWaitInSeconds) {
		super(userName, timeOfWaitInSeconds);
32

33 34
		DesiredCapabilities capabilities = DesiredCapabilities.firefox();
		capabilities.setAcceptInsecureCerts(true);
pabloFuente's avatar
pabloFuente committed
35 36 37 38
		FirefoxProfile profile = new FirefoxProfile();

		// This flag avoids granting the access to the camera
		profile.setPreference("media.navigator.permission.disabled", true);
39
		// This flag force to use fake user media (synthetic video of multiple color)
pabloFuente's avatar
pabloFuente committed
40 41 42
		profile.setPreference("media.navigator.streams.fake", true);

		capabilities.setCapability(FirefoxDriver.PROFILE, profile);
43

44 45 46 47 48 49 50 51 52 53 54 55
		String REMOTE_URL = System.getProperty("REMOTE_URL_FIREFOX");
		if (REMOTE_URL != null) {
			log.info("Using URL {} to connect to remote web driver", REMOTE_URL);
			try {
				this.driver = new RemoteWebDriver(new URL(REMOTE_URL), capabilities);
			} catch (MalformedURLException e) {
				e.printStackTrace();
			}
		} else {
			log.info("Using local web driver");
			this.driver = new FirefoxDriver(capabilities);
		}
56

57
		this.configureDriver();
pabloFuente's avatar
pabloFuente committed
58 59
	}

60
}