use of org.openqa.selenium.safari.SafariDriver in project demo-project by vasyafomiuk.
the class Driver method getDriver.
public static WebDriver getDriver() {
if (driver == null) {
if (System.getProperty("BROWSER") == null) {
browser = ConfigurationReader.getProperty("browser");
} else {
browser = System.getProperty("BROWSER");
}
System.out.println("Browser: " + browser);
switch(browser) {
case "remote-chrome":
try {
// assign your grid server address
String gridAddress = "54.235.53.73";
URL url = new URL("http://" + gridAddress + ":4444/wd/hub");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setBrowserName("chrome");
driver = new RemoteWebDriver(url, desiredCapabilities);
} catch (Exception e) {
e.printStackTrace();
}
break;
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("mac")) {
throw new WebDriverException("Your operating system does not support the requested browser");
}
WebDriverManager.iedriver().setup();
driver = new InternetExplorerDriver();
break;
case "edge":
if (System.getProperty("os.name").toLowerCase().contains("mac")) {
throw new WebDriverException("Your operating system does not support the requested browser");
}
WebDriverManager.edgedriver().setup();
driver = new EdgeDriver();
break;
case "safari":
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
throw new WebDriverException("Your operating system does not support the requested browser");
}
WebDriverManager.getInstance(SafariDriver.class).setup();
driver = new SafariDriver();
break;
}
}
return driver;
}
use of org.openqa.selenium.safari.SafariDriver in project vol-active-support by dvsa.
the class SafariSetUp method driver.
public WebDriver driver() throws MalformedURLException {
safari.setCapability("idleTimeout", 5000);
safari.setCapability("name", "VOL-Cross-Browser");
if (getPlatform() == null) {
driver = new SafariDriver(getSafari());
} else {
safari.setCapability("platform", getPlatform());
safari.setCapability("browser_version", getBrowserVersion());
safari.setCapability("browserstack.localIdentifier", "vol");
safari.setCapability("browserstack.local", "true");
driver = new RemoteWebDriver(new URL(hubURL()), getSafari());
}
return driver;
}
use of org.openqa.selenium.safari.SafariDriver 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.safari.SafariDriver in project selenese-runner-java by vmi.
the class SafariDriverFactory method newInstance.
@Override
public WebDriver newInstance(DriverOptions driverOptions) {
if (!OS.isFamilyMac())
throw new UnsupportedOperationException("Unsupported platform: " + Platform.getCurrent());
SafariDriverService service = setupBuilder(new SafariDriverService.Builder(), driverOptions, null).build();
SafariOptions options = newSafariOptions(driverOptions);
options.merge(driverOptions.getCapabilities());
SafariDriver driver = new SafariDriver(service, options);
setInitialWindowSize(driver, driverOptions);
return driver;
}
use of org.openqa.selenium.safari.SafariDriver in project test-automation-wrapper by gjorezaharchev.
the class Safari method browser.
public WebDriver browser() {
System.setProperty("webdriver.safari.noinstall", "true");
driver = new SafariDriver();
return driver;
}
Aggregations