Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

How to get deviceName value from Multicapabilities definition at run time #4719

Closed
kat0072 opened this issue Feb 28, 2018 · 5 comments
Closed

Comments

@kat0072
Copy link

kat0072 commented Feb 28, 2018

Hi Team,

This might be repeated question for you guys but really I didn't answer yet.
Here is my multi-capabilities definition in protractor config file.
I want to access the deviceName parameter value. How can I do it?

exports.config = {
directConnect:true,
    multiCapabilities: [
        {
            browserName: 'chrome',
            'chromeOptions': {
                'mobileEmulation': {
                    'deviceName': 'iPad'
                }
            }
        }
],

Tried under onPrepare but not giving multi-capabilities values

browser.getCapabilities().then(function(c) {
            console.log(c.get('deviceName'));
        });
@IgorSasovets
Copy link
Contributor

IgorSasovets commented Feb 28, 2018

Hi, @kat0072 ! You can do it using browser.getProcessedConfig() function.

onPrepare: function() {
      return browser.getProcessedConfig().then(data => {
          console.log(data.capabilities.chromeOptions.mobileEmulation); //to print out all options
           console.log(data.capabilities.chromeOptions.mobileEmulation.deviceName); //to print out device name
      });
  }

@kat0072
Copy link
Author

kat0072 commented Mar 2, 2018

@IgorSasovets it worked. Can you please tell me that how I can access the value outside the function...
I tried assigning it to a global variable defined in the config but didnt worked and cannot access its value outside the function.

IgorSasovets added a commit to IgorSasovets/get-config-capabilities that referenced this issue Mar 2, 2018
get-config-capabilities
----------------------

This is simple example that explains how to get config capabilities variables inside test.
Please take a look at angular/protractor#4719 for description of issue.

Dependencies
--------------

In this example I used [protractor-firefox-support](https://github.com/IgorSasovets/protractor-firefox-support) lib that provides custom implementations of basic Actions class function which doesn't work in Firefox (v.52 and higher). Take a look at angular/protractor#4687.
@IgorSasovets
Copy link
Contributor

@kat0072, please take a look at get-config-capabilities for requested example.

@kat0072
Copy link
Author

kat0072 commented Mar 2, 2018

thanks, buddy got it.

@kat0072 kat0072 closed this as completed Mar 2, 2018
@Ashish-chamoli002
Copy link

Above mentioned works fine if my config is in .JS but if I create config file in TS format. it doesn't work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants