Firebug, ConsoleExport, NetExprot and Selenium

359 views
Skip to first unread message

Katy Dayan

unread,
Jan 7, 2015, 2:19:50 AM1/7/15
to fir...@googlegroups.com

Hello,

I want to export the console and net summary to the log files in my selenium automatic tests.

My environment is:
    Linux   : Red Hat Enterprise Linux Workstation release 6.3 (Santiago)
    Firefox : Mozilla Firefox 34.0.5
    Add-ons :
         WebDriver:      2.44.0
         Firebug  :      2.0.7
         ConsoleExport:  0.5b5
         NetExport:      0.9b6


My selenium Java code is like this:

package com.testscripts.iwb;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;

public class testFirefoxProfile {

	private static void printDir(String DirName) {

		if (!DirName.equals(null)){
			
			File folder = new File(DirName);
			File[] listOfFiles = folder.listFiles();
			
			System.out.println("   Start ["+DirName+"] : ");
			try {
		
				for (File f : listOfFiles) {
					if (f.isFile()) {
						System.out.println("               "+ f.getName());
						
					}
				}
				
				
				System.out.println("   End ["+DirName+"]");		
				
			}
			catch (Exception e) {
				e.printStackTrace();
			}
		}					
	}
	
	private static void deleteFileOrFolder (File file){
	    try {
	        if (file.exists()){
	        	for (File f : file.listFiles()) {
	        		f.delete();
	        		deleteFileOrFolder (f);
	        	}
	        	file.delete();
	        }
	    } catch (Exception e) {
	        e.printStackTrace(System.err);
	    }
	}
	
	public static void main(String[] args) {
		System.out.print("Start: testFirefoxProfile\n");
		
		FirefoxProfile p = new FirefoxProfile();
		
		String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());

		try {
			//p.addExtension(new File("/development/rels/glue/firefox/firefox/extensions/firebug-1.12.8.xpi"));
			p.addExtension(new File("/development/rels/glue/firefox/firefox/extensions/firebug-2.0.7.xpi"));
			p.addExtension(new File("/development/rels/glue/firefox/firefox/extensions/netExport-0.9b6.xpi"));
			p.addExtension(new File("/development/rels/glue/firefox/firefox/extensions/consoleExport-0.5b5.xpi"));
		} catch (IOException e) {
			throw new RuntimeException("Could not load required extensions, did you download them to the above location? ", e);
		}
		
		p.setPreference("extensions.firebug.currentVersion", "2.0.7");
		p.setPreference("extensions.firebug.DBG_NETEXPORT", false);
		p.setPreference("extensions.firebug.onByDefault", true);
		p.setPreference("extensions.firebug.defaultPanelName", "net");
		p.setPreference("extensions.firebug.net.enableSites", true);
		p.setPreference("extensions.firebug.net.persistent", true);
		p.setPreference("extensions.firebug.netexport.alwaysEnableAutoExport", true);
		p.setPreference("extensions.firebug.netexport.autoExportToFile", true);
		p.setPreference("extensions.firebug.netexport.autoExportToServer", false);
		p.setPreference("extensions.firebug.netexport.defaultLogDir", "/tmp/netExport");
		p.setPreference("extensions.firebug.netexport.showPreview", true); // preview.
		p.setPreference("extensions.firebug.netexport.sendToConfirmation", false);
		p.setPreference("extensions.firebug.netexport.pageLoadedTimeout", 1500);
		p.setPreference("extensions.firebug.netexport.Automation", true);
		
	
//		 // Set default Firebug preferences
        p.setPreference("extensions.firebug.allPagesActivation", "on");
        p.setPreference("extensions.firebug.console.enableSites", "true");
        p.setPreference("extensions.firebug.defaultPanelName", "console");
        p.setPreference("extensions.firebug.DBG_CONSOLEEXPORT", false);
        
        // Set default consoleExport preferences
        p.setPreference("extensions.firebug.consoleexport.defaultLogDir", "/tmp/consoleExport");
        p.setPreference("extensions.firebug.consoleexport.active", true);
        p.setPreference("extensions.firebug.consoleexport.logFilePath", "/tmp/consoleExport/console_export.log");

		///tests
        p.setPreference("browser.startup.homepage",
				"http://www.google.com");

        
 
		if (new File("/tmp/netExport").mkdir() && new File("/tmp/consoleExport").mkdir()) {
			System.out.println("Directories are  created!");
		} else {
			System.out.println("Failed to create directories!");
		}
	
		System.out.println("["+timeStamp+"]Before Test Start, Dir Contents");
		printDir("/tmp/netExport");
		printDir("/tmp/consoleExport");
        
		WebDriver driver = new FirefoxDriver(p);
		try {
			Thread.sleep(500);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		WebElement element = driver.findElement(By.name("q"));
		element.sendKeys("selenium");
		element.submit();
		element.clear();
		element.sendKeys("firefox");
		element.submit();
		element.clear();
		element.sendKeys("firebug");
		element.submit();
		element.clear();
		
		try {
			Thread.sleep(50000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		driver.quit();
		timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
		System.out.println("["+timeStamp+"]After Test Finished, Dir Contents");
		printDir("/tmp/netExport");
		printDir("/tmp/consoleExport");
		
		// cleaning:
		deleteFileOrFolder(new File("/tmp/netExport"));
		deleteFileOrFolder(new File("/tmp/consoleExport"));
		
		
		System.out.print("Done\n");
	}
	
	
}



At  the end of the running test reports:

Start: testFirefoxProfile
Directories are  created!
[2015.01.07.09.15.10]Before Test Start, Dir Contents
   Start [/tmp/netExport] : 
   End [/tmp/netExport]
   Start [/tmp/consoleExport] : 
   End [/tmp/consoleExport]
[2015.01.07.09.16.21]After Test Finished, Dir Contents
   Start [/tmp/netExport] : 
   End [/tmp/netExport]
   Start [/tmp/consoleExport] : 
   End [/tmp/consoleExport]
Done


I've tried with/without creating the root directories for the log, the results are the same 

Please advise, what is wrong?

Thanks,
Katy

Arie Hoenel

unread,
Jan 7, 2015, 12:01:55 PM1/7/15
to fir...@googlegroups.com

Katy Dayan

unread,
Jan 18, 2015, 4:27:07 AM1/18/15
to fir...@googlegroups.com
Hi

Solution for ConsoleExport it here (with attached patch of consoleExport   -  consoleExport-0.5b6.xpi )

Thank,
Katy

среда, 7 января 2015 г., 19:01:55 UTC+2 пользователь Arie Hoenel написал:

Arie Hoenel

unread,
Jan 18, 2015, 4:59:31 AM1/18/15
to fir...@googlegroups.com
that is solution for console not for netExport

--
You received this message because you are subscribed to a topic in the Google Groups "Firebug" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebug/fESjQLqYtv4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebug+u...@googlegroups.com.
To post to this group, send email to fir...@googlegroups.com.
Visit this group at http://groups.google.com/group/firebug.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebug/97b59266-e815-4b56-8ff6-6b958bef894d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages