使用Python获得所需的功能

使用Python获得所需的功能,python,selenium,automation,appium,python-appium,Python,Selenium,Automation,Appium,Python Appium,我不知道如何获得我用Appium Python客户端设置的所需功能 我特别需要知道的是设置了哪个平台,是iOS还是Android 我有一个像这样的Appium驱动程序 self.driver = webdriver.Remote(config['server_url'], config['device_config']) server_url = http://localhost:4723/wd/hub device_config = samsung_galaxy_nexus_6_0 's

我不知道如何获得我用Appium Python客户端设置的所需功能

我特别需要知道的是设置了哪个平台,是iOS还是Android

我有一个像这样的Appium驱动程序

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',
我需要这样的东西 self.driver.get_'platformName'


谢谢。

您可以使用Android环境或iOS环境

# 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)
资料来源:


如果这对你的需求没有帮助,那么只需在下面进行评论

您可以使用Android环境或iOS环境

# 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)
资料来源:


如果这对你的需求没有帮助,那么只需在下面进行评论

已设置的功能可以通过self.driver.desired_功能访问['capability_name_here']

例如:

self.driver.required_功能['platformName'] self.driver.required_功能['deviceName']


等。

可以使用self.driver访问已设置的功能。所需的功能['capability\u name\u here']

例如:

self.driver.required_功能['platformName'] self.driver.required_功能['deviceName']


等等。

谢谢Meghshyam,但这是用于设置功能的,我知道如何设置它们,我只需要返回功能的方法。类似于self.driver.get_功能'platformName',这样我就可以得到'iOS'或'Android'。新的错误,我用的是代替[],平台版本和其他CPA可以通过self.driver访问。所需的_功能['platformName']感谢Meghshyam,但这是用于设置功能的,我知道如何设置它们,我只需要返回函数的方法。类似于self.driver.get_功能的'platformName',这样我就可以得到'iOS'或'Android'。新的错误是,我使用的不是[],平台版本和其他CPA可以通过self.driver访问。所需的_功能['platformName']