Search in sources :

Example 46 with ChromeDriver

use of org.openqa.selenium.chrome.ChromeDriver in project ats-framework by Axway.

the class RealHtmlFileBrowse method setValueUsingNativeDialog.

/**
 * This method allows you to type in dialog windows. This option is available only for Windows OS
 *
 * @param path add the location of the file, you want to type in the dialog window
 * @throws Exception
 */
@PublicAtsApi
public void setValueUsingNativeDialog(String path) throws Exception {
    if (!OperatingSystemType.getCurrentOsType().isWindows()) {
        throw new RuntimeException("This method is only available for Windows machines!");
    }
    // check if the file exist
    if (!new File(path).exists()) {
        throw new FileNotFoundException("File path \"" + path + "\" is wrong or does not exist!");
    }
    // ats_file_upload.exe location
    String uploadFileDestination = System.getProperty("user.dir") + "\\ats_file_upload.exe";
    // native window name
    String windowName;
    log.info("Using native " + path + " to work with native browser dialogs");
    // check if the ats_file_upload.exe file is already created
    if (!new File(uploadFileDestination).exists()) {
        OutputStream os = null;
        InputStream is = null;
        try {
            // get the ats_file_upload.exe file, located in the ats-uiengine.jar
            is = getClass().getClassLoader().getResourceAsStream("binaries/ats_file_upload.exe");
            if (is == null) {
                throw new FileNotFoundException("The 'ats_file_upload.exe' file is not found in ats-uiengine.jar!");
            }
            File uploadFile = new File(uploadFileDestination);
            os = new FileOutputStream(uploadFile);
            IOUtils.copy(is, os);
        } finally {
            IoUtils.closeStream(is);
            IoUtils.closeStream(os);
        }
    }
    if (webDriver instanceof FirefoxDriver) {
        windowName = " \"File Upload\" ";
    } else if (webDriver instanceof ChromeDriver) {
        windowName = " \"Open\" ";
    } else {
        throw new RobotException("Not Implemented for your browser! Currently Firefox and " + "Chrome are supported.");
    }
    // add the browse button properties
    ((AbstractRealBrowserDriver) super.getUiDriver()).getHtmlEngine().getElement(properties).click();
    // run the ats_file_upload.exe file
    IProcessExecutor proc = new LocalProcessExecutor(HostUtils.LOCAL_HOST_IPv4, uploadFileDestination + windowName + path);
    proc.execute();
    // check if there is any error, while executing the ats_file_upload.exe file
    if (proc.getExitCode() != 0) {
        log.error("AutoIT process for native browser interaction failed with exit code: " + proc.getExitCode() + ";");
        log.error("Output stream data: " + proc.getStandardOutput() + ";");
        log.error("Error stream data: " + proc.getErrorOutput());
        throw new RobotException("AutoIT process for native browser interaction failed.");
    }
}
Also used : InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) RobotException(com.axway.ats.uiengine.exceptions.RobotException) AbstractRealBrowserDriver(com.axway.ats.uiengine.AbstractRealBrowserDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) FileOutputStream(java.io.FileOutputStream) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) LocalProcessExecutor(com.axway.ats.core.process.LocalProcessExecutor) File(java.io.File) IProcessExecutor(com.axway.ats.core.process.model.IProcessExecutor) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 47 with ChromeDriver

use of org.openqa.selenium.chrome.ChromeDriver in project ddd-cqrs-sample by BottegaIT.

the class BrowserAgentDriverProvider method createChromeDriver.

@Override
protected ChromeDriver createChromeDriver() {
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    String chromeBinary = System.getProperty("chrome.binary");
    if (StringUtils.isNotBlank(chromeBinary)) {
        capabilities.setCapability("chrome.binary", chromeBinary);
    }
    return new ChromeDriver(capabilities);
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver)

Example 48 with ChromeDriver

use of org.openqa.selenium.chrome.ChromeDriver in project muikku by otavanopisto.

the class AbstractUITest method createChromeDriver.

protected RemoteWebDriver createChromeDriver() {
    ChromeOptions options = new ChromeOptions();
    options.addArguments("--lang=en_US");
    options.addArguments("--start-maximized");
    ChromeDriver chromeDriver = new ChromeDriver(options);
    return chromeDriver;
}
Also used : ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver)

Example 49 with ChromeDriver

use of org.openqa.selenium.chrome.ChromeDriver in project antlr4 by antlr.

the class SharedWebDriver method init.

public static WebDriver init() {
    if (driver == null) {
        String path = SharedWebDriver.class.getPackage().getName().replace(".", "/") + "/chromedriver.bin";
        URL url = Thread.currentThread().getContextClassLoader().getResource(path);
        // skip 'file:'
        File file = new File(url.toExternalForm().substring(5));
        assertTrue(file.exists());
        System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
        driver = new ChromeDriver();
    } else if (timer != null) {
        timer.cancel();
        timer = null;
    }
    return driver;
}
Also used : ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) File(java.io.File) URL(java.net.URL)

Example 50 with ChromeDriver

use of org.openqa.selenium.chrome.ChromeDriver in project flow by vaadin.

the class ChromeBrowserTest method createHeadlessChromeDriver.

private WebDriver createHeadlessChromeDriver() {
    ChromeOptions options = new ChromeOptions();
    options.addArguments("--headless", "--disable-gpu");
    return TestBench.createDriver(new ChromeDriver(options));
}
Also used : ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver)

Aggregations

ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)91 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)41 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)39 File (java.io.File)33 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)27 WebDriver (org.openqa.selenium.WebDriver)24 HashMap (java.util.HashMap)21 Before (org.junit.Before)13 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)13 URL (java.net.URL)11 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)11 InternetExplorerDriver (org.openqa.selenium.ie.InternetExplorerDriver)11 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)11 Test (org.junit.Test)10 ChromeDriverService (org.openqa.selenium.chrome.ChromeDriverService)9 Actions (org.openqa.selenium.interactions.Actions)9 PhantomJSDriver (org.openqa.selenium.phantomjs.PhantomJSDriver)9 HtmlUnitDriver (org.openqa.selenium.htmlunit.HtmlUnitDriver)8 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)7 SafariDriver (org.openqa.selenium.safari.SafariDriver)7