huisajiaod 2023-03-24 14:35 采纳率: 100%
浏览 12
已结题

关于#pytest#的问题,如何解决?

运行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

  • 写回答

3条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2023-03-24 16:16
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 4月1日
  • 已采纳回答 3月24日
  • 创建了问题 3月24日

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改