Example usage for org.openqa.selenium.logging LogType PROFILER

List of usage examples for org.openqa.selenium.logging LogType PROFILER

Introduction

In this page you can find the example usage for org.openqa.selenium.logging LogType PROFILER.

Prototype

String PROFILER

To view the source code for org.openqa.selenium.logging LogType PROFILER.

Click Source Link

Document

This log type pertains to logs relating to performance timings.

Usage

From source file:com.cengage.mindtap.keywords.BasePageActions.java

public void analyzePROFILERLog() {
    System.out.println("*********** PROFILE LOG ************");
    LogEntries logEntries = driver.manage().logs().get(LogType.PROFILER);
    for (LogEntry entry : logEntries) {
        System.out.println(new Date(entry.getTimestamp()) + " " + entry.getLevel() + " " + entry.getMessage());
        //do something useful with the data
    }//from   w w w .java  2 s  . c  o m
    System.out.println("*********** PROFILE LOG ************");
}

From source file:com.dhenton9000.screenshots.ScreenShotLauncher.java

/**
 * set up the webdriver/*from  w w  w. j a va2 s.co  m*/
 *
 * @return
 */
private WebDriver configureDriver() {

    WebDriver driver = null;
    LoggingPreferences logs = new LoggingPreferences();
    logs.enable(LogType.BROWSER, Level.SEVERE);
    logs.enable(LogType.CLIENT, Level.SEVERE);
    logs.enable(LogType.DRIVER, Level.SEVERE);
    logs.enable(LogType.PERFORMANCE, Level.SEVERE);
    logs.enable(LogType.PROFILER, Level.SEVERE);
    logs.enable(LogType.SERVER, Level.SEVERE);

    DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
    desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, logs);
    LOG.debug("creating firefox driver");
    driver = new FirefoxDriver(desiredCapabilities);
    LOG.debug("got firefox driver");

    driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
    LOG.debug("driver is loaded via config " + driver.toString());

    return driver;
}

From source file:com.dhenton9000.selenium.generic.GenericAutomationRepository.java

/**
 * set up the driver with configuration parameters
 *
 *//* ww w . j  av a2s  . c  o  m*/
private void configureDriver() {

    LoggingPreferences logs = new LoggingPreferences();
    logs.enable(LogType.BROWSER, Level.SEVERE);
    logs.enable(LogType.CLIENT, Level.SEVERE);
    logs.enable(LogType.DRIVER, Level.SEVERE);
    logs.enable(LogType.PERFORMANCE, Level.SEVERE);
    logs.enable(LogType.PROFILER, Level.SEVERE);
    logs.enable(LogType.SERVER, Level.SEVERE);

    String driverTypeString = this.config.getString("test.selenium.browser");
    if (driverTypeString == null) {
        throw new RuntimeException("must specify 'test.selenium.browser' in prop file");
    }

    DRIVER_TYPES driverType = DRIVER_TYPES.valueOf(driverTypeString);
    LOG.debug(" found driver type " + driverType.toString());
    if (driverType == null) {
        throw new RuntimeException("cannot find driver type of " + driverTypeString);
    }

    switch (driverType) {
    case FireFox:
    default:
        DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
        desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, logs);

        // sets the driver to automatically skip download dialog
        // and save csv,xcel files to a temp directory
        // that directory is set in the constructor and has a trailing
        // slash
        FirefoxProfile firefoxProfile = new FirefoxProfile();
        firefoxProfile.setPreference("browser.download.folderList", 2);
        firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);

        String target = this.getTempDownloadPath();
        firefoxProfile.setPreference("browser.download.dir", target);
        firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",
                "text/csv,application/vnd.ms-excel");

        desiredCapabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);

        LOG.debug("creating firefox driver");
        driver = new FirefoxDriver(desiredCapabilities);
        LOG.debug("got firefox driver");
        break;
    case InternetExplorer:
        break;
    case Opera:
        break;
    case Safari:
        break;
    case Chrome:
        break;

    }
    driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
    LOG.debug("driver is loaded via config " + driver.toString());

}

From source file:com.jobaline.uiautomation.framework.selenium.phantomJsThreeHourTimeoutFix.HttpCommandExecutor.java

License:Apache License

public Response execute(Command command) throws IOException {
    HttpContext context = new BasicHttpContext();

    if (command.getSessionId() == null) {
        if (QUIT.equals(command.getName())) {
            return new Response();
        }/*from  w w w. ja  v  a 2 s  .co  m*/
        if (!GET_ALL_SESSIONS.equals(command.getName()) && !NEW_SESSION.equals(command.getName())) {
            throw new SessionNotFoundException("Session ID is null. Using WebDriver after calling quit()?");
        }
    }

    CommandInfo info = nameToUrl.get(command.getName());
    try {
        HttpUriRequest httpMethod = info.getMethod(remoteServer, command);

        setAcceptHeader(httpMethod);

        if (httpMethod instanceof HttpPost) {
            String payload = new BeanToJsonConverter().convert(command.getParameters());
            ((HttpPost) httpMethod).setEntity(new StringEntity(payload, "utf-8"));
            httpMethod.addHeader("Content-Type", "application/json; charset=utf-8");
        }

        // Do not allow web proxy caches to cache responses to "get" commands
        if (httpMethod instanceof HttpGet) {
            httpMethod.addHeader("Cache-Control", "no-cache");
        }

        log(LogType.PROFILER, new HttpProfilerLogEntry(command.getName(), true));
        HttpResponse response = fallBackExecute(context, httpMethod);
        log(LogType.PROFILER, new HttpProfilerLogEntry(command.getName(), false));

        response = followRedirects(client, context, response, /* redirect count */0);

        final EntityWithEncoding entityWithEncoding = new EntityWithEncoding(response.getEntity());

        return createResponse(response, context, entityWithEncoding);
    } catch (UnsupportedCommandException e) {
        if (e.getMessage() == null || "".equals(e.getMessage())) {
            throw new UnsupportedOperationException(
                    "No information from server. Command name was: " + command.getName(), e.getCause());
        }
        throw e;
    }
}

