mercredi 24 mars 2021

Console log only showing failed requests

I am attempting to grab a url from my console log during my automated tests but for some reason its only showing all the console errors in my print out. How can I show everything thats in my console log and then pick out the url I want. The code im using:

    ChromeOptions options = new ChromeOptions();
    options.addArguments("start-maximized");
    options.addArguments("disable-infobars");
    options.addArguments("--disable-extensions");
    options.addArguments("--window-size=1920x1080");
    options.addArguments("--disable-cache");
    //options.addArguments("--headless");
    options.addArguments("--disable-application-cache");
    options.addArguments("--disk-cache-size=0");
    options.addArguments("--disable-gpu"); // applicable to windows os only
    options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
    options.addArguments("--dns-prefetch-disable");
    LoggingPreferences logPrefs = new LoggingPreferences();
    logPrefs.enable(LogType.BROWSER, Level.INFO);
    options.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
    //options.addArguments("--no-sandbox"); // Bypass OS security model
    options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
    driver = new ChromeDriver(options);


public static void analyzeLog() {

    LogEntries entry = driver.manage().logs().get(LogType.BROWSER);
    // Retrieving all log
    List<LogEntry> logs= entry.getAll();
    // Print one by one
    for(LogEntry e: logs)
    {
        System.out.println(e);
    }

    // Printing details separately
    for(LogEntry e: logs)
    {
        System.out.println("Message is: " +e.getMessage());
        System.out.println("Level is: " +e.getLevel());
    }



}

Aucun commentaire:

Enregistrer un commentaire