SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
345 stars 195 forks source link

RemoteWebDriver to get LogType=performance produces exception, works fine with ChromeDriver #8457

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 8457

Using RemoteWebDriver to obtain performance logs from LogType produces and exception.
 If you use a general ChromeDriver object, the performance logs are produced.

What steps will reproduce the problem?
1. Create a driver instance using RemoteWebDriver:

Does NOT produce performance logs:
        desiredCapabilites = DesiredCapabilities.firefox()
        LoggingPreferences logPrefs = new LoggingPreferences()
        logPrefs.enable(LogType.PERFORMANCE, Level.ALL)
        desiredCapabilites.setCapability(CapabilityType.LOGGING_PREFS, logPrefs)
        driver = { new RemoteWebDriver(new URL(seleniumGridUrl), desiredCapabilites)
}

Produces performance logs without issue:
        desiredCapabilites = DesiredCapabilities.chrome()
        LoggingPreferences logPrefs = new LoggingPreferences()
        logPrefs.enable(LogType.PERFORMANCE, Level.ALL)
        desiredCapabilites.setCapability(CapabilityType.LOGGING_PREFS, logPrefs)
        driver = { new ChromeDriver(desiredCapabilites) }

2. Execute driver.manage().logs().get(LogType.PERFORMANCE)

3. Not results are found, exception thrown.

What is the expected output?
To get a list (possibly empty) of performance logs

 What do you see instead?
org.openqa.selenium.WebDriverException: unknown error: log type 'performance' not found
  (Session info: chrome=40.0.2214.94)
  (Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Mac
OS X 10.10.2 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2 milliseconds
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'N/A', ip: 'N/A', os.name: 'Mac OS X', os.arch: 'x86_64', os.version:
'10.10.2', java.version: '1.7.0_71'
Session ID: bde2c7d069c27dc7bbd60625806f33a0
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome,
chrome={userDataDir=/var/folders/74/nn0zw7d576jbgvdsnjyhwkmw0000gn/T/.org.chromium.Chromium.yK7ES9},
rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, version=40.0.2214.94,
takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true,
browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false,
takesScreenshot=true}]
Command duration or timeout: 126 milliseconds
Build info: version: '2.43.1', revision: '5163bceef1bc36d43f3dc0b83c88998168a363a0',
time: '2014-09-10 09:43:55'
System info: host: 'N/A', ip: 'N/A', os.name: 'Mac OS X', os.arch: 'x86_64', os.version:
'10.10.2', java.version: '1.7.0_55'
Session ID: 2bbb10fd-9e1d-46dc-b500-a5e08227c100
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome,
chrome={userDataDir=/var/folders/74/nn0zw7d576jbgvdsnjyhwkmw0000gn/T/.org.chromium.Chromium.yK7ES9},
rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, webdriver.remote.sessionid=2bbb10fd-9e1d-46dc-b500-a5e08227c100,
version=40.0.2214.94, takesHeapSnapshot=true, databaseEnabled=false, cssSelectorsEnabled=true,
handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true,
applicationCacheEnabled=false, takesScreenshot=true}]
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
    at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:34)
    at org.openqa.selenium.remote.RemoteLogs.getRemoteEntries(RemoteLogs.java:65)
    at org.openqa.selenium.remote.RemoteLogs.get(RemoteLogs.java:61)

Selenium version:2.43.1 and 2.44.0
OS:OSX Yosemite, Windows7, Windows8
Browser:Chrome
Browser version:40.0.2214.93

Reported by email@stephencopp.com on 2015-02-04 17:06:52

lukeis commented 8 years ago
Moved to: Issue chromedriver:1064

Reported by barancev on 2015-03-21 12:52:53

lukeis commented 8 years ago
By the way, I can't reproduce the issue. Here is the code:

    DesiredCapabilities desiredCapabilites = DesiredCapabilities.chrome();
    LoggingPreferences logPrefs = new LoggingPreferences();
    logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
    desiredCapabilites.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
    RemoteWebDriver driver = new RemoteWebDriver(desiredCapabilites);
    try {
      System.out.println(driver.manage().logs().getAvailableLogTypes());
      driver.get("http://localhost/");
      for (LogEntry logEntry : driver.manage().logs().get(LogType.PERFORMANCE).getAll())
{
        System.out.println(logEntry);
      }

    } finally {
      driver.quit();
    }

The console output on the server side:

16:50:13.005 INFO - Executing: [new session: Capabilities [{loggingPrefs=org.ope
nqa.selenium.logging.LoggingPreferences@64bb5a5e, browserName=chrome, version=,
platform=ANY}]])
16:50:13.006 INFO - Creating a new session for Capabilities [{loggingPrefs=org.o
penqa.selenium.logging.LoggingPreferences@64bb5a5e, browserName=chrome, version=
, platform=ANY}]
Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on
port 19863
Only local connections are allowed.
16:50:15.631 INFO - Done: [new session: Capabilities [{loggingPrefs=org.openqa.s
elenium.logging.LoggingPreferences@64bb5a5e, browserName=chrome, version=, platf
orm=ANY}]]
16:50:15.653 INFO - Executing: [fetching available log types])
16:50:15.660 INFO - Done: [fetching available log types]
16:50:15.739 INFO - Executing: [get: http://localhost/])
16:50:29.728 INFO - Done: [get: http://localhost/]
16:50:29.753 INFO - Executing: [fetching logs for: performance])
16:50:29.798 INFO - Done: [fetching logs for: performance]
16:50:29.904 INFO - Executing: [delete session: 538d4407-d685-4292-a519-01aa25f0
d412])
16:50:31.040 INFO - Done: [delete session: 538d4407-d685-4292-a519-01aa25f0d412]

