Java 类org.openqa.selenium.logging.LoggingPreferences 实例源码

项目:spa-perf    文件:SPAPerfChromeDriver.java   
private static DesiredCapabilities getPerformanceLoggingCapabilities() {
    DesiredCapabilities caps = DesiredCapabilities.chrome();

    // Enable performance logging
    LoggingPreferences logPrefs = new LoggingPreferences();
    logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
    caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

    // Enable timeline tracing
    Map<String, Object> chromeOptions = new HashMap<String, Object>();
    Map<String, String> perfLoggingPrefs = new HashMap<String, String>();
    // Tracing categories, please note NO SPACE NEEDED after the commas
    perfLoggingPrefs.put("traceCategories", "blink.console,disabled-by-default-devtools.timeline");
    chromeOptions.put("perfLoggingPrefs", perfLoggingPrefs);
    //chromeOptions.put("debuggerAddress", "127.0.0.1:10134");
    caps.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

    return caps;
}
项目:AndroidRobot    文件:ChromeDriverClient.java   
public void createDriver(String pkg_name, String sn) {
        if(this.driver == null) {
            ChromeOptions chromeOptions = new ChromeOptions();
            chromeOptions.setExperimentalOption("androidPackage", pkg_name);
    //        chromeOptions.setExperimentalOption("androidActivity", "com.eg.android.AlipayGphone.AlipayLogin");
    //        chromeOptions.setExperimentalOption("debuggerAddress", "127.0.0.1:9222");
            chromeOptions.setExperimentalOption("androidUseRunningApp", true);
            chromeOptions.setExperimentalOption("androidDeviceSerial", sn);
    //        Map<String, Object> chromeOptions = new HashMap<String, Object>();
    //        chromeOptions.put("androidPackage", "com.eg.android.AlipayGphoneRC");
    //        chromeOptions.put("androidActivity", "com.eg.android.AlipayGphone.AlipayLogin");
            DesiredCapabilities capabilities = DesiredCapabilities.chrome();
            LoggingPreferences logPrefs = new LoggingPreferences();
            logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
            capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
            capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
//          capabilities.setCapability(CapabilityType., value);
            if(ChromeService.getService() != null)
                driver = new RobotRemoteWebDriver(ChromeService.getService().getUrl(), capabilities);
        }
    }
项目:grid-refactor-remote-server    文件:NewSession.java   
@Override
public Response handle() throws Exception {
  // Handle the case where the client does not send any desired capabilities.
  sessionId = allSessions.newSession(desiredCapabilities != null
                                     ? desiredCapabilities : new DesiredCapabilities());

  Map<String, Object> capabilities =
      Maps.newHashMap(allSessions.get(sessionId).getCapabilities().asMap());

  // Only servers implementing the server-side webdriver-backed selenium need
  // to return this particular value
  capabilities.put("webdriver.remote.sessionid", sessionId.toString());

  if (desiredCapabilities != null) {
    LoggingManager.perSessionLogHandler().configureLogging(
        (LoggingPreferences)desiredCapabilities.getCapability(CapabilityType.LOGGING_PREFS));
  }
  LoggingManager.perSessionLogHandler().attachToCurrentThread(sessionId);

  Response response = new Response();
  response.setSessionId(sessionId.toString());
  response.setValue(capabilities);
  return response;
}
项目:gatf    文件:SeleniumTest.java   
public SeleniumTestResult(WebDriver d, SeleniumTest test, Throwable cause, LoggingPreferences ___lp___) {
    this.status = false;
    this.internalTestRes = test.internalTestRs;
    Logs logs = d.manage().logs();
    for (String s : LOG_TYPES_SET) {
        if(!logs.getAvailableLogTypes().contains(s))continue;
        LogEntries logEntries = logs.get(s);
        if(logEntries!=null && !logEntries.getAll().isEmpty()) {
            this.logs.put(s, new SerializableLogEntries(logEntries.getAll())); 
        }
    }
    List<LogEntry> entries = new ArrayList<LogEntry>();
    entries.add(new LogEntry(Level.ALL, new Date().getTime(), cause.getMessage()));
    entries.add(new LogEntry(Level.ALL, new Date().getTime(), ExceptionUtils.getStackTrace(cause)));
    this.logs.put("gatf", new SerializableLogEntries(entries));
}
项目:marathonv5    文件:JavaDriverLogsTest.java   
public void loggingWorks() {
    LoggingPreferences prefs = new LoggingPreferences();
    prefs.enable(LogType.DRIVER, Level.INFO);
    DesiredCapabilities caps = JavaDriver.defaultCapabilities();
    caps.setCapability(CapabilityType.LOGGING_PREFS, prefs);
    driver = new JavaDriver(caps, caps);
    LogEntries logEntries = driver.manage().logs().get(LogType.DRIVER);
    List<LogEntry> all = logEntries.getAll();
    AssertJUnit.assertEquals(2, all.size());
    AssertJUnit.assertTrue(all.get(0).getMessage().contains("A new session created. sessionID = "));
}
项目:marathonv5    文件:JavaDriverLogsTest.java   
public void loglevelsAreRespected() {
    LoggingPreferences prefs = new LoggingPreferences();
    prefs.enable(LogType.DRIVER, Level.WARNING);
    DesiredCapabilities caps = JavaDriver.defaultCapabilities();
    caps.setCapability(CapabilityType.LOGGING_PREFS, prefs);
    driver = new JavaDriver(caps, caps);
    LogEntries logEntries = driver.manage().logs().get(LogType.DRIVER);
    List<LogEntry> all = logEntries.getAll();
    AssertJUnit.assertEquals(0, all.size());
}
项目:NoraUi    文件:DriverFactory.java   
/**
 * Sets the logging level of the generated web driver.
 *
 * @param caps
 *            The web driver's capabilities
 * @param level
 *            The logging level
 */
