当前位置: 首页>>代码示例>>Java>>正文


Java LogType类代码示例

本文整理汇总了Java中org.openqa.selenium.logging.LogType的典型用法代码示例。如果您正苦于以下问题:Java LogType类的具体用法?Java LogType怎么用?Java LogType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LogType类属于org.openqa.selenium.logging包,在下文中一共展示了LogType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPerformanceLoggingCapabilities

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
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;
}
 
开发者ID:hy9be,项目名称:spa-perf,代码行数:20,代码来源:SPAPerfChromeDriver.java

示例2: getTestLogs

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
public boolean getTestLogs(String videoFileName) throws Exception {
    HTMLFormatter f = new HTMLFormatter();
    File logFile = new File(OUTPUT_DIR + videoFileName + ".html");
    if (!logFile.exists()) {
        logFile.createNewFile();
    }
    FileOutputStream fos = new FileOutputStream(logFile);
    PrintStream ps = new PrintStream(fos);
    
    ps.print(f.getHead(null));
    ps.println();
    
    LogEntries entries =  driver.manage().logs().get(LogType.CLIENT);
    for(LogEntry entry : entries.getAll()) {
        if (entry.getMessage().contains("Executing:") || entry.getMessage().contains("Executed:")) {
            ps.print(f.format(entry));
            ps.println();
        }
    }
    ps.print(f.getTail(null));
    ps.println();
    ps.close();
    return true;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:25,代码来源:WebdriverTestCase.java

示例3: dndWithMove

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
public void dndWithMove() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities();
    // caps.setCapability("nativeEvents", true);
    driver = new JavaDriver(caps, caps);
    WebElement list = driver.findElement(By.cssSelector("list"));
    assertEquals(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 4\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list.getAttribute("content"));
    WebElement listitem1 = driver.findElement(By.cssSelector("list::nth-item(1)"));
    WebElement listitem5 = driver.findElement(By.cssSelector("list::nth-item(5)"));
    driver.clearlogs(LogType.DRIVER);
    System.err.println("About to sleep");
    new Actions(driver).dragAndDrop(listitem1, listitem5).perform();
    waitTillDropCompletes(
            "[[\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list);
    assertEquals(
            "[[\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list.getAttribute("content"));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:DragAndDropTest.java

示例4: dndWithCopy

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
public void dndWithCopy() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities();
    // caps.setCapability("nativeEvents", true);
    driver = new JavaDriver(caps, caps);
    WebElement list = driver.findElement(By.cssSelector("list"));
    assertEquals(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 4\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list.getAttribute("content"));
    WebElement listitem1 = driver.findElement(By.cssSelector("list::nth-item(1)"));
    WebElement listitem5 = driver.findElement(By.cssSelector("list::nth-item(5)"));
    listitem1.click();
    driver.clearlogs(LogType.DRIVER);
    Keys copyKey = Keys.ALT;
    if (Platform.isWindows()) {
        copyKey = Keys.CONTROL;
    }
    new Actions(driver).keyDown(copyKey).dragAndDrop(listitem1, listitem5).keyUp(copyKey).perform();
    waitTillDropCompletes(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0(1)\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list);
    assertEquals(
            "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0(1)\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
            list.getAttribute("content"));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:25,代码来源:DragAndDropTest.java

示例5: newDriverForTest

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
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);
}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:15,代码来源:BytecoderUnitTestRunner.java

示例6: getLog

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
@Override
public String getLog( DeviceWebDriver webDriver )
{
    try
       {
           LogEntries logEntries = webDriver.manage().logs().get( LogType.BROWSER );
           if ( logEntries != null )
           {
               StringBuilder logBuilder = new StringBuilder();
               for ( LogEntry logEntry : logEntries )
                   logBuilder.append( dateFormat.format( new Date( logEntry.getTimestamp() ) ) ).append( ": " ).append( logEntry.getMessage() ).append( "\r\n" );

               logBuilder.toString();
           }
           return null;
       }
       catch ( Exception e )
       {
           log.info( "Could not generate device logs" );
           return null;
       }
    
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:24,代码来源:SELENIUMCloudActionProvider.java

示例7: getLog

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
@Override
public String getLog( DeviceWebDriver webDriver )
{
    try
    {
        LogEntries logEntries = webDriver.manage().logs().get( LogType.BROWSER );
        if ( logEntries != null )
        {
            StringBuilder logBuilder = new StringBuilder();
            for ( LogEntry logEntry : logEntries )
                logBuilder.append( dateFormat.format( new Date( logEntry.getTimestamp() ) ) ).append( ": " ).append( logEntry.getMessage() ).append( "\r\n" );

            logBuilder.toString();
        }
        return null;
    }
    catch ( Exception e )
    {
        log.info( "Could not generate device logs" );
        return null;
    }
    
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:24,代码来源:SAUCELABSCloudActionProvider.java

示例8: processLogEntries

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
void processLogEntries(ScenarioExecutionContext context, ActionReport actionReport) {
    try {
        List<org.openqa.selenium.logging.LogEntry> logEntries = context.getDriver().manage().logs().get(LogType.BROWSER).getAll();
        ExecutorOptions options = context.getGlobalContext().getOptions();

        // TODO extract mapper
        List<LogEntry> convertedLogEntries = new ArrayList<>();

        for (org.openqa.selenium.logging.LogEntry logEntry : logEntries) {
            LogLevel actualLevel = convertLogLevel(logEntry.getLevel());

            if (LogEntry.isIncluded(options.getBrowserLogLevel(), actualLevel)) {
                convertedLogEntries.add(new LogEntry(
                    actualLevel, new Date(logEntry.getTimestamp()), logEntry.getMessage()));
            }
        }

        actionReport.setLogEntries(convertedLogEntries);
    } catch (UnsupportedCommandException e) {
        // TODO set flag on the report: https://github.com/automate-website/waml-io/issues/2
        LOG.warn("Current WebDriver does not support browser logging!");
    }
}
 
开发者ID:automate-website,项目名称:jwebrobot,代码行数:24,代码来源:Reporter.java

示例9: shouldConvertLogEntries

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
@Test
public void shouldConvertLogEntries() {
    LogEntries logEntries = mock(LogEntries.class);
    when(logs.get(LogType.BROWSER)).thenReturn(logEntries);
    LogEntry logEntry = mock(LogEntry.class);
    when(logEntries.getAll()).thenReturn(asList(logEntry));

    when(logEntry.getLevel()).thenReturn(Level.FINEST);
    when(executorOptions.getBrowserLogLevel()).thenReturn(website.automate.waml.report.io.model.LogEntry.LogLevel.DEBUG);

    reporter.processLogEntries(context, actionReport);

    verify(logEntries).getAll();

    verify(actionReport).setLogEntries(logEntryListCaptor.capture());
    List<website.automate.waml.report.io.model.LogEntry> logEntryList = logEntryListCaptor.getValue();
    assertThat(logEntryList, hasSize(1));
}
 
开发者ID:automate-website,项目名称:jwebrobot,代码行数:19,代码来源:ReporterTest.java

示例10: TestGoogleSearch

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
public static void TestGoogleSearch() throws MalformedURLException {
    //google.com
    SPAPerfChromeDriver driver = new SPAPerfChromeDriver();

    driver.get("https://news.google.com/");

    WebElement element = driver.findElement(By.name("q"));
    element.sendKeys("Selenium Conference");
    element.sendKeys(Keys.ENTER);

    ConsolePrinter printer = new ConsolePrinter();

    printer.printLogToConsole(driver, LogType.PERFORMANCE);

    //driver.detach();
    driver.close();
}
 
开发者ID:hy9be,项目名称:spa-perf,代码行数:18,代码来源:SampleTestScript.java

示例11: readPerfLog

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
public List<JsonObject> readPerfLog() throws Exception {
    List<LogEntry> entries = this.manage().logs().get(LogType.PERFORMANCE).getAll();

    List<JsonObject> events = new ArrayList<>();

    for (LogEntry entry : entries) {
        JsonObject message = JsonObject.readFrom(entry.getMessage()).get("message").asObject();

        if (message.get("method").asString() == "Tracing.dataCollected") {
            events.add(message.get("params").asObject());
        }
        if (message.get("method").asString() == "Tracing.bufferUsage") {
            throw new Exception("The DevTools trace buffer filled during the test!");
        }
    }

    return convertPerfRecordsToEvents(events);
}
 
开发者ID:hy9be,项目名称:spa-perf,代码行数:19,代码来源:SPAPerfChromeDriver.java

示例12: createDriver

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
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);
    	}
    }
 
