简体   繁体   中英

DeprecationWarning: desired_capabilities has been deprecated, please pass in an Options object with options kwarg super().__init__(

import pytest
from appium import webdriver
class Test:

    def setup_class(self):
        print("setup from here")
        desired_caps = dict()
        desired_caps['platformName'] = 'ios'
        desired_caps['platformVersion'] = '12.1'
        desired_caps['deviceName'] = 'iPhone 8'
        desired_caps['app'] = 'com.masilotti.UI-Testing-Cheat-Sheet'
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

PycharmProjects/DemoTest/venv/lib/python3.8/site-packages/appium/webdriver/webdriver.py:274: DeprecationWarning: desired_capabilities has been deprecated, please pass in an Options object with options kwarg super(). init (

How to get rid of this warning, this warning appears whenever Unitest or Pytest are used.

Short answer:

You can't. (You could suppress it)

Long answer:

Selenium Webdriver now uses Options to pass capabilities, but the appium python-client which I'm assuming you are using does not yet support it. There is an issue open on the official repo here . And here is the implementation on the selenium side.

Here is the thread with the sollution: https://bytemeta.vip/repo/appium/python-client/issues/680

Add the following to the pytest.ini to supress the warning.

[pytest]
filterwarnings = 
    # Appium team is aware of deprecation warning - https://github.com/appium/python-client/issues/680
    ignore::DeprecationWarning

Or using python:

import warnings

with warnings.catch_warnings():
            warnings.filterwarnings("ignore", category=DeprecationWarning)
            self.driver = webdriver.Remote(hub_url, caps)

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