use of org.openqa.selenium.ie.InternetExplorerDriver in project ca3sCore by kuehne-trustable-de.
the class LocomotiveBase method startWebDriver.
public void startWebDriver() {
Capabilities capabilities;
baseUrl = configuration.url();
LOGGER.info(String.format("\n=== Configuration ===\n" + "\tURL: %s\n" + "\tBrowser: %s\n" + "\tHub: %s\n", configuration.url(), configuration.browser().name(), configuration.hub()));
boolean isLocal = StringUtils.isEmpty(configuration.hub());
switch(configuration.browser()) {
case CHROME:
capabilities = new ChromeOptions();
String driverName = "chromedriver";
if (SystemUtils.IS_OS_WINDOWS) {
driverName = "chromedriver.exe";
}
try {
URL resourceURL = ResourceUtils.getURL("classpath:drivers/" + driverName);
File tmpFile = File.createTempFile("ca3sTest", driverName);
Files.copy(resourceURL.openStream(), tmpFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
if (SystemUtils.IS_OS_LINUX) {
Set<PosixFilePermission> perms = new HashSet<>();
perms.add(PosixFilePermission.OWNER_READ);
perms.add(PosixFilePermission.OWNER_WRITE);
perms.add(PosixFilePermission.OWNER_EXECUTE);
Files.setPosixFilePermissions(tmpFile.toPath(), perms);
}
System.setProperty("webdriver.chrome.driver", tmpFile.getAbsolutePath());
System.err.println("starting local Chrome using driver at : " + System.getProperty("webdriver.chrome.driver"));
if (isLocal) {
try {
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
driver = new ChromeDriver(options);
} catch (Exception x) {
x.printStackTrace();
LOGGER.error("starting chrome driver, exiting ...", x);
logFatal("chromedriver not found. See https://github.com/ddavison/conductor/wiki/WebDriver-Executables for more information.");
System.exit(1);
}
}
} catch (IOException ioe) {
ioe.printStackTrace();
System.err.println("problem installing chrome driver, exiting ...");
System.exit(1);
}
break;
case FIREFOX:
capabilities = DesiredCapabilities.firefox();
if (isLocal)
driver = new FirefoxDriver(capabilities);
break;
case INTERNET_EXPLORER:
logFatal("iedriver not found. See https://github.com/ddavison/conductor/wiki/WebDriver-Executables for more information.");
System.exit(1);
capabilities = DesiredCapabilities.internetExplorer();
if (isLocal)
driver = new InternetExplorerDriver(capabilities);
break;
case SAFARI:
logFatal("safaridriver not found. See https://github.com/ddavison/conductor/wiki/WebDriver-Executables for more information.");
System.exit(1);
capabilities = DesiredCapabilities.safari();
if (isLocal)
driver = new SafariDriver(capabilities);
break;
case PHANTOMJS:
capabilities = DesiredCapabilities.phantomjs();
if (isLocal)
try {
driver = new PhantomJSDriver(capabilities);
} catch (Exception x) {
logFatal("phantomjs not found. Download them from https://bitbucket.org/ariya/phantomjs/downloads/ and extract the binary as phantomjs.exe, phantomjs.linux, or phantomjs.mac at project root for Windows, Linux, or MacOS.");
System.exit(1);
}
break;
default:
System.err.println("Unknown browser: " + configuration.browser());
return;
}
if (!isLocal)
// they are using a hub.
try {
// just override the driver.
driver = new RemoteWebDriver(new URL(configuration.hub()), capabilities);
} catch (Exception x) {
logFatal("Couldn't connect to hub: " + configuration.hub());
x.printStackTrace();
return;
}
actions = new Actions(driver);
if (StringUtils.isNotEmpty(baseUrl))
driver.navigate().to(baseUrl);
}
use of org.openqa.selenium.ie.InternetExplorerDriver in project ASK by SQAPractical.
the class TestContext method initialize.
public static void initialize(String browser, boolean isHeadless) {
String osName = System.getProperty("os.name");
switch(browser) {
case "chrome":
String chromeDriverName = "chromedriver.exe";
if (osName != null && (osName.contains("Mac") || osName.contains("Linux"))) {
chromeDriverName = "chromedriver";
}
System.setProperty("webdriver.chrome.driver", getDriversDirPath() + chromeDriverName);
Map<String, Object> chromePreferences = new HashMap<>();
chromePreferences.put("profile.default_content_settings.geolocation", 2);
chromePreferences.put("download.prompt_for_download", false);
chromePreferences.put("download.directory_upgrade", true);
chromePreferences.put("download.default_directory", getDownloadsPath());
chromePreferences.put("credentials_enable_service", false);
chromePreferences.put("password_manager_enabled", false);
chromePreferences.put("safebrowsing.enabled", "true");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--start-maximized");
chromeOptions.setExperimentalOption("prefs", chromePreferences);
if (isHeadless) {
chromeOptions.setHeadless(true);
chromeOptions.addArguments("--window-size=1920,1080");
chromeOptions.addArguments("--disable-gpu");
}
driver = new ChromeDriver(chromeOptions);
break;
case "firefox":
String geckoDriverName = "geckodriver.exe";
if (osName != null && (osName.contains("Mac") || osName.contains("Linux"))) {
geckoDriverName = "geckodriver";
}
System.setProperty("webdriver.gecko.driver", getDriversDirPath() + geckoDriverName);
System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true");
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "/dev/null");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("xpinstall.signatures.required", false);
firefoxProfile.setPreference("app.update.enabled", false);
firefoxProfile.setPreference("browser.download.folderList", 2);
firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);
firefoxProfile.setPreference("browser.download.dir", getDownloadsPath());
firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip;application/octet-stream;application/x-zip;application/x-zip-compressed;text/css;text/html;text/plain;text/xml;text/comma-separated-values");
firefoxProfile.setPreference("browser.helperApps.neverAsk.openFile", "application/zip;application/octet-stream;application/x-zip;application/x-zip-compressed;text/css;text/html;text/plain;text/xml;text/comma-separated-values");
firefoxProfile.setPreference("browser.helperApps.alwaysAsk.force", false);
firefoxProfile.setPreference("plugin.disable_full_page_plugin_for_types", "application/pdf,application/vnd.adobe.xfdf,application/vnd.fdf,application/vnd.adobe.xdp+xml");
firefoxProfile.setPreference("webdriver.log.driver", "OFF");
FirefoxOptions firefoxOptions = new FirefoxOptions().setProfile(firefoxProfile).setLogLevel(FirefoxDriverLogLevel.INFO);
if (isHeadless) {
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.addCommandLineOptions("--headless");
firefoxOptions.setBinary(firefoxBinary);
}
driver = new FirefoxDriver(firefoxOptions);
break;
case "edge":
System.setProperty("webdriver.edge.driver", getDriversDirPath() + "MicrosoftWebDriver.exe");
driver = new EdgeDriver();
break;
case "ie":
System.setProperty("webdriver.ie.driver", getDriversDirPath() + "IEDriverServer.exe");
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
ieCapabilities.setCapability("requireWindowFocus", true);
InternetExplorerOptions ieOptions = new InternetExplorerOptions(ieCapabilities);
driver = new InternetExplorerDriver(ieOptions);
break;
case "grid":
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName(BrowserType.CHROME);
capabilities.setPlatform(Platform.ANY);
URL hubUrl = null;
try {
hubUrl = new URL("http://localhost:4444/wd/hub");
} catch (MalformedURLException e) {
e.printStackTrace();
}
driver = new RemoteWebDriver(hubUrl, capabilities);
break;
default:
throw new RuntimeException("Driver is not implemented for: " + browser);
}
}
use of org.openqa.selenium.ie.InternetExplorerDriver in project manifoldcf by apache.
the class SeleniumTester method start.
public void start(final BrowserType browserType, final String language, final String startURL) {
// Download Chrome Driver for Linux from here (https://chromedriver.storage.googleapis.com/index.html?path=2.28/)
switch(browserType) {
case CHROME:
if (System.getProperty("webdriver.chrome.driver") == null || System.getProperty("webdriver.chrome.driver").length() == 0)
throw new IllegalStateException("Please configure your SL_CHROME_DRIVER environment variable to point to the Selenium Google Chrome Driver");
// Create a new instance of Chrome driver
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized", "--lang=" + language);
driver = new ChromeDriver(options);
break;
case FIREFOX:
if (System.getProperty("webdriver.gecko.driver") == null || System.getProperty("webdriver.gecko.driver").length() == 0)
throw new IllegalStateException("Please configure your SL_FIREFOX_DRIVER environment variable to point to the Mozilla Firefox Driver");
// Create a new instance of Firefox driver
driver = new FirefoxDriver();
break;
case IE:
if (System.getProperty("webdriver.ie.driver") == null || System.getProperty("webdriver.ie.driver").length() == 0)
throw new IllegalStateException("Please configure your SL_IE_DRIVER environment variable to point to the Internet Explorer Driver");
// For more info, on how to configure IE driver, plese read https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
driver = new InternetExplorerDriver();
break;
default:
throw new IllegalArgumentException("Unknown browser type");
}
wait = new WebDriverWait(driver, defaultTimeOutInSeconds);
driver.get(startURL);
}
use of org.openqa.selenium.ie.InternetExplorerDriver in project test-automation-wrapper by gjorezaharchev.
the class IE method browser.
public WebDriver browser() {
if (System.getProperty("os.arch").equals("x86")) {
System.setProperty("webdriver.ie.driver", drivers + "IEDriverServer32.exe");
} else {
System.setProperty("webdriver.ie.driver", System.getProperty("webdriver.ie.driver", drivers + "IEDriverServer64.exe"));
}
driver = new InternetExplorerDriver(ieo());
driver.manage().deleteAllCookies();
return null;
}
use of org.openqa.selenium.ie.InternetExplorerDriver in project batch3-selenium-testng by euroTech-sdet.
the class Driver method get.
public static WebDriver get() {
if (driver == null) {
String browser = ConfigurationReader.get("browser");
switch(browser) {
case "chrome":
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
break;
case "chrome-headless":
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver(new ChromeOptions().setHeadless(true));
break;
case "firefox":
WebDriverManager.firefoxdriver().setup();
driver = new FirefoxDriver();
break;
case "firefox-headless":
WebDriverManager.firefoxdriver().setup();
driver = new FirefoxDriver(new FirefoxOptions().setHeadless(true));
break;
case "ie":
if (!System.getProperty("os.name").toLowerCase().contains("windows"))
throw new WebDriverException("Your OS doesn't support Internet Explorer");
WebDriverManager.iedriver().setup();
driver = new InternetExplorerDriver();
break;
case "edge":
if (!System.getProperty("os.name").toLowerCase().contains("windows"))
throw new WebDriverException("Your OS doesn't support Edge");
WebDriverManager.edgedriver().setup();
driver = new EdgeDriver();
break;
case "safari":
if (!System.getProperty("os.name").toLowerCase().contains("mac"))
throw new WebDriverException("Your OS doesn't support Safari");
WebDriverManager.getInstance(SafariDriver.class).setup();
driver = new SafariDriver();
break;
}
}
return driver;
}
Aggregations