appiumappium-iospython-appiumdesiredcapabilities

TypeError: Unexpected keyword argument 'desired_capabilities' APPIUM


I'm new to Appium automation in Python, this is my first project actually. I don't use selenium in this project.

This is my code: `from appium import webdriver from os import path

CUR_DIR = path.dirname(path.abspath(__file__))
APP = path.join(CUR_DIR, 'TheApp.app.zip')
APPIUM = 'http://localhost:4723'

CAPS = {
    'platformName': 'iOS',
    'platformVersion': '17.4',
    'deviceName': 'iPhone 12 mini',
    'automationName': 'XCUITest',
    'app': APP,
}

driver = webdriver.Remote(
    command_executor=APPIUM,
    desired_capabilities=CAPS
)`

When I run the code I get TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'

I found out that DesiredCapabilities was removed and I should transform it into Options, but I don't find how to do it for Appium, only for Selenium.

What can I do?


Solution

  • You can use options like this:

    from appium.options.ios import XCUITestOptions
    
    CUR_DIR = path.dirname(path.abspath(__file__))
    APP = path.join(CUR_DIR, 'TheApp.app.zip')
    APPIUM = 'http://localhost:4723'
    
    CAPS = {
        'platformName': 'iOS',
        'platformVersion': '17.4',
        'deviceName': 'iPhone 12 mini',
        'automationName': 'XCUITest',
        'app': APP,
    }
    
    driver = webdriver.Remote(APPIUM, options=XCUITestOptions().load_capabilities(CAPS))