DeprecationWarning: desired_capabilities has been deprecated, please pass in an ..报错处理

在执行pytest时候的时候遇到这个问题:很是烦人

============================== warnings summary ===============================
testcase/test_login.py::TestLogin::test_login
  D:\Python\lib\site-packages\appium\webdriver\webdriver.py:229: DeprecationWarning: desired_capabilities has been deprecated, please pass in an Options object with options kwarg
    super().__init__(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
- generated html file: file:///E:/joinkwang/Documents/appium_Ui/outputs/reports/report.html -
=================== 1 passed, 1 warning in 93.19s (0:01:33) ===================

运行的代码:

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(

通过查阅的资料表明:

Selenium Webdriver现在使用Options来传递功能,但我假设您正在使用的appium python客户端尚不支持它。

只能将以下内容添加到pytest.ini中以消除警告。
在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)

推荐第一种pytest.ini文件中新增内容。

如果觉得有用,点赞+收藏,谢谢

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值