0

enter image description here

From above image one can see that when we start running nightwatch, in console we can see browser name, version and OS name and version.

Is there a way to get versions value and use in code just like we used to get platform as

process.platform=win32 or darwin
Govind
  • 483
  • 5
  • 8

1 Answers1

0

I got the answer from https://github.com/nightwatchjs/nightwatch/issues/2445.

module.exports = {
  'Demo test GitHub': function (browser) {
    console.log(browser); // this will output all the details
    browser
      .url('http://www.google.com')   // visit the url
  }
};
so browser object gives following details:

NightwatchAPI {
  capabilities:
   { acceptInsecureCerts: false,
     acceptSslCerts: false,
     applicationCacheEnabled: false,
     browserConnectionEnabled: false,
     browserName: 'chrome',
     chrome:
      { chromedriverVersion:
         '83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416})',
        userDataDir:
         '/var/folders/5l/mgjzx80j4pb1trj_zlqrn7cc0000gp/T/.com.google.Chrome.WEyC7u' },
     cssSelectorsEnabled: true,
     databaseEnabled: false,
     'goog:chromeOptions': { debuggerAddress: 'localhost:51082' },
     handlesAlerts: true,
     hasTouchScreen: false,
     javascriptEnabled: true,
     locationContextEnabled: true,
     mobileEmulationEnabled: false,
     nativeEvents: true,
     networkConnectionEnabled: false,
     pageLoadStrategy: 'normal',
     platform: 'Mac OS X',
     proxy: {},
     rotatable: false,
     setWindowRect: true,
     strictFileInteractability: false,
     takesHeapSnapshot: true,
     takesScreenshot: true,
     timeouts: { implicit: 0, pageLoad: 300000, script: 30000 },
     unexpectedAlertBehaviour: 'ignore',
     version: '83.0.4103.116',
     webStorageEnabled: true,
     'webauthn:virtualAuthenticators': true,
     'webdriver.remote.sessionid': '034ce20513343a06554a87cb14d45ce9' },
  currentTest: [Getter],
  desiredCapabilities: null,
  sessionId: '034ce20513343a06554a87cb14d45ce9',
  .
  .
  .
  

So if we want something like browser name, version, OS name, etc use below:

console.log(browser.capabilities.platform) //prints... Mac OS X
console.log(browser.capabilities.browserName) //prints.. chrome
console.log(browser.capabilities.version) //prints... 83.0.4103.116
Govind
  • 483
  • 5
  • 8