use of org.openqa.selenium.firefox.FirefoxProfile in project kotlin by JetBrains.
the class SeleniumFireFox method createFirefoxDriver.
public static FirefoxDriver createFirefoxDriver() {
FirefoxProfile profile = new FirefoxProfile();
FirefoxDriver answer = new FirefoxDriver(profile);
return answer;
}
use of org.openqa.selenium.firefox.FirefoxProfile in project jlineup by otto-de.
the class BrowserUtils method getFirefoxProfileWithDisabledAnimatedGifs.
private FirefoxProfile getFirefoxProfileWithDisabledAnimatedGifs() {
FirefoxProfile firefoxProfileHeadless = new FirefoxProfile();
firefoxProfileHeadless.setPreference("image.animation_mode", "none");
return firefoxProfileHeadless;
}
use of org.openqa.selenium.firefox.FirefoxProfile in project zeppelin by apache.
the class WebDriverManager method getWebDriver.
public static WebDriver getWebDriver() {
WebDriver driver = null;
if (driver == null) {
try {
FirefoxBinary ffox = new FirefoxBinary();
if ("true".equals(System.getenv("TRAVIS"))) {
// xvfb is supposed to
ffox.setEnvironmentProperty("DISPLAY", ":99");
// run with DISPLAY 99
}
int firefoxVersion = WebDriverManager.getFirefoxVersion();
LOG.info("Firefox version " + firefoxVersion + " detected");
downLoadsDir = FileUtils.getTempDirectory().toString();
String tempPath = downLoadsDir + "/firebug/";
downloadFireBug(firefoxVersion, tempPath);
final String firebugPath = tempPath + "firebug.xpi";
final String firepathPath = tempPath + "firepath.xpi";
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", downLoadsDir);
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.download.manager.showAlertOnComplete", false);
profile.setPreference("browser.download.manager.closeWhenDone", true);
profile.setPreference("app.update.auto", false);
profile.setPreference("app.update.enabled", false);
profile.setPreference("dom.max_script_run_time", 0);
profile.setPreference("dom.max_chrome_script_run_time", 0);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-ustar,application/octet-stream,application/zip,text/csv,text/plain");
profile.setPreference("network.proxy.type", 0);
profile.addExtension(new File(firebugPath));
profile.addExtension(new File(firepathPath));
driver = new FirefoxDriver(ffox, profile);
} catch (Exception e) {
LOG.error("Exception in WebDriverManager while FireFox Driver ", e);
}
}
if (driver == null) {
try {
driver = new ChromeDriver();
} catch (Exception e) {
LOG.error("Exception in WebDriverManager while ChromeDriver ", e);
}
}
if (driver == null) {
try {
driver = new SafariDriver();
} catch (Exception e) {
LOG.error("Exception in WebDriverManager while SafariDriver ", e);
}
}
String url;
if (System.getenv("url") != null) {
url = System.getenv("url");
} else {
url = "http://localhost:8080";
}
long start = System.currentTimeMillis();
boolean loaded = false;
driver.manage().timeouts().implicitlyWait(AbstractZeppelinIT.MAX_IMPLICIT_WAIT, TimeUnit.SECONDS);
driver.get(url);
while (System.currentTimeMillis() - start < 60 * 1000) {
// wait for page load
try {
(new WebDriverWait(driver, 30)).until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver d) {
return d.findElement(By.xpath("//i[@tooltip='WebSocket Connected']")).isDisplayed();
}
});
loaded = true;
break;
} catch (TimeoutException e) {
LOG.info("Exception in WebDriverManager while WebDriverWait ", e);
driver.navigate().to(url);
}
}
if (loaded == false) {
fail();
}
return driver;
}
use of org.openqa.selenium.firefox.FirefoxProfile in project Asqatasun by Asqatasun.
the class ProfileFactory method getProfile.
/**
*
* @return
* a set-up Firefox profile
*/
private FirefoxProfile getProfile(boolean loadImage) {
if (StringUtils.isNotBlank(pathToPreSetProfile)) {
File presetProfileDir = new File(pathToPreSetProfile);
if (presetProfileDir.exists() && presetProfileDir.canRead() && presetProfileDir.canExecute() && presetProfileDir.canWrite()) {
Logger.getLogger(this.getClass()).debug("Start firefox profile with path " + presetProfileDir.getAbsolutePath());
return new FirefoxProfile(presetProfileDir);
} else {
Logger.getLogger(this.getClass()).debug("The profile with path " + presetProfileDir.getAbsolutePath() + " doesn't exist or don't have permissions");
}
}
Logger.getLogger(this.getClass()).debug("Start firefox with fresh new profile");
FirefoxProfile firefoxProfile = new FirefoxProfile();
setUpPreferences(firefoxProfile, loadImage);
// setUpExtensions(firefoxProfile);
setUpProxy(firefoxProfile);
return firefoxProfile;
}
use of org.openqa.selenium.firefox.FirefoxProfile in project ORCID-Source by ORCID.
the class ShibbolethTest method createFireFoxDriverWithModifyHeaders.
private WebDriver createFireFoxDriverWithModifyHeaders(List<Pair<String, String>> headers) throws IOException {
FirefoxProfile fireFoxProfile = new FirefoxProfile();
File modifyHeaders = new File(System.getProperty("user.dir") + "/src/test/resources/modify-headers-0.7.1.1.xpi");
fireFoxProfile.setEnableNativeEvents(false);
fireFoxProfile.addExtension(modifyHeaders);
fireFoxProfile.setPreference("modifyheaders.headers.count", headers.size());
for (int i = 0; i < headers.size(); i++) {
fireFoxProfile.setPreference("modifyheaders.headers.action" + i, "Add");
fireFoxProfile.setPreference("modifyheaders.headers.name" + i, headers.get(i).getLeft());
fireFoxProfile.setPreference("modifyheaders.headers.value" + i, headers.get(i).getRight());
fireFoxProfile.setPreference("modifyheaders.headers.enabled" + i, true);
}
fireFoxProfile.setPreference("modifyheaders.config.active", true);
fireFoxProfile.setPreference("modifyheaders.config.alwaysOn", true);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName("firefox");
capabilities.setPlatform(org.openqa.selenium.Platform.ANY);
capabilities.setCapability(FirefoxDriver.PROFILE, fireFoxProfile);
// Marionette does not allow untrusted certs yet
capabilities.setCapability(FirefoxDriver.MARIONETTE, false);
WebDriver webDriver = new FirefoxDriver(capabilities);
return webDriver;
}
Aggregations