简体   繁体   中英

Get desired capabilities with Python

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM