Get the current name in the configuration of multi-conveyor transporters?

I use browser.getCapabilities () to get information about browser name and platform.

Multichannel configuration configuration:



    multiCapabilities:[
    {
    browserName: 'chrome',
    name: 'iPhone',
    chromeOptions: {
            args: ['--window-size=400,800','--user-agent="Mozilla/5.0 (iPad; CPU iPhone OS 7_0_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A4449d Safari/9537.53"']
        }
    }
    ]

"browser.getCapabilities ()" returns below



    { caps_: 
       { platform: 'MAC',
         acceptSslCerts: true,
         javascriptEnabled: true,
         browserName: 'chrome',
         chrome: { userDataDir: '/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/.org.chromium.Chromium.ten2tT' },
         rotatable: false,
         locationContextEnabled: true,
         mobileEmulationEnabled: false,
         'webdriver.remote.sessionid': '1a7542e9-8a70-469c-964d-3c3cd4330145',
         version: '40.0.2214.93',
         takesHeapSnapshot: true,
         cssSelectorsEnabled: true,
         databaseEnabled: false,
         handlesAlerts: true,
         browserConnectionEnabled: false,
         nativeEvents: true,
         webStorageEnabled: true,
         applicationCacheEnabled: false,
         takesScreenshot: true } }

Is there a way to get a name from an opportunity object?

+4
source share
2 answers

If several browsers are installed on the conf.js page, you should return the name of the browser in which the test is running:

browser.browserName

In the beforeEach function for the test, I added console.log(browser.browserName);and exported the correct browser name for each of the tests.

[launcher] Running 3 instances of WebDriver

------------------------------------
[safari #2] PID: 36412
[safari #2] Using the selenium server at http://localhost:4444/wd/hub
[safari #2] safari
[safari #2] 
[safari #2]   Test - pass
[safari #2] 
[safari #2] 
[safari #2] Finished in 1.469 seconds
[safari #2] 1 test, 0 assertions, 0 failures
[safari #2] 

[launcher] 2 instance(s) of WebDriver still running

------------------------------------
[firefox #3] PID: 36413
[firefox #3] Using the selenium server at http://localhost:4444/wd/hub
[firefox #3] firefox
[firefox #3] 
[firefox #3]   Test - pass
[firefox #3] 
[firefox #3] 
[firefox #3] Finished in 1.464 seconds
[firefox #3] 1 test, 0 assertions, 0 failures
[firefox #3] 

[launcher] 1 instance(s) of WebDriver still running

------------------------------------
[chrome #1] PID: 36411
[chrome #1] Using the selenium server at http://localhost:4444/wd/hub
[chrome #1] chrome
[chrome #1] 
[chrome #1]   Test - pass
[chrome #1] 
[chrome #1] 
[chrome #1] Finished in 2.173 seconds
[chrome #1] 1 test, 0 assertions, 0 failures
[chrome #1] 

[launcher] 0 instance(s) of WebDriver still running
[launcher] safari #2 passed
[launcher] firefox #3 passed
[launcher] chrome #1 passed

Process finished with exit code 0
0
source

onPrepare, :

browser.getCapabilities()
  .then( cap => browser.name = cap.caps_.browserName )

browserName multiCapabilities:

chrome: {
  browserName: 'chrome',
  logName: 'Chrome'
},
firefox: {
  browserName: 'firefox',
  logName: 'Firefox'
}

browser.name .

2017-01-07:

Protractor 4 caps_, getCapabilities().

0

All Articles