From source file:edu.uga.cs.clickminer.ClickminerCLI.java

License:Open Source License

private static void setBrowserLoggingConfig(String outLog, String driverLog, DesiredCapabilities cap,
        FirefoxProfile profile) {//from   w  w w. ja  va  2s.  c o  m
    if (outLog != null || driverLog != null) {
        if (driverLog != null) {
            LoggingPreferences logs = new LoggingPreferences();
            logs.enable(LogType.BROWSER, Level.ALL);
            logs.enable(LogType.DRIVER, Level.ALL);
            logs.enable(LogType.CLIENT, Level.ALL);
            logs.enable(LogType.SERVER, Level.ALL);
            logs.enable(LogType.PROFILER, Level.ALL);
            cap.setCapability(CapabilityType.LOGGING_PREFS, logs);
            profile.setPreference("webdriver.log.file", driverLog);
        }
        if (outLog != null) {
            System.setProperty("webdriver.firefox.logfile", outLog);
        }

    }

}

From source file:org.aludratest.service.gui.web.selenium.selenium2.AludraSeleniumHttpCommandExecutor.java

License:Apache License

@Override
public Response execute(Command command) throws IOException {
    HttpContext context = new BasicHttpContext();

    if (command.getSessionId() == null) {
        if (QUIT.equals(command.getName())) {
            return new Response();
        }//  ww  w  .jav a  2s.  c  o m
        if (!GET_ALL_SESSIONS.equals(command.getName()) && !NEW_SESSION.equals(command.getName())) {
            throw new SessionNotFoundException("Session ID is null. Using WebDriver after calling quit()?");
        }
    }

    HttpRequest request = commandCodec.encode(command);

    String requestUrl = remoteServer.toExternalForm().replaceAll("/$", "") + request.getUri();

    HttpUriRequest httpMethod = createHttpUriRequest(request.getMethod(), requestUrl);
    for (String name : request.getHeaderNames()) {
        // Skip content length as it is implicitly set when the message entity is set below.
        if (!"Content-Length".equalsIgnoreCase(name)) {
            for (String value : request.getHeaders(name)) {
                httpMethod.addHeader(name, value);
            }
        }
    }

    if (httpMethod instanceof HttpPost) {
        ((HttpPost) httpMethod).setEntity(new ByteArrayEntity(request.getContent()));
    }

    if (requestTimeout > 0 && (httpMethod instanceof HttpRequestBase)) {
        RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(15000)
                .setConnectTimeout(15000).setSocketTimeout(requestTimeout).build();
        ((HttpRequestBase) httpMethod).setConfig(requestConfig);
    } else if (httpMethod instanceof HttpRequestBase) {
        // ensure Selenium Standard is set
        RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(60000)
                .setConnectTimeout(60000).setSocketTimeout(THREE_HOURS).build();
        ((HttpRequestBase) httpMethod).setConfig(requestConfig);
    }

    try {
        log(LogType.PROFILER, new HttpProfilerLogEntry(command.getName(), true));
        HttpResponse response = fallBackExecute(context, httpMethod);
        log(LogType.PROFILER, new HttpProfilerLogEntry(command.getName(), false));

        lastResponse = response;
        response = followRedirects(client, context, response, /* redirect count */0);
        lastResponse = response;

        return createResponse(response, context);
    } catch (UnsupportedCommandException e) {
        if (e.getMessage() == null || "".equals(e.getMessage())) {
            throw new UnsupportedOperationException(
                    "No information from server. Command name was: " + command.getName(), e.getCause());
        }
        throw e;
    } catch (SocketTimeoutException e) {
        LoggerFactory.getLogger(AludraSeleniumHttpCommandExecutor.class)
                .warn("Timeout in HTTP Command Executor. Timeout was "
                        + ((HttpRequestBase) httpMethod).getConfig().getSocketTimeout());
        throw e;
    }
}

From source file:org.pentaho.ctools.suite.CToolsTestSuite.java

License:Open Source License

@BeforeClass
public static void setUpClass() throws IOException {
    System.out.println("Master setup");

    //System.setProperty("webdriver.log.file", "/dev/stdout");
    //System.setProperty("webdriver.firefox.logfile", "/dev/stdout");

    //Setting log preferences
    LoggingPreferences logs = new LoggingPreferences();
    logs.enable(LogType.BROWSER, Level.ALL);
    logs.enable(LogType.SERVER, Level.ALL);
    logs.enable(LogType.DRIVER, Level.ALL);
    logs.enable(LogType.PROFILER, Level.ALL);
    logs.enable(LogType.CLIENT, Level.ALL);
    logs.enable(LogType.PERFORMANCE, Level.ALL);

    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability(CapabilityType.LOGGING_PREFS, logs);

    //Inicialize DRIVER
    FirefoxProfile ffProfile = new FirefoxProfile();
    ffProfile.setPreference("intl.accept_languages", "en-us");

    capabilities.setCapability(FirefoxDriver.PROFILE, ffProfile);

    JavaScriptError.addExtension(ffProfile);
    driver = new FirefoxDriver(capabilities);
    driver.manage().window().maximize();
    driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    //Inicialize WAIT
    wait = new FluentWait<WebDriver>(driver).withTimeout(30, TimeUnit.SECONDS).pollingEvery(1, TimeUnit.SECONDS)
            .ignoring(org.openqa.selenium.NoSuchElementException.class);

    //Inicialize BASEURL
    baseUrl = "http://localhost:8080/pentaho/";
}