AttributeError:在 ios 自动化中连接到服务器时,“NoneType”对象没有属性“to_capability”问题

问题描述 投票:0回答:1

所需的功能和驱动程序实现:

@pytest.fixture
def driver(request):
    print(os.getcwd())
    global driver
    caps = {}
    caps = {
        'automationName': 'XCUITest',
        'platformName': 'iOS',
        'deviceName': 'iPhone 6S',
        'platformVersion': '16.6',
        'udid': '******',
        'autoAcceptAlerts': 'true',
        'noReset': False,
        'fullReset': False,
        'app': os.getcwd() + '/app/apkname.ipa'
    }
    appium_server_url = "http://localhost:4723/wd/hub"
    driver = webdriver.Remote(appium_server_url, caps)
    yield driver


控制台日志:

tests/step_defs/framework/driver.py:45: in driver
    driver = webdriver.Remote(appium_server_url, caps)
my_env/lib/python3.11/site-packages/appium/webdriver/webdriver.py:229: in __init__
    super().__init__(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <[AttributeError("'WebDriver' object has no attribute 'session_id'") raised in repr()] WebDriver object at 0x10cc97710>, command_executor = <appium.webdriver.appium_connection.AppiumConnection object at 0x10cc97650>, keep_alive = True
file_detector = None, options = None

    def __init__(
        self,
        command_executor="http://127.0.0.1:4444",
        keep_alive=True,
        file_detector=None,
        options: Union[BaseOptions, List[BaseOptions]] = None,
    ) -> None:
        """Create a new driver that will issue commands using the wire
        protocol.
    
        :Args:
         - command_executor - Either a string representing URL of the remote server or a custom
             remote_connection.RemoteConnection object. Defaults to 'http://127.0.0.1:4444/wd/hub'.
         - keep_alive - Whether to configure remote_connection.RemoteConnection to use
             HTTP keep-alive. Defaults to True.
         - file_detector - Pass custom file detector object during instantiation. If None,
             then default LocalFileDetector() will be used.
         - options - instance of a driver options.Options class
        """
    
        if isinstance(options, list):
            capabilities = create_matches(options)
            _ignore_local_proxy = False
        else:
>           capabilities = options.to_capabilities()
E           AttributeError: 'NoneType' object has no attribute 'to_capabilities'

my_env/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py:185: AttributeError
================================================================================================================ warnings summary =================================================================================================================
my_env/lib/python3.11/site-packages/selenium/webdriver/remote/remote_connection.py:27

期望脚本应该成功运行并且appium服务器GUI将显示执行日志

python ios webdriver pytest appium
1个回答
0
投票

例如,尝试通过

options

{
    "platformName": "iOS",
    "appium:options": {
        "automationName": "XCUITest",
        "platformVersion": "16.0",
        "app": "/path/to/your.app",
        "deviceName": "iPhone 12",
        "noReset": true
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.