1

I don't know how to get desired capabilities I've set with Appium Python client.

What I need specifically to know is which platform is set, is it iOS or Android?

I have Appium driver like this.

self.driver = webdriver.Remote(config['server_url'], config['device_config'])

server_url = http://localhost:4723/wd/hub

device_config = samsung_galaxy_nexus_6_0

'samsung_galaxy_nexus_6_0': {
        'app': '/Users/majdukovic/Documents/no_root_ux.apk',
        'platformName': 'Android',
        'platformVersion': '6.0',
        'deviceName': 'Galaxy Nexus 6.0',
        'avd': 'Galaxy_Nexus_6.0',

I need something like this self.driver.get_capabilities('platformName')

Thanks.

niraj
  • 17,498
  • 4
  • 33
  • 48
Mate Ajdukovic
  • 340
  • 3
  • 17

2 Answers2

2

Already set capabilities can be accessed with self.driver.desired_capabilities['capabilty_name_here']

for example:

self.driver.desired_capabilities['platformName'] self.driver.desired_capabilities['deviceName']

etc.

Mate Ajdukovic
  • 340
  • 3
  • 17
1

You can either use Android environment or iOS environment

# Android environment
import unittest
from appium import webdriver

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.2'
desired_caps['deviceName'] = 'Android Emulator'
desired_caps['app'] = PATH('../../../apps/selendroid-test-app.apk')

self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)



# iOS environment
import unittest
from appium import webdriver

desired_caps = {}
desired_caps['platformName'] = 'iOS'
desired_caps['platformVersion'] = '7.1'
desired_caps['deviceName'] = 'iPhone Simulator'
desired_caps['app'] = PATH('../../apps/UICatalog.app.zip')

self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

Source: https://github.com/appium/python-client

If it doesn't help what you need then simply comment below.

Meghshyam Sonar
  • 394
  • 3
  • 12
  • thanks Meghshyam, but this is for setting capabilities, I know how to set them, I just need method which returns capabilities. Something like `self.driver.get_capabilities('platformName')` so with that I would get either 'iOS' or 'Android'. – Mate Ajdukovic Mar 14 '18 at 11:02
  • Newby mistake, I was using () instead of [], platform version and other cpas can be accessed with `self.driver.desired_capabilities['platformName']` – Mate Ajdukovic Mar 14 '18 at 11:39