Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance log for Chrome doesn't work in 4.0.0-alpha.3 #7300

Closed
soulgalore opened this issue Jun 17, 2019 · 4 comments
Closed

Performance log for Chrome doesn't work in 4.0.0-alpha.3 #7300

soulgalore opened this issue Jun 17, 2019 · 4 comments

Comments

@soulgalore
Copy link
Contributor

soulgalore commented Jun 17, 2019

馃悰 Bug Report

With Chrome 75/Chromedriver 75 and NodeJS Selenium 4.0.0-alpha.3 getting the Chrome performance log fails. I think it was introduced in 8edc13b together with the Chromedriver switch to have w3c compliant as default.

This works with Selenium 3.6.0

To Reproduce

Run the following code + use Chromedriver 75 in the same dir and have Chrome 75 installed.

const chrome = require('selenium-webdriver/chrome');
const { Builder, logging } = require('selenium-webdriver');

const options = new chrome.Options();
const logPrefs = new logging.Preferences();
logPrefs.setLevel(logging.Type.PERFORMANCE, logging.Level.ALL);

const perfLogConf = { enableNetwork: true, enablePage: true };

options.setPerfLoggingPrefs(perfLogConf);
options.setLoggingPrefs(logPrefs);

const service = new chrome.ServiceBuilder()
  .loggingTo('./chromedriver.log')
  .enableVerboseLogging()
  .build();
chrome.setDefaultService(service);

const driver = new Builder()
  .forBrowser('chrome')
  .setChromeOptions(options)
  .build();

driver.get(
  'https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/chrome_exports_Driver.html'
);

Expected behavior

The code should not return any error.

It generates an error: InvalidArgumentError: invalid argument: perfLoggingPrefs specified, but performance logging was not enabled. However the log is enabled.

Checking the Chromedriver log we can see that the loggingPrefs is filtered out in the "always match part" (since it's only w3c compliant fields).

[1560795572.228][INFO]: Starting ChromeDriver 75.0.3770.90 (a6dcaf7e3ec6f70a194cc25e8149475c6590e025-refs/branch-heads/3770@{#1003})
[1560795572.228][INFO]: Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1560795572.251][INFO]: [8580073239e9346564a93f6dfcbd2cae] COMMAND InitSession {
   "capabilities": {
      "alwaysMatch": {
         "browserName": "chrome",
         "goog:chromeOptions": {
            "perfLoggingPrefs": {
               "enableNetwork": true,
               "enablePage": true
            }
         }
      }
   },
   "desiredCapabilities": {
      "browserName": "chrome",
      "goog:chromeOptions": {
         "perfLoggingPrefs": {
            "enableNetwork": true,
            "enablePage": true
         }
      },
      "loggingPrefs": {
         "performance": "ALL"
      }
   }
}
[1560795572.251][INFO]: [8580073239e9346564a93f6dfcbd2cae] RESPONSE InitSession ERROR invalid argument: perfLoggingPrefs specified, but performance logging was not enabled
[1560795572.251][DEBUG]: Log type 'driver' lost 1 entries on destruction

Is this a Chromedriver error or Selenium or both? It works in 3.6.0 :)

Environment

OS: OSX
Browser: Chrome
Browser version: 75
Browser Driver version: Chromedriver 75.0.3770.90
Language Bindings version: NodeJs 4.0.0-alpha.3

@cool-firer
Copy link

I met the same error, also Chrome 75, any solution?

@twalpole
Copy link
Contributor

As mentioned in the Chromedriver 75.0.3770.8 changelog - http://chromedriver.chromium.org/downloads - the preference name was changed to goog:loggingPrefs to be W3C compliant. I don't know if changing that will fix your issue though since the log access endpoints also changed in Chromedriver 75.0.3770.90 to be W3C compliant, and I'm not sure whether or not the JS 4.0 alpha supports the new endpoints yet.

@cool-firer
Copy link

yeah, looks like a way to get log:
'use strict'

const webdriver = require('selenium-webdriver');
const { Preferences, Type, Level } = require('selenium-webdriver/lib/logging')
const { By, Key, Capabilities, until } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

async function tesss() {

  const caps = webdriver.Capabilities.chrome();
  const logPrefs = new Preferences();
  logPrefs.setLevel(Type.PERFORMANCE, Level.ALL);

  caps.setLoggingPrefs(logPrefs);
  caps.set('goog:loggingPrefs', logPrefs);

  const options = new chrome.Options(caps);
  options.headless();

  const driver = new webdriver.Builder()
  .forBrowser('chrome')
  .setChromeOptions(options)
  .setFirefoxOptions(/* ... */)
  .build();

  await driver.get('https://www.google.com/');

  await driver.sleep(2000);

  const en = await driver.manage().logs().get(Type.PERFORMANCE);
  console.log(en);

  await driver.quit();

}
tesss();

According to https://stackoverflow.com/questions/53049026/selenium-chrome-performance-logs-not-working

@barancev
Copy link
Member

Fixed by commit 6674a23

@lock lock bot locked and limited conversation to collaborators Aug 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants