package organized.chaos;
import java.util.logging.Level;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.logging.LogEntries;
import org.openqa.selenium.logging.LogEntry;
import org.openqa.selenium.logging.LogType;
import org.openqa.selenium.logging.LoggingPreferences;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
public class FetchBrowserConsoleLogsTest {
private WebDriver wd = null;
@Test
public void f() {
wd.get("http://www.facebook.com");
}
@BeforeMethod
public void beforeMethod() {
DesiredCapabilities dc = DesiredCapabilities.firefox();
LoggingPreferences prefs = new LoggingPreferences();
prefs.enable(LogType.BROWSER, Level.ALL);
dc.setCapability(CapabilityType.LOGGING_PREFS, prefs);
wd = new FirefoxDriver(dc);
}
@AfterMethod
public void afterMethod() {
if (wd != null) {
LogEntries logEntries = wd.manage().logs().get(LogType.BROWSER);
for (LogEntry eachEntry : logEntries.getAll()){
System.out.println(eachEntry.toString());
}
wd.quit();
}
}
}
The URL would need to be prefixed with http://localhost:5555/wd/hub/ [ here 5555 is the port numberof the node and NOT the grid ]
Visit this group at https://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/d/optout.
console.log("your message")
But i could not get console.log messages. I have tried all type of logs. Can some one help me ?
Thanks,
Param
window.consoleLogs = "";
console.log = function(msg){ window.consoleLogs += msg + "\n"; };
return window.consoleLogs; //or return the global variable you defined if named something else