Search in sources :

Example 11 with LogEntry

use of org.openqa.selenium.logging.LogEntry in project ghostdriver by detro.

the class LogTest method shouldReturnLogTypeBrowser.

@Test
public void shouldReturnLogTypeBrowser() {
    WebDriver d = getDriver();
    d.get(server.getBaseUrl() + "/common/errors.html");
    // Throw 3 errors that are logged in the Browser's console
    WebElement throwErrorButton = d.findElement(By.cssSelector("input[type='button']"));
    throwErrorButton.click();
    throwErrorButton.click();
    throwErrorButton.click();
    // Retrieve and count the errors
    LogEntries logEntries = d.manage().logs().get("browser");
    assertEquals(3, logEntries.getAll().size());
    for (LogEntry logEntry : logEntries) {
        System.out.println(logEntry);
    }
    // Clears logs
    logEntries = d.manage().logs().get("browser");
    assertEquals(0, logEntries.getAll().size());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) LogEntries(org.openqa.selenium.logging.LogEntries) WebElement(org.openqa.selenium.WebElement) LogEntry(org.openqa.selenium.logging.LogEntry) Test(org.junit.Test)

Example 12 with LogEntry

use of org.openqa.selenium.logging.LogEntry in project ghostdriver by detro.

the class LogTest method shouldReturnLogTypeHar.

@Test
public void shouldReturnLogTypeHar() {
    WebDriver d = getDriver();
    d.get(server.getBaseUrl() + "/common/iframes.html");
    LogEntries logEntries = d.manage().logs().get("har");
    for (LogEntry logEntry : logEntries) {
        System.out.println(logEntry);
    }
    String firstRequestMessage = logEntries.getAll().get(0).getMessage();
    String secondRequestMessage = d.manage().logs().get("har").getAll().get(0).getMessage();
    assertTrue(secondRequestMessage.length() < firstRequestMessage.length());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) LogEntries(org.openqa.selenium.logging.LogEntries) LogEntry(org.openqa.selenium.logging.LogEntry) Test(org.junit.Test)

Aggregations

LogEntry (org.openqa.selenium.logging.LogEntry)12 LogEntries (org.openqa.selenium.logging.LogEntries)8 WebDriver (org.openqa.selenium.WebDriver)5 Test (org.junit.Test)4 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)4 File (java.io.File)3 PrintWriter (java.io.PrintWriter)3 ChromeBrowserTest (com.vaadin.flow.testutil.ChromeBrowserTest)2 CompileOptions (de.mirkosertic.bytecoder.backend.CompileOptions)2 CompileTarget (de.mirkosertic.bytecoder.backend.CompileTarget)2 BytecodeMethodSignature (de.mirkosertic.bytecoder.core.BytecodeMethodSignature)2 BytecodeObjectTypeRef (de.mirkosertic.bytecoder.core.BytecodeObjectTypeRef)2 ControlFlowProcessingException (de.mirkosertic.bytecoder.ssa.ControlFlowProcessingException)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Optional (java.util.Optional)2 StreamSupport (java.util.stream.StreamSupport)2 Assert (org.junit.Assert)2