开发者ID:hoozheng,项目名称:AndroidRobot,代码行数:22,代码来源:ChromeDriverClient.java

示例13: fetchAndStoreLogsFromDriver

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
/**
 * Fetches and stores available logs from the given session and driver.
 * 
 *  @param sessionId The id of the session.
 *  @param driver The driver to get the logs from.
 *  @throws IOException If there was a problem reading from file.
 */
@Override
public synchronized void fetchAndStoreLogsFromDriver(SessionId sessionId, WebDriver driver) 
    throws IOException {
  if (!perSessionDriverEntries.containsKey(sessionId)) {
    perSessionDriverEntries.put(sessionId, Maps.<String, LogEntries>newHashMap());
  }
  Map<String, LogEntries> typeToEntriesMap = perSessionDriverEntries.get(sessionId);
  if (storeLogsOnSessionQuit) {
    typeToEntriesMap.put(LogType.SERVER, getSessionLog(sessionId));
    Set<String> logTypeSet = driver.manage().logs().getAvailableLogTypes();
    for (String logType : logTypeSet) {
      typeToEntriesMap.put(logType, driver.manage().logs().get(logType));
    }
  }
}
 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:23,代码来源:DefaultPerSessionLogHandler.java

示例14: after

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
@cucumber.api.java.After
public void after(Scenario result) {
    if (webDriverProvider.hasActiveWebDriver()) {
        WebDriver webDriver = webDriverProvider.provideDriver();

        if (result != null) {
            LogEntries logs = webDriver.manage().logs().get(LogType.BROWSER);

            if (LOG.isInfoEnabled()) {
                String logOutput = logs.getAll().stream()
                        .map(LogEntry::toString)
                        .collect(joining("\n"));

                LOG.info("Browser console.log output: {}", "\n" + logOutput);
            }
        }
    }
}
 
开发者ID:as-ideas,项目名称:crowdsource,代码行数:19,代码来源:BrowserLogFetchHook.java

示例15: dumpLog

import org.openqa.selenium.logging.LogType; //导入依赖的package包/类
private void dumpLog() throws Exception {
	Logs log = driver.manage().logs();
	LogEntries entries = log.get(LogType.BROWSER);
	// System.out.println(entries);
	List<LogEntry> list = entries.getAll();
	boolean fail = false;
	for (int i = 0; i < list.size(); i++) {
		LogEntry e = list.get(i);
		System.out.println(e);
		if (e.getLevel().getName().equals("SEVERE") 
				&& e.getMessage().indexOf("Uncaught ") != -1
				&& e.getMessage().indexOf(" Error:") != -1) {
			System.out.println("*** Uncaught Error ***");
			fail = true;
		}		    			
	}
	if (fail) throw new Exception("Unhandled Exception! Check console log for details");		
}
 
开发者ID:redskyit,项目名称:ScriptDriver,代码行数:19,代码来源:RunTests.java


注:本文中的org.openqa.selenium.logging.LogType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。