private void setLoggingLevel(DesiredCapabilities caps) {
    final LoggingPreferences logPrefs = new LoggingPreferences();
    logPrefs.enable(LogType.BROWSER, Level.ALL);
    logPrefs.enable(LogType.CLIENT, Level.OFF);
    logPrefs.enable(LogType.DRIVER, Level.OFF);
    logPrefs.enable(LogType.PERFORMANCE, Level.OFF);
    logPrefs.enable(LogType.PROFILER, Level.OFF);
    logPrefs.enable(LogType.SERVER, Level.OFF);
    caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
}
项目:Bytecoder    文件:BytecoderUnitTestRunner.java   
private WebDriver newDriverForTest() {
    ChromeOptions theOptions = new ChromeOptions();
    theOptions.addArguments("headless");
    theOptions.addArguments("disable-gpu");

    LoggingPreferences theLoggingPreferences = new LoggingPreferences();
    theLoggingPreferences.enable(LogType.BROWSER, Level.ALL);
    theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences);

    DesiredCapabilities theCapabilities = DesiredCapabilities.chrome();
    theCapabilities.setCapability(ChromeOptions.CAPABILITY, theOptions);

    return new RemoteWebDriver(DRIVERSERVICE.getUrl(), theCapabilities);
}
项目:carnotzet    文件:ExamplesTest.java   
private static WebDriver createBrowserSession() throws MalformedURLException {
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setJavascriptEnabled(true);
    LoggingPreferences logPreferences = new LoggingPreferences();
    logPreferences.enable(LogType.BROWSER, Level.ALL);
    capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPreferences);
    return new RemoteWebDriver(
            new URL("http://" + runtime.getContainer("selenium-chrome").getIp() + ":4444/wd/hub"),
            capabilities
    );
}
项目:Cognizant-Intelligent-Test-Scripter    文件:WebDriverFactory.java   
@SuppressWarnings("unchecked")
private static LoggingPreferences getLogPrefs(String value) {
    LoggingPreferences logs = new LoggingPreferences();
    try {
        ObjectMapper mapper = new ObjectMapper();
        HashMap<String, String> prefs = mapper.readValue(value, HashMap.class);
        for (String logType : prefs.keySet()) {
            logs.enable(logType, Level.parse(prefs.get(logType)));
        }
    } catch (IOException ex) {
        LOGGER.log(Level.SEVERE, null, ex);
    }
    return logs;
}
项目:ja11y    文件:AccessibilitySinfferTest.java   
@Before
public void beforeTest() throws IOException {
    ChromeDriverManager.getInstance().setup();
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    LoggingPreferences logPrefs = new LoggingPreferences();
    logPrefs.enable(LogType.BROWSER, Level.ALL);
    desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
    driver = new ChromeDriver(desiredCapabilities);
    accessibilitySniffer = new AccessibilitySniffer(driver);

}
项目:delay-repay-bot    文件:PhantomJSTest.java   
public static DesiredCapabilities getDefaultDesiredCapabilities() {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setJavascriptEnabled(true);
    capabilities.setCapability("acceptSslCerts", true);
    capabilities.setCapability("takesScreenshot", true);
    capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, asList("--ignore-ssl-errors=true"));
    LoggingPreferences loggingPreferences = new LoggingPreferences();
    loggingPreferences.enable(LogType.BROWSER, Level.ALL);
    capabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences);
    return capabilities;
}
项目:delay-repay-bot    文件:PhantomJSTest.java   
public static DesiredCapabilities getChromeCapabilities() {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setJavascriptEnabled(true);
    capabilities.setCapability("acceptSslCerts", true);
    capabilities.setCapability("takesScreenshot", true);
    capabilities.setCapability(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, asList("--ignore-ssl-errors=true"));
    LoggingPreferences loggingPreferences = new LoggingPreferences();
    loggingPreferences.enable(LogType.BROWSER, Level.ALL);
    capabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences);
    return capabilities;
}
项目:grid-refactor-remote-server    文件:DefaultPerSessionLogHandler.java   
/**
 * Configures logging using a logging preferences object.
 * 
 * @param prefs The logging preferences object.
 */
