簡體   English   中英

DeprecationWarning:desired_capabilities 已被棄用,請使用 options kwarg super().__init__(

[英]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 已被棄用,請傳入帶有選項 kwarg super() 的 Options 對象。 初始化(

如何擺脫這個警告,每當使用 Unitest 或 Pytest 時都會出現這個警告。

簡短的回答:

你不能。 (你可以壓制它)

長答案:

Selenium Webdriver 現在使用 Options 來傳遞功能,但我假設您正在使用的appium python-client尚不支持它。 這里的官方回購有一個問題。 是硒方面的實現。

這是解決方案的線程: https ://bytemeta.vip/repo/appium/python-client/issues/680

將以下內容添加到 pytest.ini 以抑制警告。

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

或使用python:

import warnings

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM