运行pytest时出现空套件
class TestBase:
def setup_method(self): #前置处理器
# 调用连接模拟器
self.driver = Driver_Config().get_driver()
print("每个用例执行前执行一次")
def teardown_method(self): #后置处理器
print("每个测试执行之后都执行一次")
def test_01(self): #登录用例
# 向左滑动屏幕三次
self.driver.swipe(960, 960, 140, 960, 300)
self.driver.swipe(960, 960, 140, 960, 300)
self.driver.swipe(960, 960, 140, 960, 300)
# 轻敲即刻启程
TouchAction(self.driver).tap(x=570, y=1800).perform()
# 点击“允许”按钮两次
e1 = self.driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().text("允许")') # 文本取值text
e1.click()
e1.click()
# 点击“牛人”按钮
e2 = self.driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().text("牛人")')
e2.click()
# 点击“个人头像”
e3 = self.driver.find_element(AppiumBy.ID, 'com.jhss.youguu:id/head_pic')
e3.click()
# 点击“登录”按钮
e4 = self.driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().textContains("登")') # text模糊查找
e4.click()
# 点击“账号密码登录”
e5 = self.driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR,
'new UiSelector().textContains("账号密码")') # text模糊查找
e5.click()
# 输入“账号”
e6 = self.driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR,
'new UiSelector().textContains("请输入手机号")') # text模糊查找
e6.send_keys('19521272747')
# 输入“密码”
e7 = self.driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR,
'new UiSelector().textStartsWith("请输入")') # text以什么开始
e7.send_keys('543832.com')
# 点击“登录”按钮
e8 = self.driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().text("登录")')
e8.click()
if __name__ == '__main__':
pytest.main(['-s'])
文件命名方式是pytest的原则,pycharm执行方式更改为pytest