@Override
public void configureLogging(LoggingPreferences prefs) {
  if (prefs == null) {
    return;
  }
  if (prefs.getEnabledLogTypes().contains(LogType.SERVER)) {      
    serverLogLevel = prefs.getLevel(LogType.SERVER);
  }
}
项目:gatf    文件:SeleniumTest.java   
public SeleniumTestResult(WebDriver d, SeleniumTest test, LoggingPreferences ___lp___)
{
    this.status = true;
    this.internalTestRes = test.internalTestRs;
    Logs logs = d.manage().logs();
    for (String s : LOG_TYPES_SET) {
        if(!logs.getAvailableLogTypes().contains(s))continue;
        LogEntries logEntries = logs.get(s);
        if(logEntries!=null && !logEntries.getAll().isEmpty()) {
            this.logs.put(s, new SerializableLogEntries(logEntries.getAll())); 
        }
    }
}
项目:gatf    文件:SeleniumTest.java   
public void newWindow(LoggingPreferences lp) {
    try
    {
        Method m = getClass().getMethod("setupDriver"+browserName, new Class[]{LoggingPreferences.class});
        if(m!=null) {
            m.invoke(this, new Object[]{lp});
        }
        __wpos__++;
    }
    catch (Exception e)
    {
        throw new RuntimeException("Invalid browser name specified");
    }
}
项目:gatf    文件:Test.java   
public void setupDriverappiumios(LoggingPreferences ___lp___) throws Exception {
    DesiredCapabilities ___dc___ = new DesiredCapabilities("ios", "null", org.openqa.selenium.Platform.MAC);
    ___dc___.setCapability(CapabilityType.LOGGING_PREFS, ___lp___);
    set___d___(new io.appium.java_client.ios.IOSDriver(new java.net.URL("http://127.0.0.1:4723/wd/hub"), ___dc___));
    setBrowserName("appium-ios");

}
项目:gatf    文件:Test.java   
public void setupDriverchrome(LoggingPreferences ___lp___) throws Exception {
    org.openqa.selenium.chrome.ChromeOptions ___dc___ = new org.openqa.selenium.chrome.ChromeOptions();
    ___dc___.setCapability(CapabilityType.LOGGING_PREFS, ___lp___);
    set___d___(new org.openqa.selenium.chrome.ChromeDriver(___dc___));
    setBrowserName("chrome");

}
项目:gatf    文件:Test.java   
@SuppressWarnings("unchecked")
public Map<String, SeleniumResult> execute(LoggingPreferences ___lp___) throws Exception {
    addTest("chrome");
    startTest();
    quit();
    setupDriverchrome(___lp___);
    _execute(___lp___);
    return get__result__();
}
项目:gatf    文件:GatfTestCaseExecutorMojo.java   
public ConcSeleniumTest(int index, AcceptanceTestContext context, List<SeleniumTest> tests, List<Object[]> testdata, LoggingPreferences lp) {
    this.index = index;
    this.context = context;
    this.tests = tests;
    this.testdata = testdata;
    this.lp = lp;
}
项目:teasy    文件:SeleniumTestExecutionListener.java   
private void setLoggingPrefs(DesiredCapabilities capabilities) {
    LoggingPreferences logPrefs = new LoggingPreferences();
    logPrefs.enable(LogType.BROWSER, Level.ALL);
    capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
}
项目:devtools-driver    文件:IOSLogManager.java   
public IOSLogManager(LoggingPreferences prefs) {
  Level perfLevel = prefs.getLevel(LogType.PERFORMANCE);
  if (perfLevel.intValue() < Level.OFF.intValue()) {
    logs.put(LogType.PERFORMANCE, new WebDriverLog(LogType.PERFORMANCE, perfLevel));
  }
}
项目:grid-refactor-remote-server    文件:NoOpSessionLogHandler.java   
@Override
public void configureLogging(LoggingPreferences prefs) {    
}
项目:crowdsource    文件:WebDriverProvider.java   
private void enableLogging(DesiredCapabilities capabilities) {
    LoggingPreferences loggingPreferences = new LoggingPreferences();
    loggingPreferences.enable(LogType.BROWSER, Level.ALL);
    capabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences);
}
项目:elpi    文件:WebdriverTestCase.java   
@Before
public void initDriver() throws Exception {
    if("local".equals(testType) || "all".equals(testType)) {
        if ("firefox".equals(targetBrowser)) {
            driver = new FirefoxDriver();
        }
        if ("chrome".equals(targetBrowser)) {
            driver = new ChromeDriver();
        }
    }

    OUTPUT_DIR = System.getProperty("BUILD_OUTPUT");

    name = readPropertyOrEnv("BUILD_TAG", getClass().getSimpleName());
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setCapability("name", name);

    if (targetPlatforme.equalsIgnoreCase("WINDOWS")) {
        platforme = Platform.WINDOWS;
    }
    desiredCapabilities.setCapability(CapabilityType.PLATFORM, platforme);
    desiredCapabilities.setJavascriptEnabled(true);
    if ("no".equals(videoCapture)) {
        desiredCapabilities.setCapability("record-video", false);
    }
    if ("no".equals(imageCapture)) {
        desiredCapabilities.setCapability("record-screenshots", false);
    }//we need this if use sauce lab integration
    //targetBrowser = readPropertyOrEnv("SELENIUM_BROWSER", targetBrowser);
    desiredCapabilities.setBrowserName(targetBrowser);
    System.out.println(System.getProperty("webdriver.chrome.driver"));
    if("htmlUnit".equals(testType)) {
        driver = new HtmlUnitDriver(desiredCapabilities);
    }
    LoggingPreferences logs = new LoggingPreferences(); 
    logs.enable(LogType.PROFILER, Level.INFO);
    desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, logs);
    URL gridurl = new URL(gridHubUrl);

    if ("grid".equals(testType) || "all".equals(testType)) {
        driver = new RemoteWebDriver(gridurl, desiredCapabilities);
    }
    if (driver instanceof JavascriptExecutor) {
        js = (JavascriptExecutor) driver;
    }
    RemoteWebDriver rd = (RemoteWebDriver) driver;
    sessionId = rd.getSessionId().toString();
    rd.setLogLevel(Level.INFO);
    driver.manage().window().maximize();
    recordingStarted = startRecording();
    actions = new Actions(driver);
}
项目:gatf    文件:GatfTestCaseExecutorMojo.java   
public ConcSeleniumTestDT(int index, AcceptanceTestContext context, List<SeleniumTest> tests, LoggingPreferences lp) {
    this.index = index;
    this.context = context;
    this.tests = tests;
    this.lp = lp;
}
项目:seletest    文件:DriverBeanPostProcessor.java   
/**
 * Actions after initializing beans
 */
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    String browserType=null;
    String clientLogs=null;

    ITestResult result=Reporter.getCurrentTestResult();

    if(result!=null) {
        browserType=Reporter.getCurrentTestResult().getMethod().getTestClass().getXmlTest().getAllParameters().get(env.getProperty("browser"));
        clientLogs=Reporter.getCurrentTestResult().getMethod().getTestClass().getXmlTest().getAllParameters().get(env.getProperty("logs"));
    }

    if(bean instanceof DesiredCapabilities) {

        /**Collect Javascript console errors*/
        if(clientLogs!=null && Boolean.parseBoolean(clientLogs)) {
            LoggingPreferences loggingprefs = new LoggingPreferences();
            loggingprefs.enable(LogType.BROWSER, Level.ALL);// Javascript console errors
            DesiredCapabilities logCaps=new DesiredCapabilities();
            logCaps.setCapability(CapabilityType.LOGGING_PREFS,loggingprefs);
            ((DesiredCapabilities) bean).merge(logCaps);
        }

        /**Defines browser capability for selenium grid requests*/
        if(browserType!=null) {
            if(browserType.compareTo("chrome") == 0) {
                ((DesiredCapabilities) bean).merge(DesiredCapabilities.chrome());
            } else if(browserType.compareTo("firefox") == 0) {
                ((DesiredCapabilities) bean).merge(DesiredCapabilities.firefox());
            } else if(browserType.compareTo("ie") == 0) {
                ((DesiredCapabilities) bean).merge(DesiredCapabilities.internetExplorer());
            } else if(browserType.compareTo("phantomJs") == 0) {
                ((DesiredCapabilities) bean).merge(DesiredCapabilities.phantomjs());
            }
        }

    }

    return bean;
}
项目:dropwizard-experiment    文件:WebDriverFactory.java   
private static void withBrowserLogs(DesiredCapabilities caps) {
    LoggingPreferences logs = new LoggingPreferences();
    logs.enable(LogType.BROWSER, Level.ALL);
    caps.setCapability(CapabilityType.LOGGING_PREFS, logs);
}
项目:grid-refactor-remote-server    文件:PerSessionLogHandler.java   
public abstract void configureLogging(LoggingPreferences loggingPrefs);
项目:gatf    文件:SeleniumTest.java   
public abstract Map<String, SeleniumResult> execute(LoggingPreferences ___lp___) throws Exception;