use of org.openqa.selenium.firefox.FirefoxProfile in project Asqatasun by Asqatasun.
the class ScenarioLoaderImpl method run.
@Override
public void run() {
try {
LOGGER.debug("Launch Scenario " + scenario);
FirefoxProfile firefoxProfile;
if (isScenarioOnlyLoadPage(scenario)) {
LOGGER.debug("Audit page script");
firefoxProfile = profileFactory.getOnlineProfile();
} else {
LOGGER.debug("Scenario script, images are loaded and implicitly " + "wait timeout set");
implicitelyWaitDriverTimeout = SCENARIO_IMPLICITELY_WAIT_TIMEOUT;
firefoxProfile = profileFactory.getScenarioProfile();
}
Script script = getScriptFromScenario(scenario, firefoxProfile);
try {
if (script.run()) {
LOGGER.debug(webResource.getURL() + " succeeded");
} else {
LOGGER.debug(webResource.getURL() + " failed");
}
} catch (TestRunException tre) {
// The TestRunException is caught but not as runtime, to audit
// at least pages already fetched
LOGGER.warn(tre.getMessage());
} catch (RuntimeException re) {
LOGGER.warn(re.getMessage());
throw new ScenarioLoaderException(re);
}
profileFactory.shutdownFirefoxProfile(firefoxProfile);
} catch (IOException | JSONException | SuiteException ex) {
LOGGER.warn(ex.getMessage());
throw new ScenarioLoaderException(ex);
}
}
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 selenium_java by sergueik.
the class AppTest method setup.
@BeforeClass
public static void setup() throws IOException {
// System.out.println(System.getProperty("user.dir"));
FirefoxProfile profile = new FirefoxProfile();
try {
profile.addExtension(new File(System.getProperty("user.dir") + "/src/main/resources/firefox"));
} catch (IOException e) {
e.printStackTrace();
}
// http://www.programcreek.com/java-api-examples/index.php?api=org.openqa.selenium.firefox.FirefoxProfile
// http://www.atetric.com/atetric/javadoc/org.seleniumhq.selenium/selenium-firefox-driver/2.43.1/src-html/org/openqa/selenium/firefox/FirefoxProfile.html
profile.setPreference("app.update.enabled", false);
// Setting preferences
// profile.setPreference("extensions.firebug.currentVersion", "2.0");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName("firefox");
capabilities.setPlatform(org.openqa.selenium.Platform.ANY);
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
driver = new RemoteWebDriver(capabilities);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
use of org.openqa.selenium.firefox.FirefoxProfile in project selenium_java by sergueik.
the class BaseTest method setupTestClass.
@BeforeClass
public void setupTestClass(ITestContext context) throws IOException {
getOsName();
if (browser.equals("chrome")) {
System.setProperty("webdriver.chrome.driver", (new File("c:/java/selenium/chromedriver.exe")).getAbsolutePath());
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("profile.default_content_settings.popups", 0);
String downloadFilepath = System.getProperty("user.dir") + System.getProperty("file.separator") + "target" + System.getProperty("file.separator");
chromePrefs.put("download.default_directory", downloadFilepath);
chromePrefs.put("enableNetwork", "true");
options.setExperimentalOption("prefs", chromePrefs);
options.addArguments("allow-running-insecure-content");
options.addArguments("allow-insecure-localhost");
options.addArguments("enable-local-file-accesses");
options.addArguments("disable-notifications");
// options.addArguments("start-maximized");
options.addArguments("browser.download.folderList=2");
options.addArguments("--browser.helperApps.neverAsk.saveToDisk=image/jpg,text/csv,text/xml,application/xml,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/excel,application/pdf");
options.addArguments("browser.download.dir=" + downloadFilepath);
// options.addArguments("user-data-dir=/path/to/your/custom/profile");
capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
driver = new ChromeDriver(capabilities);
} else if (browser.equals("firefox")) {
System.setProperty("webdriver.gecko.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/geckodriver.exe").getAbsolutePath() : "/tmp/geckodriver");
System.setProperty("webdriver.firefox.bin", osName.toLowerCase().startsWith("windows") ? new File("c:/Program Files (x86)/Mozilla Firefox/firefox.exe").getAbsolutePath() : "/usr/bin/firefox");
// https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
// use legacy FirefoxDriver
capabilities.setCapability("marionette", false);
// http://www.programcreek.com/java-api-examples/index.php?api=org.openqa.selenium.firefox.FirefoxProfile
capabilities.setCapability("locationContextEnabled", false);
capabilities.setCapability("acceptSslCerts", true);
capabilities.setCapability("elementScrollBehavior", 1);
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(true);
System.out.println(System.getProperty("user.dir"));
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
try {
driver = new FirefoxDriver(capabilities);
} catch (WebDriverException e) {
e.printStackTrace();
throw new RuntimeException("Cannot initialize Firefox driver");
}
}
actions = new Actions(driver);
driver.manage().timeouts().setScriptTimeout(scriptTimeout, TimeUnit.SECONDS);
// Declare a wait time
wait = new WebDriverWait(driver, flexibleWait);
wait.pollingEvery(pollingInterval, TimeUnit.MILLISECONDS);
screenshot = ((TakesScreenshot) driver);
js = ((JavascriptExecutor) driver);
driver.manage().window().maximize();
context.setAttribute("driver", driver);
context.setAttribute("config", config);
// Go to URL
driver.get(baseURL);
}
Aggregations