The console output on the client side:

[performance, browser, driver, client, server]
[2015-03-21T16:50:20+0400] [INFO] {"message":{"method":"Network.responseReceived","params":{"frameId":"28480.1","loaderId":"28480.2","requestId":"28480.1","response":{"connectionId":0,"connectionReused":false,"encodedDataLength":-1,"fromDiskCache":false,"fromServiceWorker":false,"headers":{"Access-Control-Allow-Origin":"*","Content-Type":"text/plain;charset=US-ASCII"},"mimeType":"text/plain","protocol":"data","status":200,"statusText":"OK","url":"data:,"},"timestamp":1426942217.5344,"type":"Other"}},"webview":"C359224A-06E5-42B6-8D1B-52687733920A"}
[2015-03-21T16:50:20+0400] [INFO] {"message":{"method":"Network.loadingFinished","params":{"encodedDataLength":0,"requestId":"28480.1","timestamp":1426942217.5344}},"webview":"C359224A-06E5-42B6-8D1B-52687733920A"}
[2015-03-21T16:50:20+0400] [INFO] {"message":{"method":"Page.frameNavigated","params":{"frame":{"id":"28480.1","loaderId":"28480.2","mimeType":"text/plain","securityOrigin":"://","url":"data:,"}}},"webview":"C359224A-06E5-42B6-8D1B-52687733920A"}
[2015-03-21T16:50:21+0400] [INFO] {"message":{"method":"Page.loadEventFired","params":{"timestamp":1426942220.99924}},"webview":"C359224A-06E5-42B6-8D1B-52687733920A"}
[2015-03-21T16:50:21+0400] [INFO] {"message":{"method":"Page.frameStoppedLoading","params":{"frameId":"28480.1"}},"webview":"C359224A-06E5-42B6-8D1B-52687733920A"}
[2015-03-21T16:50:21+0400] [INFO] {"message":{"method":"Page.domContentEventFired","params":{"timestamp":1426942220.99927}},"webview":"C359224A-06E5-42B6-8D1B-52687733920A"}
....

Reported by barancev on 2015-03-21 12:56:02

lukeis commented 8 years ago
Can you try instantiating the RemoteWebDriver with the constructor containing a remote
URL like my example?  Selenium is hosted elsewhere; otherwise, I would just use the
ChromeDriver instantiation.

public RemoteWebDriver(java.net.URL remoteAddress, Capabilities desiredCapabilities)

Reported by email@stephencopp.com on 2015-03-21 16:58:00

lukeis commented 8 years ago
new RemoteWebDriver(desiredCapabilites)
is equivalent to
new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), desiredCapabilites)
see
https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/remote/HttpCommandExecutor.java#L70-L72

Unfortunately I can't try MacOS, may be it is platform-specific issue.

Reported by barancev on 2015-03-22 08:31:03

lukeis commented 8 years ago
This is not platform specific; I can repo it on both Mac and Windows.

This occurs when using the Selenium Grid, typically a remote URL, not a localhost URL.
 To reproduce locally:

Start a selenium grid locally:
java -jar selenium-server-standalone-2.45.0.jar -role node  -hub http://localhost:4444/grid/register
-browser browserName=chrome,maxInstances=1

Start a selenium node locally:
java -jar selenium-server-standalone-2.45.0.jar -role hub

Run your same scenario again:
    DesiredCapabilities desiredCapabilites = DesiredCapabilities.chrome();
    LoggingPreferences logPrefs = new LoggingPreferences();
    logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
    desiredCapabilites.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
    RemoteWebDriver driver = new RemoteWebDriver(desiredCapabilites);
    try {
      System.out.println(driver.manage().logs().getAvailableLogTypes());
      driver.get("http://localhost/");
      for (LogEntry logEntry : driver.manage().logs().get(LogType.PERFORMANCE).getAll())
{
        System.out.println(logEntry);
      }

    } finally {
      driver.quit();
    }

Reported by stephencopp on 2015-03-23 16:13:52

lukeis commented 8 years ago

Reported by gmanikpure@chromium.org on 2015-03-23 17:34:50

lukeis commented 8 years ago
Reproduced

Reported by barancev on 2015-03-28 17:45:57

lukeis commented 8 years ago

Reported by barancev on 2015-03-28 17:45:58

lukeis commented 8 years ago

Reported by barancev on 2015-03-28 17:46:54

lukeis commented 8 years ago
Fixed by https://github.com/SeleniumHQ/selenium/commit/01bf9a0372b98a50026b6a4411504ce8341f3c51

Reported by barancev on 2015-03-28 19:29:39

lukeis commented 8 years ago
exellent, thank you!

Reported by email@stephencopp.com on 2015-03-30 15:51:59

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 18:25:11