1.问题描述
每次运行都有desired_capabilities has been deprecated && TouchAction’ action is deprecated的警告信息
2.脚本内容
class TestDW:
def setup(self):
desire_cap = {}
desire_cap["platformName"] = "Android"
desire_cap["deviceName"] = "29d2ed7e7d04"
desire_cap["appPackage"] = "com.xueqiu.android"
desire_cap["appActivity"] = ".view.WelcomeActivityAlias"
desire_cap["noReset"] = "true"
# desire_cap["dontStopAppOnReset"] = "true"
desire_cap["skipDeviceInitialization"] = "true"
desire_cap["platformVersion"] = "7.1.2"
self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desire_cap)
self.driver.implicitly_wait(5)
def teardown(self):
self.driver.quit()
def test_touch_action(self):
action = TouchAction(self.driver)
window_ret = self.driver.get_window_rect() # 获取屏幕的尺寸
width = window_ret['width']
height = window_ret['height']
x1 = int(width / 2)
y_start = int(height * (4/5)) # 向上滑动,起点为屏幕的4/5处
y_end = int(height * (1/5))
action.press(x=x1, y=y_start).wait(500).move_to(x=x1, y=y_end).release().perform()
3.详细日志
/Users/yangmeiqing/PycharmProjects/pythonProject/test_appium/venv/bin/python /Users/yangmeiqing/PycharmProjects/pythonProject/test_appium/test_dwpytest.py
============================= test session starts ==============================
platform darwin – Python 3.7.4, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 – /Users/yangmeiqing/PycharmProjects/pythonProject/test_appium/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/yangmeiqing/PycharmProjects/pythonProject/test_appium
collecting … collected 1 item
test_dwpytest.py::TestDW::test_touch_action [Deprecated] ‘TouchAction’ action is deprecated. Please use W3C actions instead.
PASSED
=============================== warnings summary ===============================
test_dwpytest.py::TestDW::test_touch_action
/Users/yangmeiqing/PycharmProjects/pythonProject/test_appium/venv/lib/python3.7/site-packages/appium/webdriver/webdriver.py:274: DeprecationWarning: desired_capabilities has been deprecated, please pass in an Options object with options kwarg
AppiumConnection(command_executor, keep_alive=keep_alive), desired_capabilities, browser_profile, proxy
– Docs: How to capture warnings — pytest documentation
======================== 1 passed, 1 warning in 10.17s =========================
Process finished with exit code 0