From dcd330306ab9649e6692fecc65d55a3507b766e4 Mon Sep 17 00:00:00 2001
From: zhi1yuan <157468940+zhi1yuan@users.noreply.github.com>
Date: Fri, 9 May 2025 17:29:23 +0800
Subject: [PATCH 01/11] =?UTF-8?q?UI=E8=87=AA=E5=8A=A8=E5=8C=96=E6=A1=86?=
=?UTF-8?q?=E6=9E=B6=E5=88=9D=E7=89=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 52 ++++
.idea/.gitignore | 8 +
.idea/vcs.xml | 4 +
Base/__init__.py | 0
Base/app_assert_page.py | 20 ++
Base/base_page.py | 48 ++++
PageObjct/__init__.py | 0
PageObjct/element_page/IM_page.py | 35 +++
PageObjct/element_page/__init__.py | 0
PageObjct/element_page/club_page.py | 227 +++++++++++++++++
PageObjct/element_page/login_page.py | 100 ++++++++
PageObjct/operation_page/__init__.py | 0
PageObjct/operation_page/club_step.py | 337 ++++++++++++++++++++++++++
TestCase/__init__.py | 6 +
TestCase/club/__init__.py | 0
TestCase/club/test_creat_club.py | 227 +++++++++++++++++
TestCase/login/__init__.py | 0
TestCase/login/test_login.py | 56 +++++
common/__init__.py | 0
common/data_util.py | 12 +
common/wait_util.py | 14 ++
config/__init__.py | 0
config/config.yaml | 12 +
main.py | 16 ++
24 files changed, 1174 insertions(+)
create mode 100644 .gitignore
create mode 100644 .idea/.gitignore
create mode 100644 .idea/vcs.xml
create mode 100644 Base/__init__.py
create mode 100644 Base/app_assert_page.py
create mode 100644 Base/base_page.py
create mode 100644 PageObjct/__init__.py
create mode 100644 PageObjct/element_page/IM_page.py
create mode 100644 PageObjct/element_page/__init__.py
create mode 100644 PageObjct/element_page/club_page.py
create mode 100644 PageObjct/element_page/login_page.py
create mode 100644 PageObjct/operation_page/__init__.py
create mode 100644 PageObjct/operation_page/club_step.py
create mode 100644 TestCase/__init__.py
create mode 100644 TestCase/club/__init__.py
create mode 100644 TestCase/club/test_creat_club.py
create mode 100644 TestCase/login/__init__.py
create mode 100644 TestCase/login/test_login.py
create mode 100644 common/__init__.py
create mode 100644 common/data_util.py
create mode 100644 common/wait_util.py
create mode 100644 config/__init__.py
create mode 100644 config/config.yaml
create mode 100644 main.py
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..617156f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,52 @@
+# http://www.gnu.org/software/automake
+
+Makefile.in
+/ar-lib
+/mdate-sh
+/py-compile
+/test-driver
+/ylwrap
+.deps/
+.dirstamp
+
+# http://www.gnu.org/software/autoconf
+
+autom4te.cache
+/autoscan.log
+/autoscan-*.log
+/aclocal.m4
+/compile
+/config.cache
+/config.guess
+/config.h.in
+/config.log
+/config.status
+/config.sub
+/configure
+/configure.scan
+/depcomp
+/install-sh
+/missing
+/stamp-h1
+
+# https://www.gnu.org/software/libtool/
+
+/ltmain.sh
+
+# http://www.gnu.org/software/texinfo
+
+/texinfo.tex
+
+# http://www.gnu.org/software/m4/
+
+m4/libtool.m4
+m4/ltoptions.m4
+m4/ltsugar.m4
+m4/ltversion.m4
+m4/lt~obsolete.m4
+
+# Generated Makefile
+# (meta build system like autotools,
+# can automatically generate from config.status script
+# (which is called by configure script))
+Makefile
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..35410ca
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..d843f34
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/Base/__init__.py b/Base/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/Base/app_assert_page.py b/Base/app_assert_page.py
new file mode 100644
index 0000000..fedff02
--- /dev/null
+++ b/Base/app_assert_page.py
@@ -0,0 +1,20 @@
+from selenium.common import NoSuchElementException
+
+class AppAssertPage:
+
+ def __init__(self,driver):
+ self.driver = driver
+
+ def is_element_present(self, how, what):
+ '''
+ 判断元素是否存在
+ :param how: 定位方式
+ :param what: 定位元素的属性值
+ :return: True:代表元素存在, False:代表元素不存在
+ '''
+ try:
+ self.driver.find_element(how, what)
+ return True
+
+ except NoSuchElementException:
+ return False
\ No newline at end of file
diff --git a/Base/base_page.py b/Base/base_page.py
new file mode 100644
index 0000000..c97ad2a
--- /dev/null
+++ b/Base/base_page.py
@@ -0,0 +1,48 @@
+from appium import webdriver
+
+
+class BasePage:
+
+ def __init__(self, driver):
+ self.driver = driver
+
+ # 元素定位
+ def locator(self, locator):
+ return self.driver.find_element(*locator)
+
+ # 输入
+ def input(self, locator, text):
+ self.driver.find_element(*locator).send_keys(text)
+
+ # 点击
+ def click(self, locator):
+ self.driver.find_element(*locator).click()
+
+ # 滑动
+ def swipe(self, start_x, start_y, end_x, end_y, duration=0):
+ # 获取屏幕尺寸
+ window_size = self.driver.window_size()
+ x = window_size["width"]
+ y = window_size["height"]
+ touch_move = self.driver.swipe(start_x=x * start_x,
+ start_y=y * start_y,
+ end_x=x * end_x,
+ end_y=y * end_y,
+ duration=duration)
+ return touch_move
+
+ # 左滑
+ def left_slide(self):
+ self.driver.swipe(345, 298, 80, 298)
+
+ # 右滑
+ def right_slide(self):
+ self.driver.swipe(2, 404, 263, 404)
+
+ # 上滑
+ def up_slide(self):
+ self.driver.swipe(111, 641, 111, 209)
+
+ # 下拉
+ def down_slide(self):
+ self.driver.swipe(111, 209, 111, 641)
diff --git a/PageObjct/__init__.py b/PageObjct/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/PageObjct/element_page/IM_page.py b/PageObjct/element_page/IM_page.py
new file mode 100644
index 0000000..73b6842
--- /dev/null
+++ b/PageObjct/element_page/IM_page.py
@@ -0,0 +1,35 @@
+from appium.webdriver.common.mobileby import MobileBy
+
+from Base.base_page import BasePage
+
+
+class IMPage(BasePage):
+ # 消息输入框
+ el_input_IM = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeTextView')
+ # 发送消息按钮
+ el_send_message = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="chat send message light"]')
+ # +号更多按钮
+ el_IM_more = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="chat more light"]')
+ # 相册
+ el_photo_choose = (MobileBy.ACCESSIBILITY_ID, 'chat_more_album_light')
+ # 拍照
+ el_take_a_photo = (MobileBy.ACCESSIBILITY_ID, 'chat_more_camera_light')
+ # 语音通话
+ el_voice_communication = (MobileBy.ACCESSIBILITY_ID, 'chat_more_voice_light')
+ # 红包
+ el_red_packet = (MobileBy.ACCESSIBILITY_ID, 'chat_more_redpacket_light')
+ # 转账
+ el_transfer_accounts = (MobileBy.ACCESSIBILITY_ID, 'chat_more_transfer_light')
+ # 个人名片
+ el_personal_card = (MobileBy.ACCESSIBILITY_ID, 'chat_more_personal_card_light')
+ # 文件
+ el_document = (MobileBy.ACCESSIBILITY_ID, 'chat_more_document_light')
+ # 选择图片
+ el_picture_choose = (MobileBy.XPATH,'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[4]/XCUIElementTypeOther/XCUIElementTypeButton')
+ # 发送图片
+ el_send_picture = (MobileBy.ACCESSIBILITY_ID, '发送(1)')
+ # 选择视频
+ el_video_choice = (MobileBy.XPATH,'(//XCUIElementTypeImage[@name="/var/containers/Bundle/Application/7024A092-04C5-4391-8650-52A234FC16EB/Zapry.app/TZImagePickerController.bundle/photo_def_photoPickerVc@2x.png"])[2]')
+
+
diff --git a/PageObjct/element_page/__init__.py b/PageObjct/element_page/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/PageObjct/element_page/club_page.py b/PageObjct/element_page/club_page.py
new file mode 100644
index 0000000..33c7445
--- /dev/null
+++ b/PageObjct/element_page/club_page.py
@@ -0,0 +1,227 @@
+from appium.webdriver.common.mobileby import MobileBy
+from Base.base_page import BasePage
+
+
+class ClubPage(BasePage):
+ """元素定位"""
+
+ '''创建部落'''
+ el_icon = (MobileBy.ACCESSIBILITY_ID, "tribe_add_light")
+ # +号浮层中的创建普通部落
+ el_create = (MobileBy.ACCESSIBILITY_ID, "tribe_create_banner")
+ # +号浮层中的创建订阅部落
+ el_create_subscribe = (MobileBy.ACCESSIBILITY_ID, "tribe_create_subscribe_banner")
+ # 添加头像
+ el_photo = (MobileBy.XPATH,
+ "//XCUIElementTypeApplication[@name='Zapry']/XCUIElementTypeWindow/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]/XCUIElementTypeButton")
+ # 选择照片
+ el_choose = (MobileBy.XPATH,
+ "//XCUIElementTypeApplication[@name='Zapry']/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[8]/XCUIElementTypeOther/XCUIElementTypeImage")
+ # 完成
+ el_finish = (MobileBy.XPATH, '(//XCUIElementTypeStaticText[@name="完成"])[2]')
+ # 裁剪完成
+ el_tailor = (MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="完成"]')
+ # 名字输入框
+ el_name = (MobileBy.CLASS_NAME, 'XCUIElementTypeTextField')
+ # 创建普通部落的icon
+ el_create_club = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="创建部落"]')
+ # 创建订阅部落的下一步
+ el_create_next = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="下一步"]')
+
+ '''部落创建完成后的后续操作'''
+ # 跳过
+ el_skip = (MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="跳过"]')
+ # 邀请你的好友
+ el_invite = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther[2]/XCUIElementTypeOther[2]/XCUIElementTypeTable/XCUIElementTypeCell[2]')
+ # 去设置欢迎页
+ el_Wellcome = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther[2]/XCUIElementTypeOther[2]/XCUIElementTypeTable/XCUIElementTypeCell[3]')
+ # 查看部落管理
+ el_view_manage = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther[2]/XCUIElementTypeOther[2]/XCUIElementTypeTable/XCUIElementTypeCell[4]')
+ # 查看部落数据
+ el_view_data = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther[2]/XCUIElementTypeOther[2]/XCUIElementTypeTable/XCUIElementTypeCell[5]')
+ # 发布一则动态
+ el_active = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther[2]/XCUIElementTypeOther[2]/XCUIElementTypeTable/XCUIElementTypeCell[6]')
+ # 跳过这些步骤
+ el_skip_all = (MobileBy.ACCESSIBILITY_ID, '跳过这些步骤')
+
+ '''部落首页元素'''
+ # 侧边栏由上至下第一个部落
+ el_club1 = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[1]/XCUIElementTypeOther/XCUIElementTypeImage')
+ # 部落设置
+ el_setting = (MobileBy.ACCESSIBILITY_ID, 'tribe setting light')
+ # 分享二维码
+ el_share = (MobileBy.ACCESSIBILITY_ID, 'tribe share light')
+ # 部落内搜索聊天记录
+ el_search = (MobileBy.ACCESSIBILITY_ID, 'tribe search light')
+ # 部落社区
+ el_community = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]')
+ # 部落首页添加房间
+ el_add_room = (MobileBy.XPATH, '(//XCUIElementTypeButton[@name="tribe detail add light"])[4]')
+
+ '''分享部落二维码'''
+ # 分享到IM--邀请好友
+ el_invite_IM = (MobileBy.ACCESSIBILITY_ID, 'tribe_invite_circle_friend')
+
+ '''选择聊天页面'''
+ # #外层搜索输入框热区(热区:可点击热区)
+ el_search_out = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeTextField')
+ # 我的部落热区
+ el_my_club = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]')
+ # 我的联系人热区
+ el_my_contacts = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[2]')
+ # #我的群聊热区
+ el_my_group = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[3]')
+ # 联系人内搜索
+ el_contacts_search = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeTextField[2]')
+
+ '''分享到部落'''
+ # 左侧往下第二个部落
+ el_second_club = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeCollectionView/XCUIElementTypeCell[2]/XCUIElementTypeOther/XCUIElementTypeImage')
+ # 选择‘日常聊天’房间
+ el_choose_chart_room = (MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="日常聊天"]')
+ # 选择“聊天房间”
+ el_choose_ChartRoom1 = (MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="聊天房间"]')
+ # 选择“应用房间”房间
+ el_choose_DappRoom = (MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="应用房间"]')
+ # 点击‘完成’
+ el_share_club_done = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="完成(1)"]')
+
+ '''分享-搜索联系人'''
+ # 搜索出来的item的名字
+ el_first_name = (MobileBy.XPATH, '(//XCUIElementTypeStaticText[@name="204!"])[2]')
+ # #我的联系人第一个item
+ # el_first_item = (MobileBy.XPATH,'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]')
+ # 确认
+ el_confirm = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="确认(1/9)"]')
+ # 聚合页点击完成
+ el_share_done = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="完成(1/9)"]')
+
+ '''分享到群聊'''
+ # 群聊搜索输入框
+ el_group_search = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeTextField[2]')
+ # 选择第一个群聊
+ el_choose_group_chart = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable[2]/XCUIElementTypeCell[1]')
+ # 点击确认
+ el_group_confirm = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="确认(1/9)"]')
+
+ # 分享弹窗选择发送
+ el_share_send = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="发送"]')
+
+ '''发部落动态'''
+ # 写动态按钮
+ el_send_community = (MobileBy.ACCESSIBILITY_ID, 'tribe send community', 'discover post icon')
+ # 标题
+ el_head_title = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]/XCUIElementTypeTextView')
+ # 正文
+ el_body_text = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[2]/XCUIElementTypeTextView')
+ # 发布按钮
+ el_release = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="发布"]')
+
+ '''创建房间'''
+ # 创建普通房间
+ el_chart_room = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[1]/XCUIElementTypeOther')
+ # 房间名输入框
+ el_chart_name = (MobileBy.CLASS_NAME, 'XCUIElementTypeTextField')
+ # 立即创建
+ el_create_button = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="立即创建"]')
+ # 创建DAPP房间
+ el_dapp_room = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[2]/XCUIElementTypeOther')
+ # DAPP房间名输入框
+ el_dapp_name = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeTextField')
+ # 应用链接输入框
+ el_dapp_link = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeTextField')
+ # 应用介绍输入框
+ el_dapp_text = (MobileBy.CLASS_NAME, 'XCUIElementTypeTextView')
+ # 创建完成
+ el_dapp_done = (MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="完成"]')
+ # 进入聊天频道
+ el_into_channel = (MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="日常聊天"]')
+
+ '''聊天房间信息页'''
+ # 进入房间信息
+ el_chart_room_information = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="chat setting light"]')
+ # 返回
+ el_back = (MobileBy.ACCESSIBILITY_ID, '返回')
+ # 全员禁言
+ el_all_Shutup = (MobileBy.CLASS_NAME, 'XCUIElementTypeSwitch')
+ # 消息免打扰
+ el_message_disturb = (MobileBy.ACCESSIBILITY_ID, '消息免打扰')
+ # 清空聊天消息
+ el_clear_message = (MobileBy.ACCESSIBILITY_ID, '清空聊天记录')
+ # 删除房间
+ el_delete_room = (MobileBy.ACCESSIBILITY_ID, '删除房间')
+
+ '''发布房间公告'''
+ # 设置房间公告
+ el_announce = (MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="房间公告"]')
+ # 编辑公告
+ el_announce_content = (MobileBy.CLASS_NAME, 'XCUIElementTypeTextView')
+ # 发布
+ el_announcement = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="发布"]')
+
+ '''设置免打扰'''
+ # 不允许通知
+ el_no_disturb = (MobileBy.CLASS_NAME, '不允许通知')
+
+ '''清空聊天记录'''
+ # 清空弹窗,二次确认
+ el_clear_popup = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="清空"]')
+
+ '''删除房间'''
+ # 删除弹窗,二次确认
+ el_delete_popup = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="删除"]')
+ '''应用房间相关'''
+ # 未绑定钱包点击应用房间的弹窗
+ el_popup_BindWallet = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="立即添加"]')
+ el_PayPwd = (MobileBy.XPATH,'//XCUIElementTypeKey[@name="1"]')
+ # 应用房间跳转提示
+ el_popup_jumping = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="确定"]')
+ # 应用房间聊天气泡
+ el_DappRoom_chart =(MobileBy.XPATH,'//XCUIElementTypeImage[@name="dapp_chat2"]')
+ # 应用房间功能浮层
+ el_DappRoom_util = (MobileBy.ACCESSIBILITY_ID,'dappMoreIcon')
+ # dapp窗口化
+ el_DappRoom_windowed = (MobileBy.ACCESSIBILITY_ID,'dappWindowedIcon')
+ # 关闭dapp
+ el_DappRoom_close = (MobileBy.ACCESSIBILITY_ID,'dappCloseIcon')
+ # dapp窗口放大
+ el_DappWindowed_BlowUp = (MobileBy.ACCESSIBILITY_ID,'windowedFullSize')
+ # dapp窗口关闭
+ el_DappWindowed_Close = (MobileBy.ACCESSIBILITY_ID,'windowedClosed')
+ # 聊天
+ el_dapp_chart2 = (MobileBy.ACCESSIBILITY_ID,'dapp chat')
+ # 分享dapp
+ el_dapp_share = (MobileBy.ACCESSIBILITY_ID,'dapp chat')
+
+
+
+
+ '''创建钱包'''
+ # 创建新钱包
+ el_create_NewWallet = (MobileBy.XPATH, '//XCUIElementTypeOther[@name="创建新钱包"]')
+ # 二次确认
+ el_popup_NewWallet = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="创建新钱包"]')
+ # 跳过生物识别
+ el_recognition_skip = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="跳过"]')
+ # 设置密码为“111111”
\ No newline at end of file
diff --git a/PageObjct/element_page/login_page.py b/PageObjct/element_page/login_page.py
new file mode 100644
index 0000000..aa1884b
--- /dev/null
+++ b/PageObjct/element_page/login_page.py
@@ -0,0 +1,100 @@
+from time import sleep
+from tkinter.font import names
+
+from appium.webdriver.common.mobileby import MobileBy
+from Base.base_page import BasePage
+
+
+class LoginPage(BasePage):
+
+ #账号tab
+ el_account = (MobileBy.ACCESSIBILITY_ID,"账号")
+ #账户输入框
+ el_username = (MobileBy.CLASS_NAME,'XCUIElementTypeTextField')
+ #密码输入框
+ el_password = (MobileBy.XPATH,'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther')
+ #登录按钮
+ el_login = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="登录测试环境"]')
+ #下一步
+ el_nex = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="下一步"]')
+ #一键注册按钮
+ el_single = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="一键注册"]')
+ #新注册用户页面的跳过
+ el_skip2 = (MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="跳过"]')
+ #全选部落
+ el_all = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="全选"]')
+ #进入部落按钮
+ el_join = (MobileBy.ACCESSIBILITY_ID,'进入部落')
+ #我知道了
+ el_know = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="我知道了"]')
+ # 设置头像
+ el_heads = (MobileBy.XPATH,'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[1]')
+ # 选择图片
+ el_photo = (MobileBy.XPATH,'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[8]/XCUIElementTypeOther/XCUIElementTypeImage')
+ # 完成
+ el_done1 = (MobileBy.XPATH,'(//XCUIElementTypeStaticText[@name="完成"])[2]')
+ #裁剪完成
+ el_tailor = (MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="完成"]')
+ #输入名字
+ el_pname = (MobileBy.CLASS_NAME,'XCUIElementTypeTextField')
+ #点击完成
+ el_done = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="完成"]')
+
+
+ #登录步骤
+ def login1(self,username,password):
+ #切换到账户登录
+ self.click(self.el_account)
+ #输入账号
+ self.input(self.el_username,username)
+ #点击登录测试环境(下一步)
+ self.click(self.el_login)
+ #输入密码
+ self.input(self.el_password,password)
+ #点击登录
+ self.click(self.el_login)
+ sleep(2)
+
+ #一键注册
+ def single(self):
+ #点击一键注册
+ self.click(self.el_single)
+ # 点击跳过
+ self.click(self.el_skip2)
+ # 点击我知道了
+ self.click(self.el_know)
+
+
+ #注册步骤
+ def login2(self,username,password,name):
+ # 切换到账户登录
+ self.click(self.el_account)
+ # 输入账号
+ self.input(self.el_username, username)
+ # 点击登录测试环境(下一步)
+ self.click(self.el_login)
+ # 输入密码
+ self.input(self.el_password, password)
+ # 点击登录
+ self.click(self.el_nex)
+ #输入用户名
+ self.input(self.el_pname,name)
+ # 点击设置头像
+ self.click(self.el_heads)
+ # 选择照片
+ self.click(self.el_photo)
+ # 点击完成
+ self.click(self.el_done1)
+ # 太快了找不到元素
+ sleep(1)
+ # 裁剪完成
+ self.click(self.el_tailor)
+ #点击完成
+ self.click(self.el_done)
+ # 点击全选部落按钮
+ self.click(self.el_all)
+ # 点击进入部落
+ self.click(self.el_join)
+ sleep(1)
+ # 点击我知道了
+ self.click(self.el_know)
\ No newline at end of file
diff --git a/PageObjct/operation_page/__init__.py b/PageObjct/operation_page/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/PageObjct/operation_page/club_step.py b/PageObjct/operation_page/club_step.py
new file mode 100644
index 0000000..421c095
--- /dev/null
+++ b/PageObjct/operation_page/club_step.py
@@ -0,0 +1,337 @@
+from logging import exception
+from time import sleep
+
+from PageObjct.element_page.IM_page import IMPage
+from PageObjct.element_page.club_page import ClubPage
+from common.wait_util import WaitPage
+from web import driver
+
+
+class ClubStep(ClubPage, IMPage):
+
+
+ def create_club(self, name):
+ """创建部落"""
+ # 点击icon
+ self.click(self.el_icon)
+ # 点击卡片
+ self.click(self.el_create)
+ # 部落头像
+ self.click(self.el_photo)
+ # 选择照片
+ self.click(self.el_choose)
+ # 点击完成
+ self.click(self.el_finish)
+ # 太快了找不到元素
+ sleep(1)
+ # 裁剪完成
+ self.click(self.el_tailor)
+ # 输入部落名
+ self.input(self.el_name, name)
+ # 点击创建部落
+ self.click(self.el_create_club)
+
+ '''分享部落到频道'''
+
+ def share_club_to_club(self):
+ # 点击侧边栏第一个部落
+ self.click(self.el_club1)
+ # 点击分享
+ self.click(self.el_share)
+ # 点击邀请好友
+ self.click(self.el_invite_IM)
+ # 选择部落
+ self.click(self.el_my_club)
+ # 选择第二个部落
+ self.click(self.el_second_club)
+ sleep(1)
+ # 选择聊天房间
+ self.click(self.el_choose_chart_room)
+ sleep(1)
+ # 点击完成
+ self.click(self.el_share_club_done)
+ sleep(1)
+ # 分享弹窗点击发送
+ self.click(self.el_share_send)
+
+ """分享部落到单聊"""
+
+ def share_club_to_contact(self, contact_name):
+ # 点击侧边栏第一个部落
+ self.click(self.el_club1)
+ # 点击分享
+ self.click(self.el_share)
+ # 点击邀请好友
+ self.click(self.el_invite_IM)
+ # 点击我的联系人item
+ self.click(self.el_my_contacts)
+ # 我的联系人内部搜索输入框中输入
+ self.input(self.el_contacts_search, contact_name)
+ sleep(1)
+ # 点击搜索结果中的第一个联系人的名字
+ self.click(self.el_first_name)
+ sleep(1)
+ # 点击确认
+ self.click(self.el_confirm)
+ sleep(1)
+ # 外部聚合页点击完成
+ self.click(self.el_share_done)
+ # 分享弹窗点击发送
+ self.click(self.el_share_send)
+
+ '''分享部落到群聊'''
+
+ def share_club_to_group_chat(self, group_name):
+ # 点击侧边栏第一个部落
+ self.click(self.el_club1)
+ # 点击分享
+ self.click(self.el_share)
+ # 点击邀请好友
+ self.click(self.el_invite_IM)
+ sleep(1)
+ # 选择群聊
+ self.click(self.el_my_group)
+ # 搜索群名
+ self.input(self.el_group_search, group_name)
+ sleep(1)
+ # 选择第一个群聊
+ self.click(self.el_choose_group_chart)
+ sleep(1)
+ # 点击确认
+ self.click(self.el_group_confirm)
+ sleep(1)
+ # 分享弹窗点击发送
+ self.click(self.el_share_send)
+
+ '''发一条部落动态'''
+
+ def send_community(self, title, text):
+ # 点击进入部落社区
+ self.click(self.el_community)
+ # 点击写动态按钮
+ self.click(self.el_send_community)
+ # 输入标题
+ self.input(self.el_head_title, title)
+ # 输入正文
+ self.input(self.el_body_text, text)
+ # 点击发布
+ self.click(self.el_release)
+
+ '''添加聊天房间'''
+
+ def add_chat_room(self, chart_room):
+ # 点击 部落管理 后面的 + 号
+ self.click(self.el_add_room)
+ # 选择聊天房间
+ self.click(self.el_chart_room)
+ # 输入房间名
+ self.input(self.el_chart_name, chart_room)
+ # 创建房间
+ self.click(self.el_create_button)
+
+ '''添加DAPP房间'''
+
+ def add_dapp_room(self, dapp_room, dapp_link, dapp_text):
+ # 点击 部落管理 后面的 + 号
+ self.click(self.el_add_room)
+ # 选择应用房间
+ self.click(self.el_dapp_room)
+ # 输入应用房间名
+ self.input(self.el_dapp_name, dapp_room)
+ # 输入链接
+ self.input(self.el_dapp_link, dapp_link)
+ # 输入介绍
+ self.input(self.el_dapp_text, dapp_text)
+ # 创建应用房间
+ self.click(self.el_dapp_done)
+ # self.swipe(123,123,432,422)
+
+ '''频道发消息'''
+
+ def send_message_to_channel(self, text):
+ # 选择侧边栏第一个部落
+ self.click(self.el_club1)
+ # 网卡的时候加载慢,使用显式等待
+ driver.implicitly_wait(10)
+ # 选择”聊天房间“房间
+ self.click(self.el_choose_ChartRoom1)
+ # 输入框内输入消息
+ self.input(self.el_input_IM, text)
+ # 发送消息
+ self.click(self.el_send_message)
+
+ '''频道发图片'''
+
+ def send_picture_to_channel(self):
+ # 选择侧边栏第一个部落
+ self.click(self.el_club1)
+ # 选择”聊天房间“房间
+ self.click(self.el_choose_ChartRoom1)
+ # 点开更多面板
+ self.click(self.el_IM_more)
+ # 进入相册
+ self.click(self.el_photo_choose)
+ # 上滑两次确保到了相册顶部
+ self.down_slide()
+ self.down_slide()
+ driver.implicitly_wait(10)
+ # 选择第4张图片
+ self.click(self.el_picture_choose)
+ # 点击发送
+ self.click(self.el_send_picture)
+
+ '''频道发视频'''
+
+ def send_video_to_channel(self):
+ # 选择侧边栏第一个部落
+ self.click(self.el_club1)
+ # 选择”聊天房间“房间
+ self.click(self.el_choose_ChartRoom1)
+ # 点开更多面板
+ self.click(self.el_IM_more)
+ # 进入相册
+ self.click(self.el_photo_choose)
+ # 上滑两次确保到了相册顶部
+ self.down_slide()
+ self.down_slide()
+ driver.implicitly_wait(10)
+ # 选择第2个视频
+ self.click(self.el_video_choice)
+ # 点击发送
+ self.click(self.el_send_picture)
+
+ '''发布房间公告'''
+
+ def chart_room_announce(self, text):
+ # 选择侧边栏第一个部落
+ self.click(self.el_club1)
+ # 选择“聊天房间”房间
+ self.click(self.el_choose_ChartRoom1)
+ # 进入房间信息
+ self.click(self.el_chart_room_information)
+ # 打开房间公告
+ self.click(self.el_announce)
+ # 输入内容
+ self.input(self.el_announce_content, text)
+ # 发布公告
+ self.click(self.el_announcement)
+ # 返回房间
+ self.click(self.el_back)
+
+ '''开启全员禁言'''
+
+ def all_shutup(self):
+ # 选择侧边栏第一个部落
+ self.click(self.el_club1)
+ # 选择“日常聊天”房间
+ self.click(self.el_choose_ChartRoom1)
+ # 进入房间信息
+ self.click(self.el_chart_room_information)
+ # 开启全员禁言
+ self.click(self.el_all_Shutup)
+ # 返回房间
+ self.click(self.el_back)
+
+ '''设置免打扰'''
+
+ def message_disturb(self):
+ # 选择侧边栏第一个部落
+ self.click(self.el_club1)
+ # 选择“聊天房间”房间
+ self.click(self.el_choose_ChartRoom1)
+ # 进入房间信息
+ self.click(self.el_choose_ChartRoom1)
+ # 点击免打扰唤起浮层
+ self.click(self.el_all_Shutup)
+ # 选择“不允许通知”
+ self.click(self.el_no_disturb)
+ # 返回房间
+ self.click(self.el_back)
+
+ '''清空聊天记录'''
+
+ def clear_message(self):
+ # 选择侧边栏第一个部落
+ self.click(self.el_club1)
+ # 选择“聊天房间”房间
+ self.click(self.el_choose_ChartRoom1)
+ # 进入房间信息
+ self.click(self.el_chart_room_information)
+ # 点击清空聊天记录
+ self.click(self.el_clear_message)
+ # 二次确认
+ self.click(self.el_clear_popup)
+ # 返回
+ self.click(self.el_back)
+
+ '''删除房间'''
+
+ def delete_room(self):
+ # 选择侧边栏第一个部落
+ self.click(self.el_club1)
+ # 选择“聊天房间”房间
+ self.click(self.el_choose_ChartRoom1)
+ # 进入房间信息
+ self.click(self.el_chart_room_information)
+ # 删除房间
+ self.click(self.el_delete_room)
+ # 二次确认
+ self.click(self.el_delete_popup)
+
+ '''通过应用房间提示绑定钱包'''
+ def bing_wallet(self):
+ # 选择第一个部落
+ self.click(self.el_club1)
+ # 点击应用房间
+ self.click(self.el_choose_DappRoom)
+ # 跳转到绑定钱包页面
+ self.click(self.el_popup_BindWallet)
+ # 创建新钱包
+ self.click(self.el_create_NewWallet)
+ # 二次确认
+ self.click(self.el_popup_NewWallet)
+ # 跳过生物识别
+ self.click(self.el_recognition_skip)
+ # 输入密码并二次确认密码
+ for i in range(12):
+ self.click(self.el_PayPwd)
+ '''最小化dapp'''
+ def dapp_windowed(self):
+ # 进入第一个部落
+ self.click(self.el_club1)
+ # 选择dapp房间
+ self.click(self.el_choose_DappRoom)
+ # 弹窗点击确定
+ try:
+ self.click(self.el_popup_jumping)
+ except Exception as e:
+ print(f'没有出现弹窗或其他原因:{e}')
+ # 点击窗口化
+ self.click(self.el_DappRoom_windowed)
+
+ '''关闭dapp'''
+ def dapp_close1(self):
+ # 进入第一个部落
+ self.click(self.el_club1)
+ # 选择dapp房间
+ self.click(self.el_choose_DappRoom)
+ # 弹窗点击确定
+ try:
+ self.click(self.el_popup_jumping)
+ except Exception as e:
+ print(f'没有出现弹窗或其他原因:{e}')
+ self.click(self.el_DappRoom_close)
+
+ '''最小化后再打开全屏'''
+ def dapp_blow_up(self):
+ # 先最小化
+ self.dapp_windowed()
+ # 放大到全屏
+ self.click(self.el_DappWindowed_BlowUp)
+
+ '''关闭dapp小窗'''
+ def dapp_close2(self):
+ # 先最小化
+ self.dapp_windowed()
+ # 关闭dapp窗口
+ self.click(self.el_DappWindowed_Close)
diff --git a/TestCase/__init__.py b/TestCase/__init__.py
new file mode 100644
index 0000000..d837360
--- /dev/null
+++ b/TestCase/__init__.py
@@ -0,0 +1,6 @@
+import pytest
+
+
+
+if __name__ == '__main__':
+ pytest.main()
\ No newline at end of file
diff --git a/TestCase/club/__init__.py b/TestCase/club/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/TestCase/club/test_creat_club.py b/TestCase/club/test_creat_club.py
new file mode 100644
index 0000000..366d5c6
--- /dev/null
+++ b/TestCase/club/test_creat_club.py
@@ -0,0 +1,227 @@
+import os
+import re
+from time import sleep
+
+import pytest
+from appium import webdriver
+from appium.webdriver.common.mobileby import MobileBy
+
+from Base.app_assert_page import AppAssertPage
+from PageObjct.operation_page.club_step import ClubStep
+from common.data_util import readYaml
+
+
+class TestCreateClub:
+
+ # def test_start_server(self):
+ def tset_up(self):
+ # 回到根目录
+ rootpath = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
+ # yaml文件的绝对路径
+ path = os.path.join(rootpath, 'config/config.yaml')
+ # 拿到数据
+ data = readYaml(path)
+ # 连接Appium Server,初始化自动化环境
+ self.driver = webdriver.Remote('http://localhost:4723/wd/hub', data['ios_caps'])
+
+ def teardown(self):
+ self.driver.quit()
+
+ # 创建部落
+ def test_create_club(self):
+ self.tset_up()
+ """创建部落"""
+ club_step = ClubStep(self.driver)
+ club_step.create_club('部落')
+ # 创建过程太慢,需要多等一会
+ sleep(6)
+ # 断言
+ ass = AppAssertPage(driver=self.driver)
+ # 检查页面有没有“跳过”元素
+ assert ass.is_element_present(MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="跳过"]') == True
+ self.teardown()
+
+ def test_share_club_to_club(self):
+ self.tset_up()
+ """分享部落到房间"""
+ club_step = ClubStep(self.driver)
+ club_step.share_club_to_club()
+ sleep(1)
+ ass = AppAssertPage(driver=self.driver)
+ # 检查页面有没有“部落邀请”元素
+ assert ass.is_element_present(MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="部落邀请"]') == True
+ self.teardown()
+
+ def test_share_club_to_contact(self):
+ self.tset_up()
+ """分享部落到单聊"""
+ club_step = ClubStep(self.driver)
+ club_step.share_club_to_contact('204')
+ sleep(1)
+ ass = AppAssertPage(driver=self.driver)
+ # 检查页面有没有“部落邀请”元素
+ assert ass.is_element_present(MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="部落邀请"]') == True
+ self.teardown()
+
+ def test_share_club_to_group_chart(self):
+ self.tset_up()
+ """分享部落群聊"""
+ club_step = ClubStep(self.driver)
+ club_step.share_club_to_group_chat('2')
+ sleep(1)
+ ass = AppAssertPage(driver=self.driver)
+ # 检查页面有没有“部落邀请”元素
+ assert ass.is_element_present(MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="部落邀请"]') == True
+ self.teardown()
+
+ def test_send_community(self):
+ self.tset_up()
+ """发部落动态"""
+ club_step = ClubStep(self.driver)
+ club_step.send_community('这是动态标题', '这是动态内容')
+ sleep(2)
+ # 检查页面有没有“动态详情”元素
+ ass = AppAssertPage(driver=self.driver)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, '动态详情') == True
+ self.teardown()
+
+ def test_add_chart_room(self):
+ self.tset_up()
+ """添加聊天房间"""
+ club_step = ClubStep(self.driver)
+ club_step.add_chat_room('聊天房间')
+ sleep(2)
+ ass = AppAssertPage(driver=self.driver)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, '聊天房间') == True
+ self.teardown()
+
+ def test_add_dapp_room(self):
+ self.tset_up()
+ """添加应用房间"""
+ club_step = ClubStep(self.driver)
+ club_step.add_dapp_room('应用房间',
+ 'https://www.baidu.com/s?wd=%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95&rsv_spt=1&rsv_iqid=0x9058a494003119fd&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_dl=tb&rsv_enter=1&rsv_sug3=38&rsv_sug1=36&rsv_sug7=100&rsv_sug2=0&rsv_btype=i&prefixsug=%25E8%2587%25AA%25E5%258A%25A8%25E5%258C%2596%25E6%25B5%258B%25E8%25AF%2595&rsp=5&inputT=12351&rsv_sug4=15729',
+ '应用房间介绍,这就是百度了一个“自动化测试”的百度网站')
+ sleep(2)
+ ass = AppAssertPage(driver=self.driver)
+ try:
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, '应用房间') == True, "没有找到这个元素,测试失败!"
+ except AssertionError as e:
+ print(e)
+ self.teardown()
+
+ def test_send_message_to_channel(self):
+ self.tset_up()
+ """频道发消息"""
+ club_step = ClubStep(self.driver)
+ club_step.send_message_to_channel('123456')
+
+ ass = AppAssertPage(driver=self.driver)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, '123456') == True
+ self.teardown()
+
+ def test_send_picture_to_channel(self):
+ self.tset_up()
+ '''在频道发图片'''
+ club_step = ClubStep(self.driver)
+ club_step.send_picture_to_channel()
+ # 多等一会让图片发送成功
+ sleep(2)
+ ass = AppAssertPage(driver=self.driver)
+ # 被检查的元素
+ el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ self.teardown()
+
+ def test_send_video_to_channel(self):
+ self.tset_up()
+ '''在频道发视频'''
+ club_step = ClubStep(self.driver)
+ club_step.send_video_to_channel()
+ sleep(2)
+ ass = AppAssertPage(driver=self.driver)
+ # 被检查的元素
+ el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ self.teardown()
+
+ def test_chart_room_announce(self):
+ self.tset_up()
+ '''聊天房间发布公告'''
+ club_step = ClubStep(self.driver)
+ club_step.chart_room_announce('欢迎来到聊天房间')
+ sleep(2)
+ ass = AppAssertPage(driver=self.driver)
+ el_ass = '(//XCUIElementTypeStaticText[@name="公告"])[8]'
+ assert ass.is_element_present(MobileBy.XPATH, el_ass) == True
+ self.teardown()
+
+ def test_all_shutup1(self):
+ self.tset_up()
+ '''房间禁言'''
+ club_step = ClubStep(self.driver)
+ club_step.all_shutup()
+ ass = AppAssertPage(driver=self.driver)
+ el_ass = '203 已开启“全员禁言” '
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ self.teardown()
+
+ def test_all_shutup2(self):
+ self.tset_up()
+ '''房间禁言'''
+ club_step = ClubStep(self.driver)
+ club_step.all_shutup()
+ ass = AppAssertPage(driver=self.driver)
+ el_ass = '203 已关闭“全员禁言” '
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ self.teardown()
+
+ def test_message_disturb(self):
+ self.tset_up()
+ '''消息免打扰'''
+ club_step = ClubStep(self.driver)
+ club_step.message_disturb()
+ ass = AppAssertPage(driver=self.driver)
+ el_ass = 'chat_disturb_light'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ self.teardown()
+
+ def test_clear_message(self):
+ self.tset_up()
+ '''清空聊天记录'''
+ club_step = ClubStep(self.driver)
+ club_step.clear_message()
+ ass = AppAssertPage(driver=self.driver)
+ el_ass = '//XCUIElementTypeStaticText[@name="部落主"]'
+ assert ass.is_element_present(MobileBy.XPATH, el_ass) == False
+ self.teardown()
+
+ def test_delete_room(self):
+ self.tset_up()
+ '''删除房间'''
+ club_step = ClubStep(self.driver)
+ club_step.delete_room()
+ sleep(2)
+ ass = AppAssertPage(driver=self.driver)
+ el_ass = '//XCUIElementTypeStaticText[@name="聊天房间"]'
+ assert ass.is_element_present(MobileBy.XPATH, el_ass) == False
+ self.teardown()
+
+ def test_bing_wallet(self):
+ self.tset_up()
+ '''根据应用房间提示去绑定钱包'''
+ club_step = ClubStep(self.driver)
+ club_step.bing_wallet()
+ # 创建钱包后加载较慢
+ sleep(4)
+ ass = AppAssertPage(driver=self.driver)
+ el_ass = '交易历史'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == False
+ self.teardown()
+
+
+窗口化el_ass ='//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther[1]'
+
+
+if __name__ == '__main__':
+ pytest.main()
diff --git a/TestCase/login/__init__.py b/TestCase/login/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/TestCase/login/test_login.py b/TestCase/login/test_login.py
new file mode 100644
index 0000000..da3aca6
--- /dev/null
+++ b/TestCase/login/test_login.py
@@ -0,0 +1,56 @@
+import os
+import secrets
+from time import sleep
+
+from appium import webdriver
+from appium.webdriver.common.mobileby import MobileBy
+
+from Base.app_assert_page import AppAssertPage
+from PageObjct.element_page.login_page import LoginPage
+from common.data_util import readYaml
+
+
+class TestLogin:
+
+ def setup(self):
+ # 回到根目录
+ rootpath = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
+ # yaml文件的绝对路径
+ path = os.path.join(rootpath, 'config/config.yaml')
+ # 拿到数据
+ data = readYaml(path)
+ # 连接Appium Server,初始化自动化环境
+ self.driver = webdriver.Remote('http://localhost:4723/wd/hub', data['ios_caps'])
+
+ def teardown(self):
+ self.driver.quit()
+
+ # @pytest.mark.parametrize('username,password', readYaml('../config/config.yaml'))
+ def test_login1(self):
+ login_page = LoginPage(driver=self.driver)
+ '''账号登录'''
+ login_page.login1('new203', 'Sta12345')
+ sleep(1)
+ ass = AppAssertPage(driver=self.driver)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, 'tribe_add_light') == True
+
+ def test_login2(self):
+ login_page = LoginPage(driver=self.driver)
+ '''新用户注册'''
+ # 生成一个随机的令牌,例如用于安全令牌或密码
+ token = secrets.token_hex(2) # 生成一个2字节的十六进制字符串,4位
+ data = 'new'
+ ddname = data + token
+ login_page.login2(ddname, 'Sta12345', '新注册用户')
+ sleep(1)
+ # 断言
+ ass = AppAssertPage(driver=self.driver)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, '参与共建热门部落') == True
+
+ def test_single(self):
+ login_page = LoginPage(driver=self.driver)
+ '''一键注册'''
+ login_page.single()
+ sleep(1)
+ ass = AppAssertPage(driver=self.driver)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, '参与共建热门部落') == True
diff --git a/common/__init__.py b/common/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/common/data_util.py b/common/data_util.py
new file mode 100644
index 0000000..7b2d999
--- /dev/null
+++ b/common/data_util.py
@@ -0,0 +1,12 @@
+import os
+
+import yaml
+
+def readYaml(path):
+ with open(path,'r+',encoding="utf-8") as file:
+ #绝对路径
+ data = yaml.load(stream=file,Loader=yaml.FullLoader)
+ #相对路径
+ # data = yaml.safe_load(file)
+ return data
+
diff --git a/common/wait_util.py b/common/wait_util.py
new file mode 100644
index 0000000..67ac598
--- /dev/null
+++ b/common/wait_util.py
@@ -0,0 +1,14 @@
+from selenium.webdriver.support import expected_conditions as EC
+from selenium.webdriver.support.ui import WebDriverWait
+from appium import webdriver
+
+
+class WaitPage:
+ def __init__(self, driver):
+ self.driver = driver
+
+ # 定义一个获取元素的方法
+ def get_element(self,driver, *element):
+ element = WebDriverWait(driver,10).until(EC.element_to_be_clickable(*element))
+ return element
+
diff --git a/config/__init__.py b/config/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/config/config.yaml b/config/config.yaml
new file mode 100644
index 0000000..2ae8167
--- /dev/null
+++ b/config/config.yaml
@@ -0,0 +1,12 @@
+ios_caps:
+ platformName: iOS # 被测手机平台:Android/iOS
+ platformVersion: 17.5.1 # 手机iOS版本
+ deviceName: iPhone 12 # 设备名,安卓手机可以随意填写
+ bundleId: com.mimo.cyberflow.test # 启动APP Package名称
+ # appActivity: .ui.splash.SplashActivity # 启动Activity名称
+ # unicodeKeyboard: True # 使用自带输入法,输入中文时填True
+ # resetKeyboard: True # 执行完程序恢复原来输入法
+ # noReset: True # 不要重置App,如果为False的话,执行完脚本后,app的数据会清空,比如你原本登录了,执行完脚本后就退出登录了
+ # newCommandTimeout: 6000 # 超时时间可以设置久一些,太短,用例比较多会报错
+ automationName: XCUITest # 自动化测试引擎 ,默认Appium
+ udid: 00008101-000B38942E78001E
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..b56c695
--- /dev/null
+++ b/main.py
@@ -0,0 +1,16 @@
+# 这是一个示例 Python 脚本。
+
+# 按 ⌃R 执行或将其替换为您的代码。
+# 按 双击 ⇧ 在所有地方搜索类、文件、工具窗口、操作和设置。
+
+
+def print_hi(name):
+ # 在下面的代码行中使用断点来调试脚本。
+ print(f'Hi, {name}') # 按 ⌘F8 切换断点。
+
+
+# 按装订区域中的绿色按钮以运行脚本。
+if __name__ == '__main__':
+ print_hi('PyCharm')
+
+# 访问 https://www.jetbrains.com/help/pycharm/ 获取 PyCharm 帮助
From 4b863e4ba5a239a7a0ca1e80694c08835d1d00eb Mon Sep 17 00:00:00 2001
From: zhi1yuan <157468940+zhi1yuan@users.noreply.github.com>
Date: Sat, 10 May 2025 10:34:59 +0800
Subject: [PATCH 02/11] config.yaml
---
config/config.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/config.yaml b/config/config.yaml
index 2ae8167..37b6701 100644
--- a/config/config.yaml
+++ b/config/config.yaml
@@ -9,4 +9,4 @@ ios_caps:
# noReset: True # 不要重置App,如果为False的话,执行完脚本后,app的数据会清空,比如你原本登录了,执行完脚本后就退出登录了
# newCommandTimeout: 6000 # 超时时间可以设置久一些,太短,用例比较多会报错
automationName: XCUITest # 自动化测试引擎 ,默认Appium
- udid: 00008101-000B38942E78001E
+ udid: 00008101-000B38942E78001E # ios手机的udid
From 5ca951bc6725a87e7ea9cad9b5d89456738a95e5 Mon Sep 17 00:00:00 2001
From: zhi1yuan <157468940+zhi1yuan@users.noreply.github.com>
Date: Sat, 10 May 2025 10:34:59 +0800
Subject: [PATCH 03/11] =?UTF-8?q?=E7=BA=A2=E5=8C=85=E5=85=83=E7=B4=A0?=
=?UTF-8?q?=E5=B0=81=E8=A3=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../inspectionProfiles/profiles_settings.xml | 6 ++
.idea/mimo-test.iml | 10 +++
.idea/misc.xml | 7 ++
.idea/vcs.xml | 4 +-
11.py | 38 +++++++++
PageObjct/element_page/IM_page.py | 41 ++++++++-
PageObjct/element_page/club_page.py | 5 +-
PageObjct/operation_page/RedPacket_step.py | 83 +++++++++++++++++++
PageObjct/operation_page/club_step.py | 7 +-
TestCase/redpacket/test_redpacket.py | 44 ++++++++++
common/start_app.py | 17 ++++
config/__init__.py | 0
config/config.yaml | 2 +-
13 files changed, 253 insertions(+), 11 deletions(-)
create mode 100644 .idea/inspectionProfiles/profiles_settings.xml
create mode 100644 .idea/mimo-test.iml
create mode 100644 .idea/misc.xml
create mode 100644 11.py
create mode 100644 PageObjct/operation_page/RedPacket_step.py
create mode 100644 TestCase/redpacket/test_redpacket.py
create mode 100644 common/start_app.py
delete mode 100644 config/__init__.py
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/mimo-test.iml b/.idea/mimo-test.iml
new file mode 100644
index 0000000..aad402c
--- /dev/null
+++ b/.idea/mimo-test.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..db8786c
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index d843f34..94a25f7 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,4 +1,6 @@
-
+
+
+
\ No newline at end of file
diff --git a/11.py b/11.py
new file mode 100644
index 0000000..b726734
--- /dev/null
+++ b/11.py
@@ -0,0 +1,38 @@
+import os
+from appium import webdriver
+from appium.options.ios import XCUITestOptions
+from requests import options
+from common.data_util import readYaml
+
+# 回到根目录
+rootpath = os.path.abspath(os.path.dirname(__file__))
+# yaml文件的绝对路径
+path = os.path.join(rootpath, 'config/config.yaml')
+# 使用redYaml方法拿到数据
+data = readYaml(path)
+# iOS参数
+ios_caps={
+ "platformName": "iOS", # 被测手机平台:Android/iOS
+ "platformVersion": "17.5.1",# 手机iOS版本
+ "deviceName": "iPhone 12", # 设备名,安卓手机可以随意填写
+ "bundleId": "com.mimo.cyberflow.test", # 启动APP Package名称
+ # appActivity: .ui.splash.SplashActivity # 启动Activity名称
+ # unicodeKeyboard: True # 使用自带输入法,输入中文时填True
+ # resetKeyboard: True # 执行完程序恢复原来输入法
+ # noReset: True # 不要重置App,如果为False的话,执行完脚本后,app的数据会清空,比如你原本登录了,执行完脚本后就退出登录了
+ # newCommandTimeout: 6000 # 超时时间可以设置久一些,太短,用例比较多会报错
+ "automationName": "XCUITest", # 自动化测试引擎 ,默认Appium
+ "udid": "00008101-000B38942E78001E" # ios手机的udid
+}
+
+# 连接Appium Server,初始化自动化环境
+driver = webdriver.Remote('http://localhost:4723/wd/hub', data['ios_caps'])
+
+# options = XCUITestOptions()
+# options.platformName = "iOS"
+# options.platformVersion = "17.5.1"
+# options.deviceName = "iPhone 12" # 设备名,安卓手机可以随意填写
+# options.bundleId = "com.mimo.cyberflow.test" # 启动APP Package名称
+# options.automationName = "XCUITest", # 自动化测试引擎 ,默认Appium
+# options.udid = "00008101-000B38942E78001E" # ios手机的udid
+# driver = webdriver.Remote('http://localhost:4723/wd/hub', options=options)
\ No newline at end of file
diff --git a/PageObjct/element_page/IM_page.py b/PageObjct/element_page/IM_page.py
index 73b6842..5517301 100644
--- a/PageObjct/element_page/IM_page.py
+++ b/PageObjct/element_page/IM_page.py
@@ -1,9 +1,23 @@
from appium.webdriver.common.mobileby import MobileBy
+from selenium.webdriver.common.by import By
from Base.base_page import BasePage
class IMPage(BasePage):
+ # 底部消息table
+ el_message_icon = (MobileBy.ACCESSIBILITY_ID,'message_unselected_icon_light')
+ '''进入聊天室'''
+ # 通讯录
+ el_address_book = (MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="通讯录"]')
+ # 搜索框
+ el_search = (MobileBy.CLASS_NAME,'XCUIElementTypeTextField')
+ # 第六位好友
+ el_choose_friend_six = (MobileBy.XPATH,'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[7]')
+ # 我的群聊
+ el_group_chart_list = (MobileBy.XPATH,'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]/XCUIElementTypeButton[2]')
+ # 第一个群聊
+ el_choose_group_first = (MobileBy.XPATH,'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]')
# 消息输入框
el_input_IM = (MobileBy.XPATH,
'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeTextView')
@@ -26,10 +40,31 @@ class IMPage(BasePage):
# 文件
el_document = (MobileBy.ACCESSIBILITY_ID, 'chat_more_document_light')
# 选择图片
- el_picture_choose = (MobileBy.XPATH,'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[4]/XCUIElementTypeOther/XCUIElementTypeButton')
+ el_picture_choose = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[4]/XCUIElementTypeOther/XCUIElementTypeButton')
# 发送图片
el_send_picture = (MobileBy.ACCESSIBILITY_ID, '发送(1)')
# 选择视频
- el_video_choice = (MobileBy.XPATH,'(//XCUIElementTypeImage[@name="/var/containers/Bundle/Application/7024A092-04C5-4391-8650-52A234FC16EB/Zapry.app/TZImagePickerController.bundle/photo_def_photoPickerVc@2x.png"])[2]')
-
+ el_video_choice = (MobileBy.XPATH,
+ '(//XCUIElementTypeImage[@name="/var/containers/Bundle/Application/7024A092-04C5-4391-8650-52A234FC16EB/Zapry.app/TZImagePickerController.bundle/photo_def_photoPickerVc@2x.png"])[2]')
+ '''红包'''
+ # 绑定钱包弹窗-立即设置
+ el_wallet_popup_go = (By.XPATH, '//XCUIElementTypeButton[@name="立即设置"]')
+ # 关闭钱包
+ el_close_wallet = (MobileBy.XPATH, '//XCUIElementTypeNavigationBar[@name="RNSScreen"]/XCUIElementTypeOther[3]')
+ # 选择其他币
+ el_choose_coin = (MobileBy.ACCESSIBILITY_ID, 'red_bag_grayarrow_down')
+ # 选择CIQI
+ el_choose_CIQI = (MobileBy.ACCESSIBILITY_ID, 'CIQI, ALG L2(test), 837046934.1')
+ # 金额
+ el_sum = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeTextField[1]')
+ # 红包备注
+ el_red_remark = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeTextField[2]')
+ # 创建红包
+ el_create_redpacket = (MobileBy.ACCESSIBILITY_ID, '创建红包')
+ # 输入密码
+ el_input_pwd = (By.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther[1]/XCUIElementTypeSecureTextField')
diff --git a/PageObjct/element_page/club_page.py b/PageObjct/element_page/club_page.py
index 33c7445..7d60601 100644
--- a/PageObjct/element_page/club_page.py
+++ b/PageObjct/element_page/club_page.py
@@ -194,7 +194,7 @@ class ClubPage(BasePage):
'''应用房间相关'''
# 未绑定钱包点击应用房间的弹窗
el_popup_BindWallet = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="立即添加"]')
- el_PayPwd = (MobileBy.XPATH,'//XCUIElementTypeKey[@name="1"]')
+
# 应用房间跳转提示
el_popup_jumping = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="确定"]')
# 应用房间聊天气泡
@@ -224,4 +224,5 @@ class ClubPage(BasePage):
el_popup_NewWallet = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="创建新钱包"]')
# 跳过生物识别
el_recognition_skip = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="跳过"]')
- # 设置密码为“111111”
\ No newline at end of file
+ # 设置密码为“111111”
+ el_PayPwd = (MobileBy.XPATH, '//XCUIElementTypeKey[@name="1"]')
\ No newline at end of file
diff --git a/PageObjct/operation_page/RedPacket_step.py b/PageObjct/operation_page/RedPacket_step.py
new file mode 100644
index 0000000..40ae797
--- /dev/null
+++ b/PageObjct/operation_page/RedPacket_step.py
@@ -0,0 +1,83 @@
+from selenium.common import ElementNotInteractableException
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions
+from selenium.webdriver.support.wait import WebDriverWait
+from PageObjct.element_page.IM_page import IMPage
+from PageObjct.element_page.club_page import ClubPage
+
+
+class RedPacketStep(ClubPage, IMPage):
+
+ def create_redpacket1(self, sum, remark, pwd):
+ '''单聊创建红包'''
+ # 去消息tab
+ self.click(self.el_message_icon)
+ # 切换到通讯录
+ self.click(self.el_address_book)
+ # 选择第6个好友
+ WebDriverWait(self.driver, 10).until(
+ expected_conditions.element_to_be_clickable((By.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[7]')))
+ # 聊天室点击+按钮
+ self.click(self.el_IM_more)
+ # 点击红包
+ self.click(self.el_red_packet)
+ # 检查有没有没绑钱包提示,没绑先绑
+ element1 = self.driver.find_elements(By.XPATH, '//XCUIElementTypeButton[@name="立即设置"]')
+ if element1:
+ element1[0].click()
+ self.click(self.el_recognition_skip)
+ # 支付密码设置为6个1
+ for i in range(12):
+ self.click(self.el_PayPwd)
+ try:
+ element2 = WebDriverWait(self.driver, 10).until(
+ expected_conditions.element_to_be_clickable(
+ (By.XPATH, '//XCUIElementTypeNavigationBar[@name="RNSScreen"]/XCUIElementTypeOther[3]')))
+ # 关闭钱包回到聊天室
+ element2.click()
+ except TimeoutError as e:
+ print(f"{e}")
+ except ElementNotInteractableException as e:
+ print(f'{e}')
+ # +号菜单
+ self.click(self.el_IM_more)
+ # 红包
+ self.click(self.el_red_packet)
+
+ else:
+ pass
+ # 输入金额
+ self.input(self.el_sum, sum)
+ # 输入备注
+ self.input(self.el_red_remark, remark)
+ # 创建红包
+ self.click(self.el_create_redpacket)
+ # 输入密码:
+ self.input(self.el_input_pwd, pwd)
+
+ def create_redpacket2(self, sum, remark, pwd):
+ '''切换CIQI币发红包'''
+ # 点击消息tab
+ self.click(self.el_message_icon)
+ # 点击通讯录
+ self.click(self.el_address_book)
+ # 加载好友列表,点击第六个好友进入聊天室
+ WebDriverWait(self.driver, 10).until(expected_conditions.element_to_be_clickable((By.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[7]')))
+ # 聊天室中点击右下角的+号按钮
+ self.click(self.el_IM_more)
+ # 点击红包
+ self.click(self.el_red_packet)
+ # 点击下拉icon
+ self.click(self.el_choose_coin)
+ # 代币列表浮层中选择CIQI币
+ self.click(self.el_choose_CIQI)
+ # 输入金额
+ self.input(self.el_sum, sum)
+ # 输入备注
+ self.input(self.el_red_remark, remark)
+ # 点击创建红包
+ self.click(self.el_create_redpacket)
+ # 输入密码
+ self.input(self.el_input_pwd, pwd)
diff --git a/PageObjct/operation_page/club_step.py b/PageObjct/operation_page/club_step.py
index 421c095..a661745 100644
--- a/PageObjct/operation_page/club_step.py
+++ b/PageObjct/operation_page/club_step.py
@@ -4,7 +4,6 @@
from PageObjct.element_page.IM_page import IMPage
from PageObjct.element_page.club_page import ClubPage
from common.wait_util import WaitPage
-from web import driver
class ClubStep(ClubPage, IMPage):
@@ -152,7 +151,7 @@ def send_message_to_channel(self, text):
# 选择侧边栏第一个部落
self.click(self.el_club1)
# 网卡的时候加载慢,使用显式等待
- driver.implicitly_wait(10)
+ self.driver.implicitly_wait(10)
# 选择”聊天房间“房间
self.click(self.el_choose_ChartRoom1)
# 输入框内输入消息
@@ -174,7 +173,7 @@ def send_picture_to_channel(self):
# 上滑两次确保到了相册顶部
self.down_slide()
self.down_slide()
- driver.implicitly_wait(10)
+ self.driver.implicitly_wait(10)
# 选择第4张图片
self.click(self.el_picture_choose)
# 点击发送
@@ -194,7 +193,7 @@ def send_video_to_channel(self):
# 上滑两次确保到了相册顶部
self.down_slide()
self.down_slide()
- driver.implicitly_wait(10)
+ self.driver.implicitly_wait(10)
# 选择第2个视频
self.click(self.el_video_choice)
# 点击发送
diff --git a/TestCase/redpacket/test_redpacket.py b/TestCase/redpacket/test_redpacket.py
new file mode 100644
index 0000000..55833fe
--- /dev/null
+++ b/TestCase/redpacket/test_redpacket.py
@@ -0,0 +1,44 @@
+import os
+from appium import webdriver
+from selenium.webdriver.common.by import By
+from Base.app_assert_page import AppAssertPage
+from PageObjct.operation_page.RedPacket_step import RedPacketStep
+from common.data_util import readYaml
+from common.start_app import StartApp
+
+
+class TestRedPacket(StartApp):
+ def set_up(self):
+ # 回到根目录
+ rootpath = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
+ # yaml文件的绝对路径
+ path = os.path.join(rootpath, 'config/config.yaml')
+ # 拿到数据
+ data = readYaml(path)
+ # 连接Appium Server,初始化自动化环境
+ self.driver = webdriver.Remote('http://localhost:4723/wd/hub', data['ios_caps'])
+
+ def teardown(self):
+ self.driver.quit()
+
+ '''单聊发红包'''
+
+ def test_redpacket(self):
+ self.set_up()
+ step = RedPacketStep(self.driver)
+ step.create_redpacket1("0.01", "自动化脚本红包", "111111")
+ ass = AppAssertPage(self.driver)
+ el = ''
+ assert ass.is_element_present(By.XPATH, el) == True, '没有找到红包元素,测试失败'
+ self.teardown()
+
+ '''单聊切币发红包'''
+
+ def test_choose_CIQI(self):
+ self.set_up()
+ step = RedPacketStep(self.driver)
+ step.create_redpacket2("0.01", "CIQI自动化红包", "111111")
+ ass = AppAssertPage(self.driver)
+ el = ''
+ assert ass.is_element_present(By.XPATH, el) == True, ''
+ self.teardown()
diff --git a/common/start_app.py b/common/start_app.py
new file mode 100644
index 0000000..893b34e
--- /dev/null
+++ b/common/start_app.py
@@ -0,0 +1,17 @@
+import os
+
+import pytest
+from appium.webdriver.webdriver import WebDriver
+from common.data_util import readYaml
+
+class StartApp:
+ def test_start_app(self):
+ # 回到根目录
+ rootpath = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
+ # yaml文件的绝对路径
+ path = os.path.join(rootpath, 'config/config.yaml')
+ # 拿到数据
+ data = readYaml(path)
+ # 连接Appium Server,初始化自动化环境
+ self.driver = WebDriver('http://localhost:4723/wd/hub', data['ios_caps'])
+
diff --git a/config/__init__.py b/config/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/config/config.yaml b/config/config.yaml
index 2ae8167..37b6701 100644
--- a/config/config.yaml
+++ b/config/config.yaml
@@ -9,4 +9,4 @@ ios_caps:
# noReset: True # 不要重置App,如果为False的话,执行完脚本后,app的数据会清空,比如你原本登录了,执行完脚本后就退出登录了
# newCommandTimeout: 6000 # 超时时间可以设置久一些,太短,用例比较多会报错
automationName: XCUITest # 自动化测试引擎 ,默认Appium
- udid: 00008101-000B38942E78001E
+ udid: 00008101-000B38942E78001E # ios手机的udid
From 17aa5f782b7f0c448e91905f8c38a9674d5bd9db Mon Sep 17 00:00:00 2001
From: gdlooker
Date: Wed, 21 May 2025 17:22:08 +0800
Subject: [PATCH 04/11] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96appium?=
=?UTF-8?q?=E5=B0=81=E8=A3=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
TestCase/redpacket/test_redpacket.py | 45 ++++++++--------------------
1 file changed, 13 insertions(+), 32 deletions(-)
diff --git a/TestCase/redpacket/test_redpacket.py b/TestCase/redpacket/test_redpacket.py
index 0b65f7d..3e5308c 100644
--- a/TestCase/redpacket/test_redpacket.py
+++ b/TestCase/redpacket/test_redpacket.py
@@ -12,95 +12,77 @@
class TestRedPacket():
- def setup(self):
- # 回到根目录
- rootpath = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
- # yaml文件的绝对路径
- path = os.path.join(rootpath, 'config/config.yaml')
- # 拿到数据
- data = readYaml(path)
- # 连接Appium Server,初始化自动化环境
- self.driver = webdriver.Remote('http://localhost:4723/wd/hub', data['ios_caps'])
-
- def teardown(self):
- self.driver.quit()
+ '''发红包用例'''
'''单聊发红包'''
- def test_redpacket(self):
- self.setup()
+ def test_redpacket(self, start_app):
+ self.driver = start_app
step = RedPacketStep(self.driver)
step.create_redpacket1("0.01", "单聊自动化脚本红包", "111111")
ass = AppAssertPage(self.driver)
el = '单聊自动化脚本红包'
sleep(1)
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, '没有找到红包元素,测试失败'
- self.teardown()
'''密码错误,发红包失败'''
- def test_redpacket_fail(self):
- self.setup()
+ def test_redpacket_fail(self, start_app):
+ self.driver = start_app
step = RedPacketStep(self.driver)
step.create_redpacket1("0.01", "", "111122")
ass = AppAssertPage(self.driver)
el = '验证失败'
sleep(1)
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, '缺少错误提示'
- self.teardown()
'''单聊切币发红包'''
- def test_redpacket2(self):
- self.setup()
+ def test_redpacket2(self, start_app):
+ self.driver = start_app
step = RedPacketStep(self.driver)
step.create_redpacket2("0.01", "CIQI自动化红包", "111111")
ass = AppAssertPage(self.driver)
el = 'CIQI自动化红包'
sleep(1)
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, ''
- self.teardown()
'''群聊发红包'''
- def test_group_redpacket(self):
- self.setup()
+ def test_group_redpacket(self, start_app):
+ self.driver = start_app
step = RedPacketStep(self.driver)
step.create_group_redpacket1('3', '0.04', '群聊自动化红包', '111111')
ass = AppAssertPage(self.driver)
el = '群聊自动化红包'
sleep(1)
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, '测试失败,未找到元素'
- self.teardown()
'''群聊发ALG普通红包'''
- def test_group_redpacket2(self):
- self.setup()
+ def test_group_redpacket2(self, start_app):
+ self.driver = start_app
step = RedPacketStep(self.driver)
step.create_group_redpacket2('3', '0.03', '群聊ALG自动化红包', '111111')
ass = AppAssertPage(self.driver)
el = '群聊ALG自动化红包'
sleep(1)
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, ''
- self.teardown()
'''频道发红包'''
- def test_channel_redpacket(self):
- self.setup()
+ def test_channel_redpacket(self, start_app):
+ self.driver = start_app
step = RedPacketStep(self.driver)
step.create_channel_redpacket1('3', '0.04', '频道自动化红包', '111111')
ass = AppAssertPage(self.driver)
el = '频道自动化红包'
sleep(1)
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, ''
- self.teardown()
'''频道发CIQI普通红包'''
def test_channel_redpacket2(self, start_app):
- # self.setup()
self.driver = start_app
step = RedPacketStep(self.driver)
step.create_channel_redpacket2('3', '0.03', '频道CIQI自动化红包', '111111')
@@ -108,4 +90,3 @@ def test_channel_redpacket2(self, start_app):
el = '频道CIQI自动化红包'
sleep(1)
check.is_true(ass.is_element_enabled(MobileBy.ACCESSIBILITY_ID, el) == True), f'元素{el}应该可见但未找到'
- # self.teardown()
From 3773464aae0b763ae2ba8d50d0af61c38dea022f Mon Sep 17 00:00:00 2001
From: gdlooker
Date: Wed, 21 May 2025 17:37:29 +0800
Subject: [PATCH 05/11] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96appium?=
=?UTF-8?q?=E5=B0=81=E8=A3=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
TestCase/redpacket/test_redpacket.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/TestCase/redpacket/test_redpacket.py b/TestCase/redpacket/test_redpacket.py
index 3e5308c..f5bea6f 100644
--- a/TestCase/redpacket/test_redpacket.py
+++ b/TestCase/redpacket/test_redpacket.py
@@ -25,7 +25,7 @@ def test_redpacket(self, start_app):
sleep(1)
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, '没有找到红包元素,测试失败'
- '''密码错误,发红包失败'''
+ '''密码错误,发红包提示'''
def test_redpacket_fail(self, start_app):
self.driver = start_app
From 7110098b84fdb855adf630bae5cce062ebd82e67 Mon Sep 17 00:00:00 2001
From: gdlooker
Date: Sat, 24 May 2025 16:49:08 +0800
Subject: [PATCH 06/11] =?UTF-8?q?=E5=A4=87=E4=BB=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Base/__init__.py | 4 +
PageObjct/__init__.py | 0
PageObjct/operation_page/IM_step.py | 118 ++++++++++++++++++++++++++
PageObjct/operation_page/club_step.py | 96 ++++++---------------
TestCase/IM/__init__.py | 0
TestCase/IM/test_IM.py | 51 +++++++++++
TestCase/__init__.py | 6 --
TestCase/club/test_creat_club.py | 92 +++++++++-----------
TestCase/redpacket/__init__.py | 0
TestCase/redpacket/test_redpacket.py | 2 +-
config/__init__.py | 0
data/__init__.py | 0
12 files changed, 239 insertions(+), 130 deletions(-)
create mode 100644 PageObjct/__init__.py
create mode 100644 PageObjct/operation_page/IM_step.py
create mode 100644 TestCase/IM/__init__.py
create mode 100644 TestCase/IM/test_IM.py
create mode 100644 TestCase/redpacket/__init__.py
create mode 100644 config/__init__.py
create mode 100644 data/__init__.py
diff --git a/Base/__init__.py b/Base/__init__.py
index e69de29..8e93451 100644
--- a/Base/__init__.py
+++ b/Base/__init__.py
@@ -0,0 +1,4 @@
+import pytest
+
+if __name__ == '__main__':
+ pytest.main()
\ No newline at end of file
diff --git a/PageObjct/__init__.py b/PageObjct/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/PageObjct/operation_page/IM_step.py b/PageObjct/operation_page/IM_step.py
new file mode 100644
index 0000000..0c1320d
--- /dev/null
+++ b/PageObjct/operation_page/IM_step.py
@@ -0,0 +1,118 @@
+from Base.base_page import BasePage
+from PageObjct.element_page.IM_page import IMPage
+from PageObjct.element_page.club_page import ClubPage
+
+
+class IMStep(IMPage,ClubPage):
+ '''IM相关操作'''
+
+ '''频道发消息'''
+
+ def IM_channel_message(self, text):
+ # 选择侧边栏第一个部落
+ self.click(self.el_club1)
+ # 网卡的时候加载慢,使用显式等待
+ self.driver.implicitly_wait(10)
+ # 选择”聊天房间“房间
+ self.click(self.el_choose_ChartRoom1)
+ # 输入框内输入消息
+ self.input(self.el_input_IM, text)
+ # 发送消息
+ self.click(self.el_send_message)
+
+ '''频道发图片'''
+
+ def IM_channel_picture(self):
+ # 选择侧边栏第一个部落
+ self.click(self.el_club1)
+ # 选择”聊天房间“房间
+ self.click(self.el_choose_ChartRoom1)
+ # 点开更多面板
+ self.click(self.el_IM_more)
+ # 进入相册
+ self.click(self.el_photo_choose)
+ # 上滑两次确保到了相册顶部
+ self.down_slide()
+ self.down_slide()
+ self.driver.implicitly_wait(10)
+ # 选择第4张图片
+ self.click(self.el_picture_choose)
+ # 点击发送
+ self.click(self.el_send_picture)
+
+ '''频道发视频'''
+
+ def IM_channel_video(self):
+ # 选择侧边栏第一个部落
+ self.click(self.el_club1)
+ # 选择”聊天房间“房间
+ self.click(self.el_choose_ChartRoom1)
+ # 点开更多面板
+ self.click(self.el_IM_more)
+ # 进入相册
+ self.click(self.el_photo_choose)
+ # 上滑两次确保到了相册顶部
+ self.down_slide()
+ self.down_slide()
+ self.driver.implicitly_wait(10)
+ # 选择第2个视频
+ self.click(self.el_video_choice)
+ # 点击发送
+ self.click(self.el_send_picture)
+
+ '''单聊发消息'''
+ def IM_solo_message(self,message):
+ # 去消息tab
+ self.click(self.el_message_icon)
+ # 点击通讯录
+ self.click(self.el_address_book)
+ # 选择第六个好友
+ self.click(self.el_choose_friend_six)
+ # 输入框输入消息
+ self.input(self.el_input_IM,message)
+ # 点击发送
+ self.click(self.el_send_message)
+
+ '''单聊发图片'''
+
+ def IM_solo_picture(self):
+ # 去消息tab
+ self.click(self.el_message_icon)
+ # 点击通讯录
+ self.click(self.el_address_book)
+ # 选择第六个好友
+ self.click(self.el_choose_friend_six)
+ # 点开更多面板
+ self.click(self.el_IM_more)
+ # 进入相册
+ self.click(self.el_photo_choose)
+ # 上滑两次确保到了相册顶部
+ self.down_slide()
+ self.down_slide()
+ self.driver.implicitly_wait(10)
+ # 选择第4张图片
+ self.click(self.el_picture_choose)
+ # 点击发送
+ self.click(self.el_send_picture)
+
+ '''单聊发视频'''
+
+ def IM_solo_video(self):
+ # 去消息tab
+ self.click(self.el_message_icon)
+ # 点击通讯录
+ self.click(self.el_address_book)
+ # 选择第六个好友
+ self.click(self.el_choose_friend_six)
+ # 点开更多面板
+ self.click(self.el_IM_more)
+ # 进入相册
+ self.click(self.el_photo_choose)
+ # 上滑两次确保到了相册顶部
+ self.down_slide()
+ self.down_slide()
+ self.driver.implicitly_wait(10)
+ # 选择第2个视频
+ self.click(self.el_video_choice)
+ # 点击发送
+ self.click(self.el_send_picture)
\ No newline at end of file
diff --git a/PageObjct/operation_page/club_step.py b/PageObjct/operation_page/club_step.py
index 74436c7..b82b149 100644
--- a/PageObjct/operation_page/club_step.py
+++ b/PageObjct/operation_page/club_step.py
@@ -7,10 +7,10 @@
class ClubStep(ClubPage, IMPage):
-
+ """创建部落"""
def create_club(self, name):
- """创建部落"""
+
# 点击icon
self.click(self.el_icon)
# 点击卡片
@@ -30,7 +30,7 @@ def create_club(self, name):
# 点击创建部落
self.click(self.el_create_club)
- '''分享部落到频道'''
+ '''分享部落到频道'''
def share_club_to_club(self):
# 点击侧边栏第一个部落
@@ -53,7 +53,7 @@ def share_club_to_club(self):
# 分享弹窗点击发送
self.click(self.el_share_send)
- """分享部落到单聊"""
+ """分享部落到单聊"""
def share_club_to_contact(self, contact_name):
# 点击侧边栏第一个部落
@@ -78,7 +78,7 @@ def share_club_to_contact(self, contact_name):
# 分享弹窗点击发送
self.click(self.el_share_send)
- '''分享部落到群聊'''
+ '''分享部落到群聊'''
def share_club_to_group_chat(self, group_name):
# 点击侧边栏第一个部落
@@ -102,7 +102,7 @@ def share_club_to_group_chat(self, group_name):
# 分享弹窗点击发送
self.click(self.el_share_send)
- '''发一条部落动态'''
+ '''发一条部落动态'''
def send_community(self, title, text):
# 点击进入部落社区
@@ -116,7 +116,7 @@ def send_community(self, title, text):
# 点击发布
self.click(self.el_release)
- '''添加聊天房间'''
+ '''添加聊天房间'''
def add_chat_room(self, chart_room):
# 点击 部落管理 后面的 + 号
@@ -128,7 +128,7 @@ def add_chat_room(self, chart_room):
# 创建房间
self.click(self.el_create_button)
- '''添加DAPP房间'''
+ '''添加DAPP房间'''
def add_dapp_room(self, dapp_room, dapp_link, dapp_text):
# 点击 部落管理 后面的 + 号
@@ -145,61 +145,7 @@ def add_dapp_room(self, dapp_room, dapp_link, dapp_text):
self.click(self.el_dapp_done)
# self.swipe(123,123,432,422)
- '''频道发消息'''
-
- def send_message_to_channel(self, text):
- # 选择侧边栏第一个部落
- self.click(self.el_club1)
- # 网卡的时候加载慢,使用显式等待
- self.driver.implicitly_wait(10)
- # 选择”聊天房间“房间
- self.click(self.el_choose_ChartRoom1)
- # 输入框内输入消息
- self.input(self.el_input_IM, text)
- # 发送消息
- self.click(self.el_send_message)
-
- '''频道发图片'''
-
- def send_picture_to_channel(self):
- # 选择侧边栏第一个部落
- self.click(self.el_club1)
- # 选择”聊天房间“房间
- self.click(self.el_choose_ChartRoom1)
- # 点开更多面板
- self.click(self.el_IM_more)
- # 进入相册
- self.click(self.el_photo_choose)
- # 上滑两次确保到了相册顶部
- self.down_slide()
- self.down_slide()
- self.driver.implicitly_wait(10)
- # 选择第4张图片
- self.click(self.el_picture_choose)
- # 点击发送
- self.click(self.el_send_picture)
-
- '''频道发视频'''
-
- def send_video_to_channel(self):
- # 选择侧边栏第一个部落
- self.click(self.el_club1)
- # 选择”聊天房间“房间
- self.click(self.el_choose_ChartRoom1)
- # 点开更多面板
- self.click(self.el_IM_more)
- # 进入相册
- self.click(self.el_photo_choose)
- # 上滑两次确保到了相册顶部
- self.down_slide()
- self.down_slide()
- self.driver.implicitly_wait(10)
- # 选择第2个视频
- self.click(self.el_video_choice)
- # 点击发送
- self.click(self.el_send_picture)
-
- '''发布房间公告'''
+ '''发布房间公告'''
def chart_room_announce(self, text):
# 选择侧边栏第一个部落
@@ -217,7 +163,7 @@ def chart_room_announce(self, text):
# 返回房间
self.click(self.el_back)
- '''开启全员禁言'''
+ '''开启全员禁言'''
def all_shutup(self):
# 选择侧边栏第一个部落
@@ -231,7 +177,7 @@ def all_shutup(self):
# 返回房间
self.click(self.el_back)
- '''设置免打扰'''
+ '''设置免打扰'''
def message_disturb(self):
# 选择侧边栏第一个部落
@@ -247,7 +193,7 @@ def message_disturb(self):
# 返回房间
self.click(self.el_back)
- '''清空聊天记录'''
+ '''清空聊天记录'''
def clear_message(self):
# 选择侧边栏第一个部落
@@ -263,7 +209,7 @@ def clear_message(self):
# 返回
self.click(self.el_back)
- '''删除房间'''
+ '''删除房间'''
def delete_room(self):
# 选择侧边栏第一个部落
@@ -277,7 +223,8 @@ def delete_room(self):
# 二次确认
self.click(self.el_delete_popup)
- '''通过应用房间提示绑定钱包'''
+ '''通过应用房间提示绑定钱包'''
+
def bing_wallet(self):
# 选择第一个部落
self.click(self.el_club1)
@@ -294,7 +241,9 @@ def bing_wallet(self):
# 输入密码并二次确认密码
for i in range(12):
self.click(self.el_PayPwd)
- '''最小化dapp'''
+
+ '''最小化dapp'''
+
def dapp_windowed(self):
# 进入第一个部落
self.click(self.el_club1)
@@ -308,7 +257,8 @@ def dapp_windowed(self):
# 点击窗口化
self.click(self.el_DappRoom_windowed)
- '''关闭dapp'''
+ '''关闭dapp'''
+
def dapp_close1(self):
# 进入第一个部落
self.click(self.el_club1)
@@ -321,14 +271,16 @@ def dapp_close1(self):
print(f'没有出现弹窗或其他原因:{e}')
self.click(self.el_DappRoom_close)
- '''最小化后再打开全屏'''
+ '''最小化后再打开全屏'''
+
def dapp_blow_up(self):
# 先最小化
self.dapp_windowed()
# 放大到全屏
self.click(self.el_DappWindowed_BlowUp)
- '''关闭dapp小窗'''
+ '''关闭dapp小窗'''
+
def dapp_close2(self):
# 先最小化
self.dapp_windowed()
diff --git a/TestCase/IM/__init__.py b/TestCase/IM/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/TestCase/IM/test_IM.py b/TestCase/IM/test_IM.py
new file mode 100644
index 0000000..eeddef9
--- /dev/null
+++ b/TestCase/IM/test_IM.py
@@ -0,0 +1,51 @@
+from time import sleep
+
+from appium.webdriver.common.mobileby import MobileBy
+
+from Base.app_assert_page import AppAssertPage
+from PageObjct.operation_page.IM_step import IMStep
+from common.start_app import start_app
+
+
+class TestIM:
+ """频道发消息"""
+ def test_IM_channel_message(self,start_app):
+ self.driver = start_app
+
+ club_step = IMStep(self.driver)
+ club_step.IM_channel_message('频道自动化消息')
+
+ ass = AppAssertPage(driver=self.driver)
+ el = "频道自动化消息"
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID,el) == True
+
+ '''在频道发图片'''
+ def test_IM_channel_picture(self,start_app):
+ self.driver = start_app
+
+ club_step = IMStep(self.driver)
+ club_step.IM_channel_picture()
+ # 多等一会让图片发送成功
+ sleep(2)
+ ass = AppAssertPage(driver=self.driver)
+ # 被检查的元素
+ el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+
+ '''在频道发视频'''
+ def test_IM_channel_video(self,start_app):
+ self.driver = start_app
+
+ club_step = IMStep(self.driver)
+ club_step.IM_channel_video()
+ sleep(2)
+ ass = AppAssertPage(driver=self.driver)
+ # 被检查的元素
+ el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+
+ '''单聊发消息'''
+ def test_IM_solo_message(self,start_app):
+ self.driver = start_app
+ step = IMStep(self.driver)
+ step.IM_solo_message("自动化单聊消息")
diff --git a/TestCase/__init__.py b/TestCase/__init__.py
index d837360..e69de29 100644
--- a/TestCase/__init__.py
+++ b/TestCase/__init__.py
@@ -1,6 +0,0 @@
-import pytest
-
-
-
-if __name__ == '__main__':
- pytest.main()
\ No newline at end of file
diff --git a/TestCase/club/test_creat_club.py b/TestCase/club/test_creat_club.py
index 366d5c6..923f46a 100644
--- a/TestCase/club/test_creat_club.py
+++ b/TestCase/club/test_creat_club.py
@@ -27,10 +27,11 @@ def tset_up(self):
def teardown(self):
self.driver.quit()
- # 创建部落
+ """创建部落"""
+
def test_create_club(self):
self.tset_up()
- """创建部落"""
+
club_step = ClubStep(self.driver)
club_step.create_club('部落')
# 创建过程太慢,需要多等一会
@@ -41,9 +42,11 @@ def test_create_club(self):
assert ass.is_element_present(MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="跳过"]') == True
self.teardown()
+ """分享部落到房间"""
+
def test_share_club_to_club(self):
self.tset_up()
- """分享部落到房间"""
+
club_step = ClubStep(self.driver)
club_step.share_club_to_club()
sleep(1)
@@ -52,9 +55,11 @@ def test_share_club_to_club(self):
assert ass.is_element_present(MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="部落邀请"]') == True
self.teardown()
+ """分享部落到单聊"""
+
def test_share_club_to_contact(self):
self.tset_up()
- """分享部落到单聊"""
+
club_step = ClubStep(self.driver)
club_step.share_club_to_contact('204')
sleep(1)
@@ -63,9 +68,11 @@ def test_share_club_to_contact(self):
assert ass.is_element_present(MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="部落邀请"]') == True
self.teardown()
+ """分享部落群聊"""
+
def test_share_club_to_group_chart(self):
self.tset_up()
- """分享部落群聊"""
+
club_step = ClubStep(self.driver)
club_step.share_club_to_group_chat('2')
sleep(1)
@@ -74,9 +81,11 @@ def test_share_club_to_group_chart(self):
assert ass.is_element_present(MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="部落邀请"]') == True
self.teardown()
+ """发部落动态"""
+
def test_send_community(self):
self.tset_up()
- """发部落动态"""
+
club_step = ClubStep(self.driver)
club_step.send_community('这是动态标题', '这是动态内容')
sleep(2)
@@ -85,9 +94,11 @@ def test_send_community(self):
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, '动态详情') == True
self.teardown()
+ """添加聊天房间"""
+
def test_add_chart_room(self):
self.tset_up()
- """添加聊天房间"""
+
club_step = ClubStep(self.driver)
club_step.add_chat_room('聊天房间')
sleep(2)
@@ -95,9 +106,11 @@ def test_add_chart_room(self):
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, '聊天房间') == True
self.teardown()
+ """添加应用房间"""
+
def test_add_dapp_room(self):
self.tset_up()
- """添加应用房间"""
+
club_step = ClubStep(self.driver)
club_step.add_dapp_room('应用房间',
'https://www.baidu.com/s?wd=%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95&rsv_spt=1&rsv_iqid=0x9058a494003119fd&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_dl=tb&rsv_enter=1&rsv_sug3=38&rsv_sug1=36&rsv_sug7=100&rsv_sug2=0&rsv_btype=i&prefixsug=%25E8%2587%25AA%25E5%258A%25A8%25E5%258C%2596%25E6%25B5%258B%25E8%25AF%2595&rsp=5&inputT=12351&rsv_sug4=15729',
@@ -110,44 +123,11 @@ def test_add_dapp_room(self):
print(e)
self.teardown()
- def test_send_message_to_channel(self):
- self.tset_up()
- """频道发消息"""
- club_step = ClubStep(self.driver)
- club_step.send_message_to_channel('123456')
-
- ass = AppAssertPage(driver=self.driver)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, '123456') == True
- self.teardown()
-
- def test_send_picture_to_channel(self):
- self.tset_up()
- '''在频道发图片'''
- club_step = ClubStep(self.driver)
- club_step.send_picture_to_channel()
- # 多等一会让图片发送成功
- sleep(2)
- ass = AppAssertPage(driver=self.driver)
- # 被检查的元素
- el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
- self.teardown()
-
- def test_send_video_to_channel(self):
- self.tset_up()
- '''在频道发视频'''
- club_step = ClubStep(self.driver)
- club_step.send_video_to_channel()
- sleep(2)
- ass = AppAssertPage(driver=self.driver)
- # 被检查的元素
- el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
- self.teardown()
+ '''聊天房间发布公告'''
def test_chart_room_announce(self):
self.tset_up()
- '''聊天房间发布公告'''
+
club_step = ClubStep(self.driver)
club_step.chart_room_announce('欢迎来到聊天房间')
sleep(2)
@@ -156,9 +136,11 @@ def test_chart_room_announce(self):
assert ass.is_element_present(MobileBy.XPATH, el_ass) == True
self.teardown()
+ '''房间开启全员禁言'''
+
def test_all_shutup1(self):
self.tset_up()
- '''房间禁言'''
+
club_step = ClubStep(self.driver)
club_step.all_shutup()
ass = AppAssertPage(driver=self.driver)
@@ -166,9 +148,11 @@ def test_all_shutup1(self):
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
self.teardown()
+ '''房间关闭全员禁言'''
+
def test_all_shutup2(self):
self.tset_up()
- '''房间禁言'''
+
club_step = ClubStep(self.driver)
club_step.all_shutup()
ass = AppAssertPage(driver=self.driver)
@@ -176,9 +160,11 @@ def test_all_shutup2(self):
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
self.teardown()
+ '''消息免打扰'''
+
def test_message_disturb(self):
self.tset_up()
- '''消息免打扰'''
+
club_step = ClubStep(self.driver)
club_step.message_disturb()
ass = AppAssertPage(driver=self.driver)
@@ -186,9 +172,11 @@ def test_message_disturb(self):
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
self.teardown()
+ '''清空聊天记录'''
+
def test_clear_message(self):
self.tset_up()
- '''清空聊天记录'''
+
club_step = ClubStep(self.driver)
club_step.clear_message()
ass = AppAssertPage(driver=self.driver)
@@ -196,9 +184,11 @@ def test_clear_message(self):
assert ass.is_element_present(MobileBy.XPATH, el_ass) == False
self.teardown()
+ '''删除房间'''
+
def test_delete_room(self):
self.tset_up()
- '''删除房间'''
+
club_step = ClubStep(self.driver)
club_step.delete_room()
sleep(2)
@@ -207,9 +197,11 @@ def test_delete_room(self):
assert ass.is_element_present(MobileBy.XPATH, el_ass) == False
self.teardown()
+ '''根据应用房间提示去绑定钱包'''
+
def test_bing_wallet(self):
self.tset_up()
- '''根据应用房间提示去绑定钱包'''
+
club_step = ClubStep(self.driver)
club_step.bing_wallet()
# 创建钱包后加载较慢
@@ -220,8 +212,6 @@ def test_bing_wallet(self):
self.teardown()
-窗口化el_ass ='//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther[1]'
-
if __name__ == '__main__':
pytest.main()
diff --git a/TestCase/redpacket/__init__.py b/TestCase/redpacket/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/TestCase/redpacket/test_redpacket.py b/TestCase/redpacket/test_redpacket.py
index f5bea6f..1383da1 100644
--- a/TestCase/redpacket/test_redpacket.py
+++ b/TestCase/redpacket/test_redpacket.py
@@ -11,7 +11,7 @@
from common.start_app import start_app
-class TestRedPacket():
+class TestRedPacket:
'''发红包用例'''
'''单聊发红包'''
diff --git a/config/__init__.py b/config/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/data/__init__.py b/data/__init__.py
new file mode 100644
index 0000000..e69de29
From a1ddfb4ac6a530680e954cbff02da1599e70ad24 Mon Sep 17 00:00:00 2001
From: zhi1yuan <157468940+zhi1yuan@users.noreply.github.com>
Date: Fri, 9 May 2025 17:29:23 +0800
Subject: [PATCH 07/11] =?UTF-8?q?=E7=BE=A4=E8=81=8A=E5=88=9B=E5=BB=BA?=
=?UTF-8?q?=E3=80=81=E5=8F=91=E6=B6=88=E6=81=AF=E3=80=81=E5=9B=BE=E7=89=87?=
=?UTF-8?q?=E3=80=81=E8=A7=86=E9=A2=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
PageObjct/element_page/IM_page.py | 4 ----
PageObjct/element_page/club_page.py | 2 --
PageObjct/operation_page/club_step.py | 8 ++------
TestCase/__init__.py | 6 ++++++
TestCase/club/test_creat_club.py | 17 -----------------
main.py | 16 ++++++++++++++++
6 files changed, 24 insertions(+), 29 deletions(-)
create mode 100644 main.py
diff --git a/PageObjct/element_page/IM_page.py b/PageObjct/element_page/IM_page.py
index 3d5af7b..fb84128 100644
--- a/PageObjct/element_page/IM_page.py
+++ b/PageObjct/element_page/IM_page.py
@@ -44,13 +44,9 @@ class IMPage(BasePage):
# 文件
el_document = (MobileBy.ACCESSIBILITY_ID, 'chat_more_document_light')
# 选择图片
- el_picture_choose = (MobileBy.XPATH,
- '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[4]/XCUIElementTypeOther/XCUIElementTypeButton')
# 发送图片
el_send_picture = (MobileBy.ACCESSIBILITY_ID, '发送(1)')
# 选择视频
- el_video_choice = (MobileBy.XPATH,
- '(//XCUIElementTypeImage[@name="/var/containers/Bundle/Application/7024A092-04C5-4391-8650-52A234FC16EB/Zapry.app/TZImagePickerController.bundle/photo_def_photoPickerVc@2x.png"])[2]')
'''发红包'''
# 绑定钱包弹窗-立即设置
diff --git a/PageObjct/element_page/club_page.py b/PageObjct/element_page/club_page.py
index 3f77cef..d7fa718 100644
--- a/PageObjct/element_page/club_page.py
+++ b/PageObjct/element_page/club_page.py
@@ -118,7 +118,6 @@ class ClubPage(BasePage):
el_group_search = (MobileBy.XPATH,
'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeTextField[2]')
# 选择第一个群聊
- el_share_group_first = (MobileBy.XPATH,
'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable[2]/XCUIElementTypeCell[1]')
# 点击确认
el_group_confirm = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="确认(1/9)"]')
@@ -198,7 +197,6 @@ class ClubPage(BasePage):
'''应用房间相关'''
# 未绑定钱包点击应用房间的弹窗
el_popup_BindWallet = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="立即添加"]')
-
# 应用房间跳转提示
el_popup_jumping = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="确定"]')
# 应用房间聊天气泡
diff --git a/PageObjct/operation_page/club_step.py b/PageObjct/operation_page/club_step.py
index b82b149..5418043 100644
--- a/PageObjct/operation_page/club_step.py
+++ b/PageObjct/operation_page/club_step.py
@@ -7,10 +7,7 @@
class ClubStep(ClubPage, IMPage):
- """创建部落"""
-
- def create_club(self, name):
-
+ """创建部落"""
# 点击icon
self.click(self.el_icon)
# 点击卡片
@@ -94,7 +91,6 @@ def share_club_to_group_chat(self, group_name):
self.input(self.el_group_search, group_name)
sleep(1)
# 选择第一个群聊
- self.click(self.el_share_group_first)
sleep(1)
# 点击确认
self.click(self.el_group_confirm)
@@ -145,7 +141,7 @@ def add_dapp_room(self, dapp_room, dapp_link, dapp_text):
self.click(self.el_dapp_done)
# self.swipe(123,123,432,422)
- '''发布房间公告'''
+ '''发布房间公告'''
def chart_room_announce(self, text):
# 选择侧边栏第一个部落
diff --git a/TestCase/__init__.py b/TestCase/__init__.py
index e69de29..d837360 100644
--- a/TestCase/__init__.py
+++ b/TestCase/__init__.py
@@ -0,0 +1,6 @@
+import pytest
+
+
+
+if __name__ == '__main__':
+ pytest.main()
\ No newline at end of file
diff --git a/TestCase/club/test_creat_club.py b/TestCase/club/test_creat_club.py
index 923f46a..b310d6d 100644
--- a/TestCase/club/test_creat_club.py
+++ b/TestCase/club/test_creat_club.py
@@ -27,11 +27,8 @@ def tset_up(self):
def teardown(self):
self.driver.quit()
- """创建部落"""
-
def test_create_club(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.create_club('部落')
# 创建过程太慢,需要多等一会
@@ -46,7 +43,6 @@ def test_create_club(self):
def test_share_club_to_club(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.share_club_to_club()
sleep(1)
@@ -59,7 +55,6 @@ def test_share_club_to_club(self):
def test_share_club_to_contact(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.share_club_to_contact('204')
sleep(1)
@@ -72,7 +67,6 @@ def test_share_club_to_contact(self):
def test_share_club_to_group_chart(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.share_club_to_group_chat('2')
sleep(1)
@@ -85,7 +79,6 @@ def test_share_club_to_group_chart(self):
def test_send_community(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.send_community('这是动态标题', '这是动态内容')
sleep(2)
@@ -98,7 +91,6 @@ def test_send_community(self):
def test_add_chart_room(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.add_chat_room('聊天房间')
sleep(2)
@@ -110,7 +102,6 @@ def test_add_chart_room(self):
def test_add_dapp_room(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.add_dapp_room('应用房间',
'https://www.baidu.com/s?wd=%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95&rsv_spt=1&rsv_iqid=0x9058a494003119fd&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_dl=tb&rsv_enter=1&rsv_sug3=38&rsv_sug1=36&rsv_sug7=100&rsv_sug2=0&rsv_btype=i&prefixsug=%25E8%2587%25AA%25E5%258A%25A8%25E5%258C%2596%25E6%25B5%258B%25E8%25AF%2595&rsp=5&inputT=12351&rsv_sug4=15729',
@@ -123,11 +114,9 @@ def test_add_dapp_room(self):
print(e)
self.teardown()
- '''聊天房间发布公告'''
def test_chart_room_announce(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.chart_room_announce('欢迎来到聊天房间')
sleep(2)
@@ -140,7 +129,6 @@ def test_chart_room_announce(self):
def test_all_shutup1(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.all_shutup()
ass = AppAssertPage(driver=self.driver)
@@ -152,7 +140,6 @@ def test_all_shutup1(self):
def test_all_shutup2(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.all_shutup()
ass = AppAssertPage(driver=self.driver)
@@ -164,7 +151,6 @@ def test_all_shutup2(self):
def test_message_disturb(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.message_disturb()
ass = AppAssertPage(driver=self.driver)
@@ -176,7 +162,6 @@ def test_message_disturb(self):
def test_clear_message(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.clear_message()
ass = AppAssertPage(driver=self.driver)
@@ -188,7 +173,6 @@ def test_clear_message(self):
def test_delete_room(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.delete_room()
sleep(2)
@@ -201,7 +185,6 @@ def test_delete_room(self):
def test_bing_wallet(self):
self.tset_up()
-
club_step = ClubStep(self.driver)
club_step.bing_wallet()
# 创建钱包后加载较慢
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..b56c695
--- /dev/null
+++ b/main.py
@@ -0,0 +1,16 @@
+# 这是一个示例 Python 脚本。
+
+# 按 ⌃R 执行或将其替换为您的代码。
+# 按 双击 ⇧ 在所有地方搜索类、文件、工具窗口、操作和设置。
+
+
+def print_hi(name):
+ # 在下面的代码行中使用断点来调试脚本。
+ print(f'Hi, {name}') # 按 ⌘F8 切换断点。
+
+
+# 按装订区域中的绿色按钮以运行脚本。
+if __name__ == '__main__':
+ print_hi('PyCharm')
+
+# 访问 https://www.jetbrains.com/help/pycharm/ 获取 PyCharm 帮助
From 0196c1d4724bebfb3c98bc0dfb3028ec100612f3 Mon Sep 17 00:00:00 2001
From: gdlooker
Date: Wed, 21 May 2025 17:22:08 +0800
Subject: [PATCH 08/11] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96appium?=
=?UTF-8?q?=E5=B0=81=E8=A3=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
TestCase/redpacket/test_redpacket.py | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/TestCase/redpacket/test_redpacket.py b/TestCase/redpacket/test_redpacket.py
index 1383da1..5b59b1d 100644
--- a/TestCase/redpacket/test_redpacket.py
+++ b/TestCase/redpacket/test_redpacket.py
@@ -12,23 +12,23 @@
class TestRedPacket:
- '''发红包用例'''
+ def set_up(self):
+ # 回到根目录
+ rootpath = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
+ # yaml文件的绝对路径
+ path = os.path.join(rootpath, 'config/config.yaml')
+ # 拿到数据
+ data = readYaml(path)
+ # 连接Appium Server,初始化自动化环境
+ self.driver = webdriver.Remote('http://localhost:4723/wd/hub', data['ios_caps'])
+
+ def teardown(self):
+ self.driver.quit()
'''单聊发红包'''
- def test_redpacket(self, start_app):
- self.driver = start_app
- step = RedPacketStep(self.driver)
- step.create_redpacket1("0.01", "单聊自动化脚本红包", "111111")
- ass = AppAssertPage(self.driver)
- el = '单聊自动化脚本红包'
- sleep(1)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, '没有找到红包元素,测试失败'
-
- '''密码错误,发红包提示'''
-
- def test_redpacket_fail(self, start_app):
- self.driver = start_app
+ def test_redpacket(self):
+ self.set_up()
step = RedPacketStep(self.driver)
step.create_redpacket1("0.01", "", "111122")
ass = AppAssertPage(self.driver)
From 6381807b3cbe2bcb631a24b457d744a9c17721e5 Mon Sep 17 00:00:00 2001
From: gdlooker
Date: Sat, 24 May 2025 16:49:08 +0800
Subject: [PATCH 09/11] =?UTF-8?q?=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
PageObjct/element_page/IM_page.py | 57 ++++++-
PageObjct/element_page/club_page.py | 1 +
PageObjct/element_page/login_page.py | 67 ++-------
PageObjct/operation_page/IM_step.py | 98 +++++++++++-
PageObjct/operation_page/RedPacket_step.py | 130 ++++++++++++----
PageObjct/operation_page/club_step.py | 12 +-
PageObjct/operation_page/login_step.py | 90 ++++++++++++
TestCase/IM/__init__.py | 0
TestCase/IM/test_IM.py | 51 -------
TestCase/__init__.py | 6 -
TestCase/club/__init__.py | 0
TestCase/login/__init__.py | 0
TestCase/login/test_login.py | 56 -------
TestCase/redpacket/__init__.py | 0
TestCase/redpacket/test_redpacket.py | 92 ------------
TestCase/test_IM.py | 139 ++++++++++++++++++
.../{club/test_creat_club.py => test_club.py} | 19 ++-
TestCase/test_login.py | 78 ++++++++++
TestCase/test_redpacket.py | 106 +++++++++++++
19 files changed, 699 insertions(+), 303 deletions(-)
create mode 100644 PageObjct/operation_page/login_step.py
delete mode 100644 TestCase/IM/__init__.py
delete mode 100644 TestCase/IM/test_IM.py
delete mode 100644 TestCase/club/__init__.py
delete mode 100644 TestCase/login/__init__.py
delete mode 100644 TestCase/login/test_login.py
delete mode 100644 TestCase/redpacket/__init__.py
delete mode 100644 TestCase/redpacket/test_redpacket.py
create mode 100644 TestCase/test_IM.py
rename TestCase/{club/test_creat_club.py => test_club.py} (98%)
create mode 100644 TestCase/test_login.py
create mode 100644 TestCase/test_redpacket.py
diff --git a/PageObjct/element_page/IM_page.py b/PageObjct/element_page/IM_page.py
index fb84128..e1e31b5 100644
--- a/PageObjct/element_page/IM_page.py
+++ b/PageObjct/element_page/IM_page.py
@@ -5,8 +5,23 @@
class IMPage(BasePage):
- # 底部消息table
+ '''消息tab'''
+ # 底部“消息”table
el_message_icon = (MobileBy.ACCESSIBILITY_ID, 'message_unselected_icon_light')
+ # +号
+ el_add = (MobileBy.ACCESSIBILITY_ID, 'navigation add x24')
+ # 发起群聊
+ el_create_group = (MobileBy.ACCESSIBILITY_ID, '发起群聊')
+ # 通讯录搜索
+ el_address_search = (MobileBy.CLASS_NAME, 'XCUIElementTypeTextField')
+ # 键盘上的”搜索“按钮
+ el_search_keyboard = (MobileBy.ACCESSIBILITY_ID, 'Search')
+ # 好友203
+ el_friend_203 = MobileBy.ACCESSIBILITY_ID, '好友成203(203)'
+ # 好友202
+ el_friend_202 = MobileBy.ACCESSIBILITY_ID, 'new202'
+ # 群聊“1111”
+ el_group_1111 = MobileBy.ACCESSIBILITY_ID, '1111'
'''通讯录'''
# 通讯录
el_address_book = (MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="通讯录"]')
@@ -18,9 +33,9 @@ class IMPage(BasePage):
# 我的群聊
el_group_chart_list = (MobileBy.XPATH,
'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]/XCUIElementTypeButton[2]')
- # 第一个群聊
- el_choose_group_first = (MobileBy.XPATH,
- '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]')
+ # 群聊"1111"
+ el_choose_group_1111 = (MobileBy.ACCESSIBILITY_ID,'1111')
+
'''聊天室'''
# 消息输入框
el_input_IM = (MobileBy.XPATH,
@@ -28,7 +43,7 @@ class IMPage(BasePage):
# 发送消息按钮
el_send_message = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="chat send message light"]')
# +号更多按钮
- el_IM_more = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="chat more light"]')
+ el_IM_more = (By.XPATH, '//XCUIElementTypeButton[@name="chat more light"]')
# 相册
el_photo_choose = (MobileBy.ACCESSIBILITY_ID, 'chat_more_album_light')
# 拍照
@@ -44,9 +59,13 @@ class IMPage(BasePage):
# 文件
el_document = (MobileBy.ACCESSIBILITY_ID, 'chat_more_document_light')
# 选择图片
+ el_picture_choose = (MobileBy.XPATH,
+ '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[4]/XCUIElementTypeOther/XCUIElementTypeButton')
# 发送图片
el_send_picture = (MobileBy.ACCESSIBILITY_ID, '发送(1)')
# 选择视频
+ el_video_choice = (MobileBy.XPATH,
+ '(//XCUIElementTypeImage[@name="/var/containers/Bundle/Application/7024A092-04C5-4391-8650-52A234FC16EB/Zapry.app/TZImagePickerController.bundle/photo_def_photoPickerVc@2x.png"])[2]')
'''发红包'''
# 绑定钱包弹窗-立即设置
@@ -89,4 +108,30 @@ class IMPage(BasePage):
el_input_pwd = (By.XPATH,
'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther[1]/XCUIElementTypeSecureTextField')
'''领红包'''
- # 选择自动化红包
+ # 单聊自动化ALG红包
+ el_solo_ALG = MobileBy.ACCESSIBILITY_ID,'单聊自动化ALG红包'
+ # 单聊自动化CIQI红包
+ el_solo_CIQI = MobileBy.ACCESSIBILITY_ID,'单聊自动化CIQI红包'
+ # 群聊自动化CIQI拼手气红包
+ el_group_lucky_CIQI = MobileBy.ACCESSIBILITY_ID, '群聊自动化CIQI拼手气红包'
+ # 群聊自动化ALG普通红包
+ el_group_common_ALG = MobileBy.ACCESSIBILITY_ID, '群聊自动化ALG普通红包'
+ # 频道自动化ALG拼手气红包
+ el_channel_lucky_ALG = MobileBy.ACCESSIBILITY_ID, '频道自动化ALG拼手气红包'
+ # 频道自动化CIQI普通红包
+ el_channel_common_CIQI = MobileBy.ACCESSIBILITY_ID, '频道自动化CIQI普通红包'
+ # 开红包
+ el_open_red_package = MobileBy.ACCESSIBILITY_ID,'red_bag_open_button'
+
+ '''单聊设置'''
+ # 进入聊天设置
+ el_chart_setting = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="chat setting light"]')
+ # 拉好友建群
+ el_chart_setting_add = (MobileBy.ACCESSIBILITY_ID,'chat setting add')
+ # 建群选择第一个好友
+ el_add_first = (MobileBy.XPATH,'(//XCUIElementTypeButton[@name="group user unselect"])[1]')
+ # 建群选择第二个好友
+ el_add_second = (MobileBy.ACCESSIBILITY_ID, '(//XCUIElementTypeButton[@name="group user unselect"])[2]')
+ # 确认建群
+ el_add_done1 = (MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="完成(1/9)"]')
+ el_add_done2 = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="完成(2/9)"]')
\ No newline at end of file
diff --git a/PageObjct/element_page/club_page.py b/PageObjct/element_page/club_page.py
index d7fa718..4ab80ca 100644
--- a/PageObjct/element_page/club_page.py
+++ b/PageObjct/element_page/club_page.py
@@ -118,6 +118,7 @@ class ClubPage(BasePage):
el_group_search = (MobileBy.XPATH,
'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeTextField[2]')
# 选择第一个群聊
+ el_share_group_first = (MobileBy.XPATH,
'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable[2]/XCUIElementTypeCell[1]')
# 点击确认
el_group_confirm = (MobileBy.XPATH, '//XCUIElementTypeButton[@name="确认(1/9)"]')
diff --git a/PageObjct/element_page/login_page.py b/PageObjct/element_page/login_page.py
index aa1884b..e10004c 100644
--- a/PageObjct/element_page/login_page.py
+++ b/PageObjct/element_page/login_page.py
@@ -39,62 +39,13 @@ class LoginPage(BasePage):
el_pname = (MobileBy.CLASS_NAME,'XCUIElementTypeTextField')
#点击完成
el_done = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="完成"]')
+ '''我的tab'''
+ # 底部“我的”tab
+ el_my = MobileBy.ACCESSIBILITY_ID, 'mine_unselected_icon_light'
+ # 退出登录
+ el_logout = MobileBy.XPATH, '(//XCUIElementTypeButton[@name="退出登录"])[2]'
+ # 退出登录二次确认
+ el_popup_logout_yes = MobileBy.XPATH, '//XCUIElementTypeButton[@name="确定"]'
+ # 登录其他账号
+ el_login_another = MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="登录其他账号"]'
-
- #登录步骤
- def login1(self,username,password):
- #切换到账户登录
- self.click(self.el_account)
- #输入账号
- self.input(self.el_username,username)
- #点击登录测试环境(下一步)
- self.click(self.el_login)
- #输入密码
- self.input(self.el_password,password)
- #点击登录
- self.click(self.el_login)
- sleep(2)
-
- #一键注册
- def single(self):
- #点击一键注册
- self.click(self.el_single)
- # 点击跳过
- self.click(self.el_skip2)
- # 点击我知道了
- self.click(self.el_know)
-
-
- #注册步骤
- def login2(self,username,password,name):
- # 切换到账户登录
- self.click(self.el_account)
- # 输入账号
- self.input(self.el_username, username)
- # 点击登录测试环境(下一步)
- self.click(self.el_login)
- # 输入密码
- self.input(self.el_password, password)
- # 点击登录
- self.click(self.el_nex)
- #输入用户名
- self.input(self.el_pname,name)
- # 点击设置头像
- self.click(self.el_heads)
- # 选择照片
- self.click(self.el_photo)
- # 点击完成
- self.click(self.el_done1)
- # 太快了找不到元素
- sleep(1)
- # 裁剪完成
- self.click(self.el_tailor)
- #点击完成
- self.click(self.el_done)
- # 点击全选部落按钮
- self.click(self.el_all)
- # 点击进入部落
- self.click(self.el_join)
- sleep(1)
- # 点击我知道了
- self.click(self.el_know)
\ No newline at end of file
diff --git a/PageObjct/operation_page/IM_step.py b/PageObjct/operation_page/IM_step.py
index 0c1320d..19bef6b 100644
--- a/PageObjct/operation_page/IM_step.py
+++ b/PageObjct/operation_page/IM_step.py
@@ -115,4 +115,100 @@ def IM_solo_video(self):
# 选择第2个视频
self.click(self.el_video_choice)
# 点击发送
- self.click(self.el_send_picture)
\ No newline at end of file
+ self.click(self.el_send_picture)
+
+ '''群聊发消息'''
+
+ def IM_group_message(self, message):
+ # 去消息tab
+ self.click(self.el_message_icon)
+ # 点击通讯录
+ self.click(self.el_address_book)
+ # 点击我的群聊
+ self.click(self.el_group_chart_list)
+ # 选择第1个群聊
+ self.click(self.el_choose_group_first)
+ # 输入框输入消息
+ self.input(self.el_input_IM, message)
+ # 点击发送
+ self.click(self.el_send_message)
+
+ '''群聊发图片'''
+
+ def IM_group_picture(self):
+ # 去消息tab
+ self.click(self.el_message_icon)
+ # 点击通讯录
+ self.click(self.el_address_book)
+ # 点击我的群聊
+ self.click(self.el_group_chart_list)
+ # 选择第1个群聊
+ self.click(self.el_choose_group_first)
+ # 点开更多面板
+ self.click(self.el_IM_more)
+ # 进入相册
+ self.click(self.el_photo_choose)
+ # 上滑两次确保到了相册顶部
+ self.down_slide()
+ self.down_slide()
+ self.driver.implicitly_wait(10)
+ # 选择第4张图片
+ self.click(self.el_picture_choose)
+ # 点击发送
+ self.click(self.el_send_picture)
+
+ '''群聊发视频'''
+
+ def IM_group_video(self):
+ # 去消息tab
+ self.click(self.el_message_icon)
+ # 点击通讯录
+ self.click(self.el_address_book)
+ # 点击我的群聊
+ self.click(self.el_group_chart_list)
+ # 选择第1个群聊
+ self.click(self.el_choose_group_first)
+ # 点开更多面板
+ self.click(self.el_IM_more)
+ # 进入相册
+ self.click(self.el_photo_choose)
+ # 上滑两次确保到了相册顶部
+ self.down_slide()
+ self.down_slide()
+ self.driver.implicitly_wait(10)
+ # 选择第2个视频
+ self.click(self.el_video_choice)
+ # 点击发送
+ self.click(self.el_send_picture)
+
+ '''拉人建群'''
+ def creat_group1(self):
+ # 去消息tab
+ self.click(self.el_message_icon)
+ # 点击通讯录
+ self.click(self.el_address_book)
+ # 选择第六个好友
+ self.click(self.el_choose_friend_six)
+ # 进入聊天设置
+ self.click(self.el_chart_setting)
+ # 点击拉人创群
+ self.click(self.el_chart_setting_add)
+ # 拉人界面选择第一个好友
+ self.click(self.el_add_first)
+ # 点击确定
+ self.click(self.el_add_done1)
+
+ '''选人创建群聊'''
+ def creat_group2(self):
+ # 点击消息tab
+ self.click(self.el_message_icon)
+ # 点击+号
+ self.click(self.el_add)
+ # 点击发起群聊
+ self.click(self.el_create_group)
+ # 选择第一个好友
+ self.click(self.el_add_first)
+ # 选择第二个好友
+ self.click(self.el_add_second)
+ # 点击完成
+ self.click(self.el_add_done2)
diff --git a/PageObjct/operation_page/RedPacket_step.py b/PageObjct/operation_page/RedPacket_step.py
index ee0db64..2f4fb43 100644
--- a/PageObjct/operation_page/RedPacket_step.py
+++ b/PageObjct/operation_page/RedPacket_step.py
@@ -1,5 +1,8 @@
+from re import search
+
from appium.webdriver.common.mobileby import MobileBy
from selenium.common import ElementNotInteractableException, NoSuchElementException
+from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
@@ -41,19 +44,18 @@ def find_club(self):
- '''单聊创建红包'''
+ '''单聊发ALG红包'''
- def create_redpacket1(self, sum, remark, pwd):
+ def create_redpacket_alg(self, text, sum, remark, pwd):
# 去消息tab
self.click(self.el_message_icon)
- # 切换到通讯录
- self.click(self.el_address_book)
- # 选择第6个好友
- WebDriverWait(self.driver, 10).until(
- expected_conditions.element_to_be_clickable((By.XPATH,
- '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[7]')))
- self.click(self.el_choose_friend_six)
+ # 搜索好友
+ self.input(self.el_address_search,text)
+ self.click(self.el_address_search)
+ self.click(self.el_search_keyboard)
+ # 选择好友203
+ self.click(self.el_friend_203)
# 聊天室点击+按钮
self.click(self.el_IM_more)
# 点击红包
@@ -83,6 +85,10 @@ def create_redpacket1(self, sum, remark, pwd):
else:
pass
+ # 点击下拉icon
+ self.click(self.el_choose_coin)
+ # 代币列表浮层中选择ALG币
+ self.click(self.el_choose_ALG)
# 输入金额
self.input(self.el_solo_sum, sum)
# 输入备注
@@ -94,7 +100,7 @@ def create_redpacket1(self, sum, remark, pwd):
'''切换CIQI币发红包'''
- def create_redpacket2(self, sum, remark, pwd):
+ def receive_solo_ciqi(self, sum, remark, pwd):
# 点击消息tab
self.click(self.el_message_icon)
@@ -103,6 +109,7 @@ def create_redpacket2(self, sum, remark, pwd):
# 加载好友列表,点击第六个好友进入聊天室
WebDriverWait(self.driver, 10).until(expected_conditions.element_to_be_clickable((By.XPATH,
'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[7]')))
+ self.click(self.el_choose_friend_six)
# 聊天室中点击右下角的+号按钮
self.click(self.el_IM_more)
# 点击红包
@@ -120,76 +127,143 @@ def create_redpacket2(self, sum, remark, pwd):
# 输入密码
self.input(self.el_input_pwd, pwd)
- '''群聊发红包'''
+ '''群聊发CIQI拼手气红包'''
def create_group_redpacket1(self, number, sum, remark, pwd):
-
+ # 点击“消息”tab
self.click(self.el_message_icon)
+ # 点击“通讯录”
self.click(self.el_address_book)
+ # 进入“我的群聊列表”
self.click(self.el_group_chart_list)
- self.click(self.el_choose_group_first)
+ # 选择群聊"1111"
+ self.click(self.el_choose_group_1111)
+ # 点击“+”
self.click(self.el_IM_more)
+ # 点击“红包”
self.click(self.el_red_packet)
+ # 选择红包类型
+ self.click(self.el_choose_redpacket_type)
+ # 选择拼手气红包
+ self.click(self.el_luck_redpacket)
+ # 点击下拉icon
+ self.click(self.el_choose_coin)
+ # 代币列表浮层中选择CIQI币
+ self.click(self.el_choose_CIQI)
+ # 输入红包数量
self.input(self.el_group_number, number)
+ # 输入红包金额
self.input(self.el_solo_sum, sum)
+ # 输入红包备注
self.input(self.el_solo_remark, remark)
+ # 点击创建红包
self.click(self.el_create_redpacket)
+ # 输入支付密码
self.input(self.el_input_pwd, pwd)
'''群聊发ALG普通红包'''
def create_group_redpacket2(self, number, sum, remark, pwd):
-
- self.click(self.el_message_icon)
- self.click(self.el_address_book)
+ # 点击“消息”tab
self.click(self.el_message_icon)
+ # 点击“通讯录”
self.click(self.el_address_book)
+ # 进入“我的群聊列表”
self.click(self.el_group_chart_list)
- self.click(self.el_choose_group_first)
+ # 选择群聊"1111"
+ self.click(self.el_choose_group_1111)
+ # 点击“+”
self.click(self.el_IM_more)
+ # 点击“红包”
self.click(self.el_red_packet)
+ # 选择红包类型
self.click(self.el_choose_redpacket_type)
+ # 选择普通红包
self.click(self.el_common_redpacket)
- self.input(self.el_group_number, number)
+ # 点击下拉icon
self.click(self.el_choose_coin)
- self.click(self.el_choose_ALG)
+ # 代币列表浮层中选择CIQI币
+ self.click(self.el_choose_CIQI)
+ # 输入红包数量
+ self.input(self.el_group_number, number)
+ # 输入红包金额
self.input(self.el_solo_sum, sum)
+ # 输入红包备注
self.input(self.el_solo_remark, remark)
+ # 点击创建红包
self.click(self.el_create_redpacket)
+ # 输入支付密码
self.input(self.el_input_pwd, pwd)
- '''频道发红包'''
+ '''频道发ALG拼手气红包'''
def create_channel_redpacket1(self, number, sum, remark, pwd):
-
- self.click(self.el_club1)
+ # 选择“新赛季”部落
+ self.find_club()
+ # 选择“日常聊天”房间
self.click(self.el_choose_chart_room)
+ # 点击“+”
self.click(self.el_IM_more)
+ # 点击“红包”
self.click(self.el_red_packet)
+ # 选择红包类型
+ self.click(self.el_choose_redpacket_type)
+ # 选择拼手气红包
+ self.click(self.el_luck_redpacket)
+ # 点击下拉icon
+ self.click(self.el_choose_coin)
+ # 代币列表浮层中选择ALG币
+ self.click(self.el_choose_ALG)
+ # 输入红包数量
self.input(self.el_channel_number, number)
+ # 输入红包金额
self.input(self.el_solo_sum, sum)
+ # 输入红包备注
self.input(self.el_solo_remark, remark)
+ # 创建红包
self.click(self.el_create_redpacket)
+ # 输入支付密码
self.input(self.el_input_pwd, pwd)
'''频道发CIQI普通红包'''
def create_channel_redpacket2(self, number, sum, remark, pwd):
+ # 选择“新赛季”部落
self.find_club()
+ # 选择“日常聊天”房间
self.click(self.el_choose_chart_room)
+ # 点击“+”
self.click(self.el_IM_more)
+ # 点击“红包”
self.click(self.el_red_packet)
+ # 选择红包类型
self.click(self.el_choose_redpacket_type)
+ # 选择拼手气红包
self.click(self.el_common_redpacket)
- self.input(self.el_channel_number, number)
+ # 点击下拉icon
self.click(self.el_choose_coin)
+ # 代币列表浮层中选择CIQI币
self.click(self.el_choose_CIQI)
- self.input(self.el_channel_sum, sum)
- self.input(self.el_channel_remark, remark)
+ # 输入红包数量
+ self.input(self.el_channel_number, number)
+ # 输入红包金额
+ self.input(self.el_solo_sum, sum)
+ # 输入红包备注
+ self.input(self.el_solo_remark, remark)
+ # 创建红包
self.click(self.el_create_redpacket)
+ # 输入支付密码
self.input(self.el_input_pwd, pwd)
- '''领红包'''
- def receive_redpacket(self):
- self.click(self.el_red_packet)
+ '''单聊领红包'''
+ def receive_solo_alg(self):
+ # 点击底部“消息”tab
+ self.click(self.el_message_icon)
+ # 进入与好友202的聊天室
+ self.click(self.el_friend_202)
+ # 选择ALG红包
+ self.click(self.el_solo_ALG)
+ # 点击开红包
+ self.click(self.el_open_red_package)
+
diff --git a/PageObjct/operation_page/club_step.py b/PageObjct/operation_page/club_step.py
index 5418043..c23605a 100644
--- a/PageObjct/operation_page/club_step.py
+++ b/PageObjct/operation_page/club_step.py
@@ -1,13 +1,16 @@
-from logging import exception
+
from time import sleep
from PageObjct.element_page.IM_page import IMPage
from PageObjct.element_page.club_page import ClubPage
-from common.wait_util import WaitPage
+
class ClubStep(ClubPage, IMPage):
- """创建部落"""
+ """创建部落"""
+
+ def create_club(self, name):
+
# 点击icon
self.click(self.el_icon)
# 点击卡片
@@ -91,6 +94,7 @@ def share_club_to_group_chat(self, group_name):
self.input(self.el_group_search, group_name)
sleep(1)
# 选择第一个群聊
+ self.click(self.el_share_group_first)
sleep(1)
# 点击确认
self.click(self.el_group_confirm)
@@ -141,7 +145,7 @@ def add_dapp_room(self, dapp_room, dapp_link, dapp_text):
self.click(self.el_dapp_done)
# self.swipe(123,123,432,422)
- '''发布房间公告'''
+ '''发布房间公告'''
def chart_room_announce(self, text):
# 选择侧边栏第一个部落
diff --git a/PageObjct/operation_page/login_step.py b/PageObjct/operation_page/login_step.py
new file mode 100644
index 0000000..0d2d508
--- /dev/null
+++ b/PageObjct/operation_page/login_step.py
@@ -0,0 +1,90 @@
+from appium.webdriver.common.mobileby import MobileBy
+
+from PageObjct.element_page.login_page import LoginPage
+from time import sleep
+
+class LoginStep(LoginPage):
+
+ '''登录步骤'''
+
+ def login1(self, username, password):
+ # 切换到账户登录
+ self.click(self.el_account)
+ # 输入账号
+ self.input(self.el_username, username)
+ # 点击登录测试环境(下一步)
+ self.click(self.el_login)
+ # 输入密码
+ self.input(self.el_password, password)
+ # 点击登录
+ self.click(self.el_login)
+ sleep(2)
+
+ '''一键注册'''
+
+ def single(self):
+ # 点击一键注册
+ self.click(self.el_single)
+ # 点击跳过
+ self.click(self.el_skip2)
+ # 点击我知道了
+ self.click(self.el_know)
+
+ '''注册步骤'''
+
+ def login2(self, username, password, name):
+ # 切换到账户登录
+ self.click(self.el_account)
+ # 输入账号
+ self.input(self.el_username, username)
+ # 点击登录测试环境(下一步)
+ self.click(self.el_login)
+ # 输入密码
+ self.input(self.el_password, password)
+ # 点击登录
+ self.click(self.el_nex)
+ # 输入用户名
+ self.input(self.el_pname, name)
+ # 点击设置头像
+ self.click(self.el_heads)
+ # 选择照片
+ self.click(self.el_photo)
+ # 点击完成
+ self.click(self.el_done1)
+ # 太快了找不到元素
+ sleep(1)
+ # 裁剪完成
+ self.click(self.el_tailor)
+ # 点击完成
+ self.click(self.el_done)
+ # 点击全选部落按钮
+ self.click(self.el_all)
+ # 点击进入部落
+ self.click(self.el_join)
+ sleep(1)
+ # 点击我知道了
+ self.click(self.el_know)
+
+ '''退出登录'''
+
+ def logout(self):
+ # 点击“我的”tab
+ self.click(self.el_my)
+ # 点击退出登录
+ self.click(self.el_logout)
+ # 二次确认弹窗点击确认
+ self.click(self.el_popup_logout_yes)
+ # 切换其他账号登录
+ self.click(self.el_login_another)
+
+ def switch_account_203(self):
+ go_back = MobileBy.ACCESSIBILITY_ID,'返回'
+ self.click(go_back)
+ self.logout()
+ self.login1('new203', 'Sta12345')
+
+ def switch_account_202(self):
+ go_back = MobileBy.ACCESSIBILITY_ID, '返回'
+ self.click(go_back)
+ self.logout()
+ self.login1('new202', 'Sta12345')
\ No newline at end of file
diff --git a/TestCase/IM/__init__.py b/TestCase/IM/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/TestCase/IM/test_IM.py b/TestCase/IM/test_IM.py
deleted file mode 100644
index eeddef9..0000000
--- a/TestCase/IM/test_IM.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from time import sleep
-
-from appium.webdriver.common.mobileby import MobileBy
-
-from Base.app_assert_page import AppAssertPage
-from PageObjct.operation_page.IM_step import IMStep
-from common.start_app import start_app
-
-
-class TestIM:
- """频道发消息"""
- def test_IM_channel_message(self,start_app):
- self.driver = start_app
-
- club_step = IMStep(self.driver)
- club_step.IM_channel_message('频道自动化消息')
-
- ass = AppAssertPage(driver=self.driver)
- el = "频道自动化消息"
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID,el) == True
-
- '''在频道发图片'''
- def test_IM_channel_picture(self,start_app):
- self.driver = start_app
-
- club_step = IMStep(self.driver)
- club_step.IM_channel_picture()
- # 多等一会让图片发送成功
- sleep(2)
- ass = AppAssertPage(driver=self.driver)
- # 被检查的元素
- el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
-
- '''在频道发视频'''
- def test_IM_channel_video(self,start_app):
- self.driver = start_app
-
- club_step = IMStep(self.driver)
- club_step.IM_channel_video()
- sleep(2)
- ass = AppAssertPage(driver=self.driver)
- # 被检查的元素
- el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
-
- '''单聊发消息'''
- def test_IM_solo_message(self,start_app):
- self.driver = start_app
- step = IMStep(self.driver)
- step.IM_solo_message("自动化单聊消息")
diff --git a/TestCase/__init__.py b/TestCase/__init__.py
index d837360..e69de29 100644
--- a/TestCase/__init__.py
+++ b/TestCase/__init__.py
@@ -1,6 +0,0 @@
-import pytest
-
-
-
-if __name__ == '__main__':
- pytest.main()
\ No newline at end of file
diff --git a/TestCase/club/__init__.py b/TestCase/club/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/TestCase/login/__init__.py b/TestCase/login/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/TestCase/login/test_login.py b/TestCase/login/test_login.py
deleted file mode 100644
index da3aca6..0000000
--- a/TestCase/login/test_login.py
+++ /dev/null
@@ -1,56 +0,0 @@
-import os
-import secrets
-from time import sleep
-
-from appium import webdriver
-from appium.webdriver.common.mobileby import MobileBy
-
-from Base.app_assert_page import AppAssertPage
-from PageObjct.element_page.login_page import LoginPage
-from common.data_util import readYaml
-
-
-class TestLogin:
-
- def setup(self):
- # 回到根目录
- rootpath = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
- # yaml文件的绝对路径
- path = os.path.join(rootpath, 'config/config.yaml')
- # 拿到数据
- data = readYaml(path)
- # 连接Appium Server,初始化自动化环境
- self.driver = webdriver.Remote('http://localhost:4723/wd/hub', data['ios_caps'])
-
- def teardown(self):
- self.driver.quit()
-
- # @pytest.mark.parametrize('username,password', readYaml('../config/config.yaml'))
- def test_login1(self):
- login_page = LoginPage(driver=self.driver)
- '''账号登录'''
- login_page.login1('new203', 'Sta12345')
- sleep(1)
- ass = AppAssertPage(driver=self.driver)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, 'tribe_add_light') == True
-
- def test_login2(self):
- login_page = LoginPage(driver=self.driver)
- '''新用户注册'''
- # 生成一个随机的令牌,例如用于安全令牌或密码
- token = secrets.token_hex(2) # 生成一个2字节的十六进制字符串,4位
- data = 'new'
- ddname = data + token
- login_page.login2(ddname, 'Sta12345', '新注册用户')
- sleep(1)
- # 断言
- ass = AppAssertPage(driver=self.driver)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, '参与共建热门部落') == True
-
- def test_single(self):
- login_page = LoginPage(driver=self.driver)
- '''一键注册'''
- login_page.single()
- sleep(1)
- ass = AppAssertPage(driver=self.driver)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, '参与共建热门部落') == True
diff --git a/TestCase/redpacket/__init__.py b/TestCase/redpacket/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/TestCase/redpacket/test_redpacket.py b/TestCase/redpacket/test_redpacket.py
deleted file mode 100644
index 5b59b1d..0000000
--- a/TestCase/redpacket/test_redpacket.py
+++ /dev/null
@@ -1,92 +0,0 @@
-import os
-from time import sleep
-import pytest_check as check
-import pytest
-from appium import webdriver
-from appium.webdriver.common.mobileby import MobileBy
-from selenium.webdriver.common.by import By
-from Base.app_assert_page import AppAssertPage
-from PageObjct.operation_page.RedPacket_step import RedPacketStep
-from common.data_util import readYaml
-from common.start_app import start_app
-
-
-class TestRedPacket:
- def set_up(self):
- # 回到根目录
- rootpath = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
- # yaml文件的绝对路径
- path = os.path.join(rootpath, 'config/config.yaml')
- # 拿到数据
- data = readYaml(path)
- # 连接Appium Server,初始化自动化环境
- self.driver = webdriver.Remote('http://localhost:4723/wd/hub', data['ios_caps'])
-
- def teardown(self):
- self.driver.quit()
-
- '''单聊发红包'''
-
- def test_redpacket(self):
- self.set_up()
- step = RedPacketStep(self.driver)
- step.create_redpacket1("0.01", "", "111122")
- ass = AppAssertPage(self.driver)
- el = '验证失败'
- sleep(1)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, '缺少错误提示'
-
- '''单聊切币发红包'''
-
- def test_redpacket2(self, start_app):
- self.driver = start_app
- step = RedPacketStep(self.driver)
- step.create_redpacket2("0.01", "CIQI自动化红包", "111111")
- ass = AppAssertPage(self.driver)
- el = 'CIQI自动化红包'
- sleep(1)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, ''
-
- '''群聊发红包'''
-
- def test_group_redpacket(self, start_app):
- self.driver = start_app
- step = RedPacketStep(self.driver)
- step.create_group_redpacket1('3', '0.04', '群聊自动化红包', '111111')
- ass = AppAssertPage(self.driver)
- el = '群聊自动化红包'
- sleep(1)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, '测试失败,未找到元素'
-
- '''群聊发ALG普通红包'''
-
- def test_group_redpacket2(self, start_app):
- self.driver = start_app
- step = RedPacketStep(self.driver)
- step.create_group_redpacket2('3', '0.03', '群聊ALG自动化红包', '111111')
- ass = AppAssertPage(self.driver)
- el = '群聊ALG自动化红包'
- sleep(1)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, ''
-
- '''频道发红包'''
-
- def test_channel_redpacket(self, start_app):
- self.driver = start_app
- step = RedPacketStep(self.driver)
- step.create_channel_redpacket1('3', '0.04', '频道自动化红包', '111111')
- ass = AppAssertPage(self.driver)
- el = '频道自动化红包'
- sleep(1)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, ''
-
- '''频道发CIQI普通红包'''
-
- def test_channel_redpacket2(self, start_app):
- self.driver = start_app
- step = RedPacketStep(self.driver)
- step.create_channel_redpacket2('3', '0.03', '频道CIQI自动化红包', '111111')
- ass = AppAssertPage(self.driver)
- el = '频道CIQI自动化红包'
- sleep(1)
- check.is_true(ass.is_element_enabled(MobileBy.ACCESSIBILITY_ID, el) == True), f'元素{el}应该可见但未找到'
diff --git a/TestCase/test_IM.py b/TestCase/test_IM.py
new file mode 100644
index 0000000..57ddb09
--- /dev/null
+++ b/TestCase/test_IM.py
@@ -0,0 +1,139 @@
+from time import sleep
+
+from appium.webdriver.common.mobileby import MobileBy
+
+from Base.app_assert_page import AppAssertPage
+from PageObjct.operation_page.IM_step import IMStep
+from common.start_app import start_app
+
+class TestIM:
+ """频道发消息"""
+ def test_im_channel_message(self,start_app):
+ self.driver = start_app
+
+ club_step = IMStep(self.driver)
+ club_step.IM_channel_message('频道自动化消息')
+
+ ass = AppAssertPage(self.driver)
+ el = "频道自动化消息"
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID,el) == True
+
+ '''在频道发图片'''
+ def test_im_channel_picture(self,start_app):
+ self.driver = start_app
+
+ club_step = IMStep(self.driver)
+ club_step.IM_channel_picture()
+ # 多等一会让图片发送成功
+ sleep(2)
+ ass = AppAssertPage(self.driver)
+ # 被检查的元素
+ el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+
+ '''在频道发视频'''
+ def test_im_channel_video(self,start_app):
+ self.driver = start_app
+
+ club_step = IMStep(self.driver)
+ club_step.IM_channel_video()
+ sleep(2)
+ ass = AppAssertPage(self.driver)
+ # 被检查的元素
+ el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+
+ '''单聊发消息'''
+ def test_im_solo_message(self,start_app):
+ self.driver = start_app
+ step = IMStep(self.driver)
+ step.IM_solo_message("自动化单聊消息")
+ ass = AppAssertPage(self.driver)
+ el_ass = '自动化单聊消息'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+
+ '''在单聊发图片'''
+
+ def test_im_solo_picture(self, start_app):
+ self.driver = start_app
+
+ club_step = IMStep(self.driver)
+ club_step.IM_solo_picture()
+ # 多等一会让图片发送成功
+ sleep(2)
+ ass = AppAssertPage(self.driver)
+ # 被检查的元素
+ el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+
+ '''在单聊发视频'''
+
+ def test_im_solo_video(self, start_app):
+ self.driver = start_app
+
+ club_step = IMStep(self.driver)
+ club_step.IM_solo_video()
+ sleep(2)
+ ass = AppAssertPage(self.driver)
+ # 被检查的元素
+ el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+
+ '''群聊发消息'''
+
+ def test_im_group_message(self, start_app):
+ self.driver = start_app
+ step = IMStep(self.driver)
+ step.IM_group_message("自动化群聊消息")
+ ass = AppAssertPage(self.driver)
+ el_ass = '自动化群聊消息'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+
+ '''在群聊发图片'''
+
+ def test_im_group_picture(self, start_app):
+ self.driver = start_app
+
+ club_step = IMStep(self.driver)
+ club_step.IM_group_picture()
+ # 多等一会让图片发送成功
+ sleep(2)
+ ass = AppAssertPage(self.driver)
+ # 被检查的元素
+ el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+
+ '''在群聊发视频'''
+
+ def test_im_group_video(self, start_app):
+ self.driver = start_app
+
+ club_step = IMStep(self.driver)
+ club_step.IM_solo_video()
+ sleep(2)
+ ass = AppAssertPage(self.driver)
+ # 被检查的元素
+ el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+
+ '''拉人创建群聊'''
+
+ def test_creat_group1(self, start_app):
+ self.driver = start_app
+ club_step = IMStep(self.driver)
+ club_step.creat_group1()
+ sleep(2)
+ ass = AppAssertPage(self.driver)
+ el_ass = '//XCUIElementTypeStaticText[@name="new202创建了群聊"]'
+ assert ass.is_element_present(MobileBy.XPATH,el_ass) == True
+
+ '''选人创建群聊'''
+ def test_creat_group2(self, start_app):
+ self.driver = start_app
+ club_step = IMStep(self.driver)
+ club_step.creat_group2()
+ sleep(2)
+ ass = AppAssertPage(self.driver)
+ el_ass = '//XCUIElementTypeStaticText[@name="new202创建了群聊"]'
+ assert ass.is_element_present(MobileBy.XPATH,el_ass) == True
+
diff --git a/TestCase/club/test_creat_club.py b/TestCase/test_club.py
similarity index 98%
rename from TestCase/club/test_creat_club.py
rename to TestCase/test_club.py
index b310d6d..652f546 100644
--- a/TestCase/club/test_creat_club.py
+++ b/TestCase/test_club.py
@@ -11,7 +11,7 @@
from common.data_util import readYaml
-class TestCreateClub:
+class TestClub:
# def test_start_server(self):
def tset_up(self):
@@ -27,8 +27,11 @@ def tset_up(self):
def teardown(self):
self.driver.quit()
+ """创建部落"""
+
def test_create_club(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.create_club('部落')
# 创建过程太慢,需要多等一会
@@ -43,6 +46,7 @@ def test_create_club(self):
def test_share_club_to_club(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.share_club_to_club()
sleep(1)
@@ -55,6 +59,7 @@ def test_share_club_to_club(self):
def test_share_club_to_contact(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.share_club_to_contact('204')
sleep(1)
@@ -67,6 +72,7 @@ def test_share_club_to_contact(self):
def test_share_club_to_group_chart(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.share_club_to_group_chat('2')
sleep(1)
@@ -79,6 +85,7 @@ def test_share_club_to_group_chart(self):
def test_send_community(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.send_community('这是动态标题', '这是动态内容')
sleep(2)
@@ -91,6 +98,7 @@ def test_send_community(self):
def test_add_chart_room(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.add_chat_room('聊天房间')
sleep(2)
@@ -102,6 +110,7 @@ def test_add_chart_room(self):
def test_add_dapp_room(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.add_dapp_room('应用房间',
'https://www.baidu.com/s?wd=%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95&rsv_spt=1&rsv_iqid=0x9058a494003119fd&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_dl=tb&rsv_enter=1&rsv_sug3=38&rsv_sug1=36&rsv_sug7=100&rsv_sug2=0&rsv_btype=i&prefixsug=%25E8%2587%25AA%25E5%258A%25A8%25E5%258C%2596%25E6%25B5%258B%25E8%25AF%2595&rsp=5&inputT=12351&rsv_sug4=15729',
@@ -114,9 +123,11 @@ def test_add_dapp_room(self):
print(e)
self.teardown()
+ '''聊天房间发布公告'''
def test_chart_room_announce(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.chart_room_announce('欢迎来到聊天房间')
sleep(2)
@@ -129,6 +140,7 @@ def test_chart_room_announce(self):
def test_all_shutup1(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.all_shutup()
ass = AppAssertPage(driver=self.driver)
@@ -140,6 +152,7 @@ def test_all_shutup1(self):
def test_all_shutup2(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.all_shutup()
ass = AppAssertPage(driver=self.driver)
@@ -151,6 +164,7 @@ def test_all_shutup2(self):
def test_message_disturb(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.message_disturb()
ass = AppAssertPage(driver=self.driver)
@@ -162,6 +176,7 @@ def test_message_disturb(self):
def test_clear_message(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.clear_message()
ass = AppAssertPage(driver=self.driver)
@@ -173,6 +188,7 @@ def test_clear_message(self):
def test_delete_room(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.delete_room()
sleep(2)
@@ -185,6 +201,7 @@ def test_delete_room(self):
def test_bing_wallet(self):
self.tset_up()
+
club_step = ClubStep(self.driver)
club_step.bing_wallet()
# 创建钱包后加载较慢
diff --git a/TestCase/test_login.py b/TestCase/test_login.py
new file mode 100644
index 0000000..4b6f75d
--- /dev/null
+++ b/TestCase/test_login.py
@@ -0,0 +1,78 @@
+
+import secrets
+from time import sleep
+
+from appium.webdriver.common.mobileby import MobileBy
+
+from Base.app_assert_page import AppAssertPage
+from PageObjct.operation_page.login_step import LoginStep
+
+
+class TestLogin:
+
+ '''账号登录'''
+
+ # @pytest.mark.parametrize('username,password', readYaml('../config/config.yaml'))
+ def test_login_202(self,start_app):
+ self.driver = start_app
+ step = LoginStep(driver=self.driver)
+ step.login1('new202', 'Sta12345')
+ sleep(1)
+ ass = AppAssertPage(self.driver)
+ # 底部“部落”tab
+ el = 'tribe_unselected_icon_light'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True,f'未找到元素{el},测试失败'
+
+ '''新用户注册'''
+
+ def test_login2(self):
+ step = LoginStep(self.driver)
+
+ # 生成一个随机的令牌,例如用于安全令牌或密码
+ token = secrets.token_hex(2) # 生成一个2个字节的十六进制字符串,4位
+ data = 'new'
+ use_name = data + token
+ step.login2(use_name, 'Sta12345', '新注册用户')
+ sleep(1)
+ # 断言
+ ass = AppAssertPage(self.driver)
+ el = '参与共建热门部落'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True,f'未找到元素{el},断言失败'
+
+ '''一键注册'''
+
+ def test_single(self):
+ step = LoginStep(self.driver)
+ step.single()
+ sleep(1)
+ ass = AppAssertPage(self.driver)
+ el = '参与共建热门部落'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True,f'未找到元素{el},断言失败'
+
+ '''退出登录'''
+
+ def test_logout(self):
+ step = LoginStep(self.driver)
+ step.logout()
+ sleep(1)
+ ass = AppAssertPage(self.driver)
+ el = '账号'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True,f'未找到元素{el},断言失败'
+
+ def test_switch_account_203(self):
+ step = LoginStep(self.driver)
+ step.switch_account_203()
+ sleep(1)
+ ass = AppAssertPage(self.driver)
+ # 底部“部落”tab
+ el = 'tribe_unselected_icon_light'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
+
+ def test_switch_account_202(self):
+ step = LoginStep(self.driver)
+ step.switch_account_202()
+ sleep(1)
+ ass = AppAssertPage(self.driver)
+ # 底部“部落”tab
+ el = 'tribe_unselected_icon_light'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
\ No newline at end of file
diff --git a/TestCase/test_redpacket.py b/TestCase/test_redpacket.py
new file mode 100644
index 0000000..4b6d738
--- /dev/null
+++ b/TestCase/test_redpacket.py
@@ -0,0 +1,106 @@
+
+from time import sleep
+import pytest_check as check
+from appium.webdriver.common.mobileby import MobileBy
+from Base.app_assert_page import AppAssertPage
+from PageObjct.operation_page.RedPacket_step import RedPacketStep
+from PageObjct.operation_page.login_step import LoginStep
+from TestCase.test_login import TestLogin
+from common.start_app import start_app
+
+
+class TestRedPacket:
+
+ '''发红包用例'''
+
+ '''单聊发ALG红包'''
+
+ def test_solo_alg(self, start_app):
+
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ switch = LoginStep(self.driver)
+ ass = AppAssertPage(self.driver)
+
+ # 发红包
+ step.create_redpacket_alg("203", "0.01", "单聊自动化ALG红包", "111111")
+ el = '单聊自动化ALG红包'
+ sleep(1)
+ # 断言:红包发送成功
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
+ # 切换到203账号
+ switch.switch_account_203()
+ # 领红包
+ step.receive_solo_alg()
+ sleep(2)
+ el2 = '已被领完,1个红包共0.01 CIQI'
+ # 断言:领取红包成功
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el2) == True, f'未找到元素{el2},测试失败'
+
+
+ '''密码错误,发红包提示'''
+
+ def test_pwd_fail(self, start_app):
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ step.create_redpacket_alg("203","0.01", "", "111122", )
+ ass = AppAssertPage(self.driver)
+ el = '验证失败'
+ sleep(1)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, '未找到错误提示消息,测试失败'
+
+ '''单聊切币发CIQI红包'''
+
+ def test_solo_ciqi(self, start_app):
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ step.create_redpacket_ciqi("0.01", "单聊自动化CIQI红包", "111111")
+ ass = AppAssertPage(self.driver)
+ el = '单聊自动化CIQI红包'
+ sleep(1)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, ''
+
+ '''群聊发CIQI拼手气红包'''
+
+ def test_group_redpacket(self, start_app):
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ step.create_group_redpacket1('3', '0.04', '群聊自动化CIQI拼手气红包', '111111')
+ ass = AppAssertPage(self.driver)
+ el = '群聊自动化CIQI拼手气红包'
+ sleep(1)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
+
+ '''群聊发ALG普通红包'''
+
+ def test_group_redpacket2(self, start_app):
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ step.create_group_redpacket2('3', '0.03', '群聊自动化ALG普通红包', '111111')
+ ass = AppAssertPage(self.driver)
+ el = '群聊自动化ALG普通红包'
+ sleep(1)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
+
+ '''频道发ALG拼手气红包'''
+
+ def test_channel_redpacket(self, start_app):
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ step.create_channel_redpacket1('3', '0.04', '频道自动化ALG拼手气红包', '111111')
+ ass = AppAssertPage(self.driver)
+ el = '频道自动化ALG拼手气红包'
+ sleep(1)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
+
+ '''频道发CIQI普通红包'''
+
+ def test_channel_redpacket2(self, start_app):
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ step.create_channel_redpacket2('3', '0.03', '频道自动化CIQI普通红包', '111111')
+ ass = AppAssertPage(self.driver)
+ el = '频道自动化CIQI普通红包'
+ sleep(1)
+ check.is_true(ass.is_element_enabled(MobileBy.ACCESSIBILITY_ID, el) == True,f'未找到元素{el},测试失败')
+
From 920e70e25e005f96ccb7cdb761fa6a9ad304ec80 Mon Sep 17 00:00:00 2001
From: gdlooker
Date: Sat, 7 Jun 2025 11:28:06 +0800
Subject: [PATCH 10/11] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=EF=BC=8C=E6=94=B6=E5=8F=91=E7=BA=A2=E5=8C=85=E5=88=86=E5=BC=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Base/base_page.py | 22 +++
PageObjct/element_page/IM_page.py | 25 ++-
PageObjct/element_page/login_page.py | 9 +-
PageObjct/operation_page/IM_step.py | 51 ++++-
PageObjct/operation_page/RedPacket_step.py | 209 +++++++++++++++++----
PageObjct/operation_page/login_step.py | 27 ++-
TestCase/test_IM.py | 49 +++--
TestCase/test_login.py | 19 +-
TestCase/test_redpacket.py | 64 ++++---
9 files changed, 380 insertions(+), 95 deletions(-)
diff --git a/Base/base_page.py b/Base/base_page.py
index c97ad2a..0a26ce0 100644
--- a/Base/base_page.py
+++ b/Base/base_page.py
@@ -1,4 +1,5 @@
from appium import webdriver
+from appium.webdriver.common.touch_action import TouchAction
class BasePage:
@@ -46,3 +47,24 @@ def up_slide(self):
# 下拉
def down_slide(self):
self.driver.swipe(111, 209, 111, 641)
+
+ # 长按
+ def long_press(self,element, duration_ms=2000):
+ """
+ 执行长按操作
+ :param element: 要长按的元素
+ :param duration_ms: 长按持续时间(毫秒)
+ """
+ action = TouchAction(self.driver)
+ action.long_press(element, duration=duration_ms).release().perform()
+
+ # 单点
+ def press(self,x, y, duration_ms=100):
+ """
+ 通过坐标执行点击操作
+ :param x: 横坐标
+ :param y: 纵坐标
+ :param duration_ms: 点击持续时间(毫秒)
+ """
+ action = TouchAction(self.driver)
+ action.press(x=x, y=y).wait(duration_ms).release().perform()
\ No newline at end of file
diff --git a/PageObjct/element_page/IM_page.py b/PageObjct/element_page/IM_page.py
index e1e31b5..1c3ce32 100644
--- a/PageObjct/element_page/IM_page.py
+++ b/PageObjct/element_page/IM_page.py
@@ -20,8 +20,9 @@ class IMPage(BasePage):
el_friend_203 = MobileBy.ACCESSIBILITY_ID, '好友成203(203)'
# 好友202
el_friend_202 = MobileBy.ACCESSIBILITY_ID, 'new202'
- # 群聊“1111”
- el_group_1111 = MobileBy.ACCESSIBILITY_ID, '1111'
+ # 第一个item
+ el_item_first = (MobileBy.XPATH,'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]')
+
'''通讯录'''
# 通讯录
el_address_book = (MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="通讯录"]')
@@ -34,7 +35,7 @@ class IMPage(BasePage):
el_group_chart_list = (MobileBy.XPATH,
'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]/XCUIElementTypeButton[2]')
# 群聊"1111"
- el_choose_group_1111 = (MobileBy.ACCESSIBILITY_ID,'1111')
+ el_group_1111 = (MobileBy.ACCESSIBILITY_ID, '1111')
'''聊天室'''
# 消息输入框
@@ -123,15 +124,27 @@ class IMPage(BasePage):
# 开红包
el_open_red_package = MobileBy.ACCESSIBILITY_ID,'red_bag_open_button'
- '''单聊设置'''
+ '''群聊设置'''
# 进入聊天设置
el_chart_setting = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="chat setting light"]')
+ # 返回
+ el_setting_go_back = (MobileBy.ACCESSIBILITY_ID,'返回')
# 拉好友建群
el_chart_setting_add = (MobileBy.ACCESSIBILITY_ID,'chat setting add')
# 建群选择第一个好友
el_add_first = (MobileBy.XPATH,'(//XCUIElementTypeButton[@name="group user unselect"])[1]')
# 建群选择第二个好友
- el_add_second = (MobileBy.ACCESSIBILITY_ID, '(//XCUIElementTypeButton[@name="group user unselect"])[2]')
+ el_add_second = (MobileBy.XPATH, '(//XCUIElementTypeButton[@name="group user unselect"])[2]')
+ # 拉人选择我第五位好友
+ el_add_five = (MobileBy.XPATH,'(//XCUIElementTypeButton[@name="group user unselect"])[5]')
# 确认建群
el_add_done1 = (MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="完成(1/9)"]')
- el_add_done2 = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="完成(2/9)"]')
\ No newline at end of file
+ el_add_done2 = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="完成(2/9)"]')
+ # 群聊名称
+ el_setting_group_name = (MobileBy.ACCESSIBILITY_ID,'群聊名称')
+ # 清除名称
+ el_setting_clear_name = (MobileBy.ACCESSIBILITY_ID,'清除文本')
+ # 输入群聊名称
+ el_setting_set_name = (MobileBy.CLASS_NAME,'XCUIElementTypeTextField')
+ # 保存群聊名称
+ el_setting_save_name = (MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="保存"]')
diff --git a/PageObjct/element_page/login_page.py b/PageObjct/element_page/login_page.py
index e10004c..e36b589 100644
--- a/PageObjct/element_page/login_page.py
+++ b/PageObjct/element_page/login_page.py
@@ -2,6 +2,8 @@
from tkinter.font import names
from appium.webdriver.common.mobileby import MobileBy
+from selenium.webdriver.common.by import By
+
from Base.base_page import BasePage
@@ -42,10 +44,15 @@ class LoginPage(BasePage):
'''我的tab'''
# 底部“我的”tab
el_my = MobileBy.ACCESSIBILITY_ID, 'mine_unselected_icon_light'
+ # el_my = By.XPATH,'//XCUIElementTypeImage[@name="mine_unselected_icon_light"]'
# 退出登录
el_logout = MobileBy.XPATH, '(//XCUIElementTypeButton[@name="退出登录"])[2]'
# 退出登录二次确认
el_popup_logout_yes = MobileBy.XPATH, '//XCUIElementTypeButton[@name="确定"]'
# 登录其他账号
el_login_another = MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="登录其他账号"]'
-
+ '''聊天室'''
+ # 返回
+ el_go_back = MobileBy.ACCESSIBILITY_ID, '返回'
+ # 搜索返回
+ el_search_goback = MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="取消"]'
\ No newline at end of file
diff --git a/PageObjct/operation_page/IM_step.py b/PageObjct/operation_page/IM_step.py
index 19bef6b..e2223f3 100644
--- a/PageObjct/operation_page/IM_step.py
+++ b/PageObjct/operation_page/IM_step.py
@@ -1,3 +1,5 @@
+from time import sleep
+
from Base.base_page import BasePage
from PageObjct.element_page.IM_page import IMPage
from PageObjct.element_page.club_page import ClubPage
@@ -127,7 +129,7 @@ def IM_group_message(self, message):
# 点击我的群聊
self.click(self.el_group_chart_list)
# 选择第1个群聊
- self.click(self.el_choose_group_first)
+ self.click(self.el_group_1111)
# 输入框输入消息
self.input(self.el_input_IM, message)
# 点击发送
@@ -143,7 +145,7 @@ def IM_group_picture(self):
# 点击我的群聊
self.click(self.el_group_chart_list)
# 选择第1个群聊
- self.click(self.el_choose_group_first)
+ self.click(self.el_group_1111)
# 点开更多面板
self.click(self.el_IM_more)
# 进入相册
@@ -167,7 +169,7 @@ def IM_group_video(self):
# 点击我的群聊
self.click(self.el_group_chart_list)
# 选择第1个群聊
- self.click(self.el_choose_group_first)
+ self.click(self.el_group_1111)
# 点开更多面板
self.click(self.el_IM_more)
# 进入相册
@@ -182,7 +184,7 @@ def IM_group_video(self):
self.click(self.el_send_picture)
'''拉人建群'''
- def creat_group1(self):
+ def create_group1(self):
# 去消息tab
self.click(self.el_message_icon)
# 点击通讯录
@@ -199,7 +201,7 @@ def creat_group1(self):
self.click(self.el_add_done1)
'''选人创建群聊'''
- def creat_group2(self):
+ def create_group2(self):
# 点击消息tab
self.click(self.el_message_icon)
# 点击+号
@@ -212,3 +214,42 @@ def creat_group2(self):
self.click(self.el_add_second)
# 点击完成
self.click(self.el_add_done2)
+
+ '''修改群名'''
+ def change_group_name(self,name):
+ # 点击消息tab
+ self.click(self.el_message_icon)
+ # 点击消息列表第一个item
+ self.click(self.el_item_first)
+ # 点击群聊设置
+ self.click(self.el_chart_setting)
+ # 点击群聊名称
+ self.click(self.el_setting_group_name)
+ # 清除历史群名
+ self.click(self.el_setting_clear_name)
+ # 输入新群名
+ self.input(self.el_setting_set_name,name)
+ # 保存
+ self.click(self.el_setting_save_name)
+ # 返回聊天室
+ self.click(self.el_setting_go_back)
+
+
+ '''拉人进群'''
+ def add_member(self):
+ # 点击消息tab
+ self.click(self.el_message_icon)
+ # 点击消息列表第一个item
+ self.click(self.el_item_first)
+ # 点击群聊设置
+ self.click(self.el_chart_setting)
+ # 点击添加成员
+ self.press(270,170)
+ # 选择第五位好友
+ self.click(self.el_add_five)
+ # 点击完成
+ self.click(self.el_add_done1)
+ sleep(2)
+ # 手势右滑返回聊天室
+ self.right_slide()
+
diff --git a/PageObjct/operation_page/RedPacket_step.py b/PageObjct/operation_page/RedPacket_step.py
index 2f4fb43..ea00fd7 100644
--- a/PageObjct/operation_page/RedPacket_step.py
+++ b/PageObjct/operation_page/RedPacket_step.py
@@ -100,20 +100,51 @@ def create_redpacket_alg(self, text, sum, remark, pwd):
'''切换CIQI币发红包'''
- def receive_solo_ciqi(self, sum, remark, pwd):
+ def receive_solo_ciqi(self,text, sum, remark, pwd):
# 点击消息tab
self.click(self.el_message_icon)
- # 点击通讯录
- self.click(self.el_address_book)
- # 加载好友列表,点击第六个好友进入聊天室
- WebDriverWait(self.driver, 10).until(expected_conditions.element_to_be_clickable((By.XPATH,
- '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[7]')))
- self.click(self.el_choose_friend_six)
+ # # 点击通讯录
+ # self.click(self.el_address_book)
+ # # 加载好友列表,点击第六个好友进入聊天室
+ # WebDriverWait(self.driver, 10).until(expected_conditions.element_to_be_clickable((By.XPATH,
+ # '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[7]')))
+ # self.click(self.el_choose_friend_six)
+ # 搜索好友
+ self.input(self.el_address_search, text)
+ self.click(self.el_address_search)
+ self.click(self.el_search_keyboard)
+ # 选择好友203
+ self.click(self.el_friend_203)
# 聊天室中点击右下角的+号按钮
self.click(self.el_IM_more)
# 点击红包
self.click(self.el_red_packet)
+ # 检查有没有没绑钱包提示,没绑先绑
+ element1 = self.driver.find_elements(By.XPATH, '//XCUIElementTypeButton[@name="立即设置"]')
+ if element1:
+ element1[0].click()
+ self.click(self.el_recognition_skip)
+ # 支付密码设置为6个1
+ for i in range(12):
+ self.click(self.el_PayPwd)
+ try:
+ element2 = WebDriverWait(self.driver, 10).until(
+ expected_conditions.element_to_be_clickable(
+ (By.XPATH, '//XCUIElementTypeNavigationBar[@name="RNSScreen"]/XCUIElementTypeOther[3]')))
+ # 关闭钱包回到聊天室
+ element2.click()
+ except TimeoutError as e:
+ print(f"{e}")
+ except ElementNotInteractableException as e:
+ print(f'{e}')
+ # +号菜单
+ self.click(self.el_IM_more)
+ # 红包
+ self.click(self.el_red_packet)
+
+ else:
+ pass
# 点击下拉icon
self.click(self.el_choose_coin)
# 代币列表浮层中选择CIQI币
@@ -129,19 +160,50 @@ def receive_solo_ciqi(self, sum, remark, pwd):
'''群聊发CIQI拼手气红包'''
- def create_group_redpacket1(self, number, sum, remark, pwd):
+ def create_group_luck_ciqi(self, text,number, sum, remark, pwd):
# 点击“消息”tab
self.click(self.el_message_icon)
- # 点击“通讯录”
- self.click(self.el_address_book)
- # 进入“我的群聊列表”
- self.click(self.el_group_chart_list)
- # 选择群聊"1111"
- self.click(self.el_choose_group_1111)
+ # # 点击“通讯录”
+ # self.click(self.el_address_book)
+ # # 进入“我的群聊列表”
+ # self.click(self.el_group_chart_list)
+ # # 选择群聊"1111"
+ # self.click(self.el_choose_group_1111)
+ # 搜索
+ self.input(self.el_address_search, text)
+ self.click(self.el_address_search)
+ self.click(self.el_search_keyboard)
+ # 选择群聊‘1111’
+ self.click(self.el_group_1111)
# 点击“+”
self.click(self.el_IM_more)
# 点击“红包”
self.click(self.el_red_packet)
+ # 检查有没有没绑钱包提示,没绑先绑
+ element1 = self.driver.find_elements(By.XPATH, '//XCUIElementTypeButton[@name="立即设置"]')
+ if element1:
+ element1[0].click()
+ self.click(self.el_recognition_skip)
+ # 支付密码设置为6个1
+ for i in range(12):
+ self.click(self.el_PayPwd)
+ try:
+ element2 = WebDriverWait(self.driver, 10).until(
+ expected_conditions.element_to_be_clickable(
+ (By.XPATH, '//XCUIElementTypeNavigationBar[@name="RNSScreen"]/XCUIElementTypeOther[3]')))
+ # 关闭钱包回到聊天室
+ element2.click()
+ except TimeoutError as e:
+ print(f"{e}")
+ except ElementNotInteractableException as e:
+ print(f'{e}')
+ # +号菜单
+ self.click(self.el_IM_more)
+ # 红包
+ self.click(self.el_red_packet)
+
+ else:
+ pass
# 选择红包类型
self.click(self.el_choose_redpacket_type)
# 选择拼手气红包
@@ -153,9 +215,9 @@ def create_group_redpacket1(self, number, sum, remark, pwd):
# 输入红包数量
self.input(self.el_group_number, number)
# 输入红包金额
- self.input(self.el_solo_sum, sum)
+ self.input(self.el_channel_sum, sum)
# 输入红包备注
- self.input(self.el_solo_remark, remark)
+ self.input(self.el_channel_remark, remark)
# 点击创建红包
self.click(self.el_create_redpacket)
# 输入支付密码
@@ -163,19 +225,50 @@ def create_group_redpacket1(self, number, sum, remark, pwd):
'''群聊发ALG普通红包'''
- def create_group_redpacket2(self, number, sum, remark, pwd):
+ def create_group_common_alg(self, text,number, sum, remark, pwd):
# 点击“消息”tab
self.click(self.el_message_icon)
- # 点击“通讯录”
- self.click(self.el_address_book)
- # 进入“我的群聊列表”
- self.click(self.el_group_chart_list)
- # 选择群聊"1111"
- self.click(self.el_choose_group_1111)
+ # # 点击“通讯录”
+ # self.click(self.el_address_book)
+ # # 进入“我的群聊列表”
+ # self.click(self.el_group_chart_list)
+ # # 选择群聊"1111"
+ # self.click(self.el_group_1111)
+ # 搜索
+ self.input(self.el_address_search, text)
+ self.click(self.el_address_search)
+ self.click(self.el_search_keyboard)
+ # 选择群聊‘1111’
+ self.click(self.el_group_1111)
# 点击“+”
self.click(self.el_IM_more)
# 点击“红包”
self.click(self.el_red_packet)
+ # 检查有没有没绑钱包提示,没绑先绑
+ element1 = self.driver.find_elements(By.XPATH, '//XCUIElementTypeButton[@name="立即设置"]')
+ if element1:
+ element1[0].click()
+ self.click(self.el_recognition_skip)
+ # 支付密码设置为6个1
+ for i in range(12):
+ self.click(self.el_PayPwd)
+ try:
+ element2 = WebDriverWait(self.driver, 10).until(
+ expected_conditions.element_to_be_clickable(
+ (By.XPATH, '//XCUIElementTypeNavigationBar[@name="RNSScreen"]/XCUIElementTypeOther[3]')))
+ # 关闭钱包回到聊天室
+ element2.click()
+ except TimeoutError as e:
+ print(f"{e}")
+ except ElementNotInteractableException as e:
+ print(f'{e}')
+ # +号菜单
+ self.click(self.el_IM_more)
+ # 红包
+ self.click(self.el_red_packet)
+
+ else:
+ pass
# 选择红包类型
self.click(self.el_choose_redpacket_type)
# 选择普通红包
@@ -187,9 +280,9 @@ def create_group_redpacket2(self, number, sum, remark, pwd):
# 输入红包数量
self.input(self.el_group_number, number)
# 输入红包金额
- self.input(self.el_solo_sum, sum)
+ self.input(self.el_channel_sum, sum)
# 输入红包备注
- self.input(self.el_solo_remark, remark)
+ self.input(self.el_channel_remark, remark)
# 点击创建红包
self.click(self.el_create_redpacket)
# 输入支付密码
@@ -197,7 +290,7 @@ def create_group_redpacket2(self, number, sum, remark, pwd):
'''频道发ALG拼手气红包'''
- def create_channel_redpacket1(self, number, sum, remark, pwd):
+ def create_channel_luck_alg(self, number, sum, remark, pwd):
# 选择“新赛季”部落
self.find_club()
# 选择“日常聊天”房间
@@ -206,6 +299,31 @@ def create_channel_redpacket1(self, number, sum, remark, pwd):
self.click(self.el_IM_more)
# 点击“红包”
self.click(self.el_red_packet)
+ # 检查有没有没绑钱包提示,没绑先绑
+ element1 = self.driver.find_elements(By.XPATH, '//XCUIElementTypeButton[@name="立即设置"]')
+ if element1:
+ element1[0].click()
+ self.click(self.el_recognition_skip)
+ # 支付密码设置为6个1
+ for i in range(12):
+ self.click(self.el_PayPwd)
+ try:
+ element2 = WebDriverWait(self.driver, 10).until(
+ expected_conditions.element_to_be_clickable(
+ (By.XPATH, '//XCUIElementTypeNavigationBar[@name="RNSScreen"]/XCUIElementTypeOther[3]')))
+ # 关闭钱包回到聊天室
+ element2.click()
+ except TimeoutError as e:
+ print(f"{e}")
+ except ElementNotInteractableException as e:
+ print(f'{e}')
+ # +号菜单
+ self.click(self.el_IM_more)
+ # 红包
+ self.click(self.el_red_packet)
+
+ else:
+ pass
# 选择红包类型
self.click(self.el_choose_redpacket_type)
# 选择拼手气红包
@@ -217,9 +335,9 @@ def create_channel_redpacket1(self, number, sum, remark, pwd):
# 输入红包数量
self.input(self.el_channel_number, number)
# 输入红包金额
- self.input(self.el_solo_sum, sum)
+ self.input(self.el_channel_sum, sum)
# 输入红包备注
- self.input(self.el_solo_remark, remark)
+ self.input(self.el_channel_remark, remark)
# 创建红包
self.click(self.el_create_redpacket)
# 输入支付密码
@@ -227,7 +345,7 @@ def create_channel_redpacket1(self, number, sum, remark, pwd):
'''频道发CIQI普通红包'''
- def create_channel_redpacket2(self, number, sum, remark, pwd):
+ def create_channel_common_ciqi(self, number, sum, remark, pwd):
# 选择“新赛季”部落
self.find_club()
# 选择“日常聊天”房间
@@ -236,6 +354,31 @@ def create_channel_redpacket2(self, number, sum, remark, pwd):
self.click(self.el_IM_more)
# 点击“红包”
self.click(self.el_red_packet)
+ # 检查有没有没绑钱包提示,没绑先绑
+ element1 = self.driver.find_elements(By.XPATH, '//XCUIElementTypeButton[@name="立即设置"]')
+ if element1:
+ element1[0].click()
+ self.click(self.el_recognition_skip)
+ # 支付密码设置为6个1
+ for i in range(12):
+ self.click(self.el_PayPwd)
+ try:
+ element2 = WebDriverWait(self.driver, 10).until(
+ expected_conditions.element_to_be_clickable(
+ (By.XPATH, '//XCUIElementTypeNavigationBar[@name="RNSScreen"]/XCUIElementTypeOther[3]')))
+ # 关闭钱包回到聊天室
+ element2.click()
+ except TimeoutError as e:
+ print(f"{e}")
+ except ElementNotInteractableException as e:
+ print(f'{e}')
+ # +号菜单
+ self.click(self.el_IM_more)
+ # 红包
+ self.click(self.el_red_packet)
+
+ else:
+ pass
# 选择红包类型
self.click(self.el_choose_redpacket_type)
# 选择拼手气红包
@@ -247,16 +390,16 @@ def create_channel_redpacket2(self, number, sum, remark, pwd):
# 输入红包数量
self.input(self.el_channel_number, number)
# 输入红包金额
- self.input(self.el_solo_sum, sum)
+ self.input(self.el_channel_sum, sum)
# 输入红包备注
- self.input(self.el_solo_remark, remark)
+ self.input(self.el_channel_remark, remark)
# 创建红包
self.click(self.el_create_redpacket)
# 输入支付密码
self.input(self.el_input_pwd, pwd)
- '''单聊领红包'''
- def receive_solo_alg(self):
+ '''领取单聊ALG红包'''
+ def open_solo_alg(self):
# 点击底部“消息”tab
self.click(self.el_message_icon)
# 进入与好友202的聊天室
diff --git a/PageObjct/operation_page/login_step.py b/PageObjct/operation_page/login_step.py
index 0d2d508..6be98e8 100644
--- a/PageObjct/operation_page/login_step.py
+++ b/PageObjct/operation_page/login_step.py
@@ -1,4 +1,5 @@
from appium.webdriver.common.mobileby import MobileBy
+from selenium.webdriver.common.by import By
from PageObjct.element_page.login_page import LoginPage
from time import sleep
@@ -78,13 +79,31 @@ def logout(self):
self.click(self.el_login_another)
def switch_account_203(self):
- go_back = MobileBy.ACCESSIBILITY_ID,'返回'
- self.click(go_back)
+ # # 聊天室返回
+ # self.click(self.el_go_back)
+ # element = self.driver.find_elements(By.XPATH,'//XCUIElementTypeStaticText[@name="取消"]')
+ # if element:
+ # element[0].click()
+ # else:
+ # pass
+ # 搜索页面返回
+ # self.click(self.el_search_goback)
+ # 退出账号
self.logout()
+ # 登录账号
self.login1('new203', 'Sta12345')
def switch_account_202(self):
- go_back = MobileBy.ACCESSIBILITY_ID, '返回'
- self.click(go_back)
+ # # 聊天室返回
+ # self.click(self.el_go_back)
+ # element = self.driver.find_elements(By.XPATH,'//XCUIElementTypeStaticText[@name="取消"]')
+ # if element:
+ # element[0].click()
+ # else:
+ # pass
+ # 搜索页面返回
+ # self.click(self.el_search_goback)
+ # 退出账号
self.logout()
+ # 登录账号
self.login1('new202', 'Sta12345')
\ No newline at end of file
diff --git a/TestCase/test_IM.py b/TestCase/test_IM.py
index 57ddb09..167ce19 100644
--- a/TestCase/test_IM.py
+++ b/TestCase/test_IM.py
@@ -15,8 +15,8 @@ def test_im_channel_message(self,start_app):
club_step.IM_channel_message('频道自动化消息')
ass = AppAssertPage(self.driver)
- el = "频道自动化消息"
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID,el) == True
+ el_ass = "频道自动化消息"
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID,el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''在频道发图片'''
def test_im_channel_picture(self,start_app):
@@ -29,7 +29,7 @@ def test_im_channel_picture(self,start_app):
ass = AppAssertPage(self.driver)
# 被检查的元素
el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''在频道发视频'''
def test_im_channel_video(self,start_app):
@@ -41,7 +41,7 @@ def test_im_channel_video(self,start_app):
ass = AppAssertPage(self.driver)
# 被检查的元素
el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''单聊发消息'''
def test_im_solo_message(self,start_app):
@@ -50,7 +50,7 @@ def test_im_solo_message(self,start_app):
step.IM_solo_message("自动化单聊消息")
ass = AppAssertPage(self.driver)
el_ass = '自动化单聊消息'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''在单聊发图片'''
@@ -64,7 +64,7 @@ def test_im_solo_picture(self, start_app):
ass = AppAssertPage(self.driver)
# 被检查的元素
el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''在单聊发视频'''
@@ -77,7 +77,7 @@ def test_im_solo_video(self, start_app):
ass = AppAssertPage(self.driver)
# 被检查的元素
el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''群聊发消息'''
@@ -87,7 +87,7 @@ def test_im_group_message(self, start_app):
step.IM_group_message("自动化群聊消息")
ass = AppAssertPage(self.driver)
el_ass = '自动化群聊消息'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''在群聊发图片'''
@@ -101,7 +101,7 @@ def test_im_group_picture(self, start_app):
ass = AppAssertPage(self.driver)
# 被检查的元素
el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''在群聊发视频'''
@@ -114,26 +114,43 @@ def test_im_group_video(self, start_app):
ass = AppAssertPage(self.driver)
# 被检查的元素
el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''拉人创建群聊'''
- def test_creat_group1(self, start_app):
+ def test_create_group1(self, start_app):
self.driver = start_app
club_step = IMStep(self.driver)
- club_step.creat_group1()
+ club_step.create_group1()
sleep(2)
ass = AppAssertPage(self.driver)
el_ass = '//XCUIElementTypeStaticText[@name="new202创建了群聊"]'
- assert ass.is_element_present(MobileBy.XPATH,el_ass) == True
+ assert ass.is_element_present(MobileBy.XPATH,el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''选人创建群聊'''
- def test_creat_group2(self, start_app):
+ def test_create_group2(self, start_app):
self.driver = start_app
club_step = IMStep(self.driver)
- club_step.creat_group2()
+ club_step.create_group2()
sleep(2)
ass = AppAssertPage(self.driver)
el_ass = '//XCUIElementTypeStaticText[@name="new202创建了群聊"]'
- assert ass.is_element_present(MobileBy.XPATH,el_ass) == True
+ assert ass.is_element_present(MobileBy.XPATH,el_ass) == True,f'断言失败,元素{el_ass}不存在'
+ '''修改群名'''
+ def test_change_group_name(self,start_app):
+ self.driver = start_app
+ club_step = IMStep(self.driver)
+ club_step.change_group_name('自动化群名')
+ ass = AppAssertPage(self.driver)
+ el_ass = 'new202将群名称修改为“自动化群名”'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID,el_ass) == True,f'断言失败,元素{el_ass}不存在'
+
+ '''拉人进群'''
+ def test_add_member(self,start_app):
+ self.driver = start_app
+ club_step = IMStep(self.driver)
+ club_step.add_member()
+ ass = AppAssertPage(self.driver)
+ el_ass = 'new202邀请201加入了群聊'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID,el_ass) == True,f'断言失败,元素{el_ass}不存在'
\ No newline at end of file
diff --git a/TestCase/test_login.py b/TestCase/test_login.py
index 4b6f75d..5376d28 100644
--- a/TestCase/test_login.py
+++ b/TestCase/test_login.py
@@ -6,7 +6,7 @@
from Base.app_assert_page import AppAssertPage
from PageObjct.operation_page.login_step import LoginStep
-
+from common.start_app import start_app
class TestLogin:
@@ -17,7 +17,6 @@ def test_login_202(self,start_app):
self.driver = start_app
step = LoginStep(driver=self.driver)
step.login1('new202', 'Sta12345')
- sleep(1)
ass = AppAssertPage(self.driver)
# 底部“部落”tab
el = 'tribe_unselected_icon_light'
@@ -25,9 +24,9 @@ def test_login_202(self,start_app):
'''新用户注册'''
- def test_login2(self):
+ def test_login2(self,start_app):
+ self.driver = start_app
step = LoginStep(self.driver)
-
# 生成一个随机的令牌,例如用于安全令牌或密码
token = secrets.token_hex(2) # 生成一个2个字节的十六进制字符串,4位
data = 'new'
@@ -41,7 +40,8 @@ def test_login2(self):
'''一键注册'''
- def test_single(self):
+ def test_single(self,start_app):
+ self.driver = start_app
step = LoginStep(self.driver)
step.single()
sleep(1)
@@ -51,7 +51,8 @@ def test_single(self):
'''退出登录'''
- def test_logout(self):
+ def test_logout(self,start_app):
+ self.driver = start_app
step = LoginStep(self.driver)
step.logout()
sleep(1)
@@ -59,7 +60,8 @@ def test_logout(self):
el = '账号'
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True,f'未找到元素{el},断言失败'
- def test_switch_account_203(self):
+ def test_switch_account_203(self,start_app):
+ self.driver = start_app
step = LoginStep(self.driver)
step.switch_account_203()
sleep(1)
@@ -68,7 +70,8 @@ def test_switch_account_203(self):
el = 'tribe_unselected_icon_light'
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
- def test_switch_account_202(self):
+ def test_switch_account_202(self,start_app):
+ self.driver = start_app
step = LoginStep(self.driver)
step.switch_account_202()
sleep(1)
diff --git a/TestCase/test_redpacket.py b/TestCase/test_redpacket.py
index 4b6d738..6beab00 100644
--- a/TestCase/test_redpacket.py
+++ b/TestCase/test_redpacket.py
@@ -19,23 +19,22 @@ def test_solo_alg(self, start_app):
self.driver = start_app
step = RedPacketStep(self.driver)
- switch = LoginStep(self.driver)
+ # switch = LoginStep(self.driver)
ass = AppAssertPage(self.driver)
-
# 发红包
step.create_redpacket_alg("203", "0.01", "单聊自动化ALG红包", "111111")
el = '单聊自动化ALG红包'
- sleep(1)
+ sleep(2)
# 断言:红包发送成功
assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
- # 切换到203账号
- switch.switch_account_203()
- # 领红包
- step.receive_solo_alg()
- sleep(2)
- el2 = '已被领完,1个红包共0.01 CIQI'
- # 断言:领取红包成功
- assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el2) == True, f'未找到元素{el2},测试失败'
+ # # 切换到203账号
+ # switch.switch_account_203()
+ # # 领红包
+ # step.open_solo_alg()
+ # sleep(2)
+ # el2 = '已被领完,1个红包共0.01 CIQI'
+ # # 断言:领取红包成功
+ # assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el2) == True, f'未找到元素{el2},测试失败'
'''密码错误,发红包提示'''
@@ -46,7 +45,7 @@ def test_pwd_fail(self, start_app):
step.create_redpacket_alg("203","0.01", "", "111122", )
ass = AppAssertPage(self.driver)
el = '验证失败'
- sleep(1)
+ sleep(2)
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, '未找到错误提示消息,测试失败'
'''单聊切币发CIQI红包'''
@@ -54,10 +53,10 @@ def test_pwd_fail(self, start_app):
def test_solo_ciqi(self, start_app):
self.driver = start_app
step = RedPacketStep(self.driver)
- step.create_redpacket_ciqi("0.01", "单聊自动化CIQI红包", "111111")
+ step.receive_solo_ciqi("203","0.01", "单聊自动化CIQI红包", "111111")
ass = AppAssertPage(self.driver)
el = '单聊自动化CIQI红包'
- sleep(1)
+ sleep(2)
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, ''
'''群聊发CIQI拼手气红包'''
@@ -65,10 +64,10 @@ def test_solo_ciqi(self, start_app):
def test_group_redpacket(self, start_app):
self.driver = start_app
step = RedPacketStep(self.driver)
- step.create_group_redpacket1('3', '0.04', '群聊自动化CIQI拼手气红包', '111111')
+ step.create_group_luck_ciqi('1111','3', '0.04', '群聊自动化CIQI拼手气红包', '111111')
ass = AppAssertPage(self.driver)
el = '群聊自动化CIQI拼手气红包'
- sleep(1)
+ sleep(2)
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
'''群聊发ALG普通红包'''
@@ -76,10 +75,10 @@ def test_group_redpacket(self, start_app):
def test_group_redpacket2(self, start_app):
self.driver = start_app
step = RedPacketStep(self.driver)
- step.create_group_redpacket2('3', '0.03', '群聊自动化ALG普通红包', '111111')
+ step.create_group_common_alg('1111','3', '0.03', '群聊自动化ALG普通红包', '111111')
ass = AppAssertPage(self.driver)
el = '群聊自动化ALG普通红包'
- sleep(1)
+ sleep(2)
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
'''频道发ALG拼手气红包'''
@@ -87,10 +86,10 @@ def test_group_redpacket2(self, start_app):
def test_channel_redpacket(self, start_app):
self.driver = start_app
step = RedPacketStep(self.driver)
- step.create_channel_redpacket1('3', '0.04', '频道自动化ALG拼手气红包', '111111')
+ step.create_channel_luck_alg('3', '0.04', '频道自动化ALG拼手气红包', '111111')
ass = AppAssertPage(self.driver)
el = '频道自动化ALG拼手气红包'
- sleep(1)
+ sleep(2)
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
'''频道发CIQI普通红包'''
@@ -98,9 +97,30 @@ def test_channel_redpacket(self, start_app):
def test_channel_redpacket2(self, start_app):
self.driver = start_app
step = RedPacketStep(self.driver)
- step.create_channel_redpacket2('3', '0.03', '频道自动化CIQI普通红包', '111111')
+ step.create_channel_common_ciqi('3', '0.03', '频道自动化CIQI普通红包', '111111')
ass = AppAssertPage(self.driver)
el = '频道自动化CIQI普通红包'
- sleep(1)
+ sleep(2)
check.is_true(ass.is_element_enabled(MobileBy.ACCESSIBILITY_ID, el) == True,f'未找到元素{el},测试失败')
+ # '''切换账号'''
+ # def test_change_account_203(self, start_app):
+ # self.driver = start_app
+ # step = LoginStep(self.driver)
+ # step.switch_account_203()
+ # ass = AppAssertPage(self.driver)
+ # # 底部“部落”tab
+ # el = 'tribe_unselected_icon_light'
+ # assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
+ #
+ #
+ #
+ # '''领取单聊ALG红包'''
+ # def test_open_solo_alg(self, start_app):
+ # self.driver = start_app
+ # step = RedPacketStep(self.driver)
+ # step.open_solo_alg()
+ # ass = AppAssertPage(self.driver)
+ # el2 = '已被领完,1个红包共0.01 CIQI'
+ # # 断言:领取红包成功
+ # assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el2) == True, f'未找到元素{el2},测试失败'
\ No newline at end of file
From 3d72d20a9bba0ee4320b3093242802ceecd413a8 Mon Sep 17 00:00:00 2001
From: gdlooker
Date: Sat, 7 Jun 2025 11:28:06 +0800
Subject: [PATCH 11/11] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=EF=BC=8C=E6=94=B6=E5=8F=91=E7=BA=A2=E5=8C=85=E5=88=86=E5=BC=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Base/base_page.py | 22 ++
PageObjct/element_page/IM_page.py | 25 +-
PageObjct/element_page/login_page.py | 9 +-
PageObjct/operation_page/IM_step.py | 51 +++-
PageObjct/operation_page/RedPacket_step.py | 262 ++++++++++++++++++---
PageObjct/operation_page/login_step.py | 68 +++++-
TestCase/test_IM.py | 49 ++--
TestCase/test_login.py | 19 +-
TestCase/test_redpacket.py | 191 +++++++++++----
9 files changed, 580 insertions(+), 116 deletions(-)
diff --git a/Base/base_page.py b/Base/base_page.py
index c97ad2a..0a26ce0 100644
--- a/Base/base_page.py
+++ b/Base/base_page.py
@@ -1,4 +1,5 @@
from appium import webdriver
+from appium.webdriver.common.touch_action import TouchAction
class BasePage:
@@ -46,3 +47,24 @@ def up_slide(self):
# 下拉
def down_slide(self):
self.driver.swipe(111, 209, 111, 641)
+
+ # 长按
+ def long_press(self,element, duration_ms=2000):
+ """
+ 执行长按操作
+ :param element: 要长按的元素
+ :param duration_ms: 长按持续时间(毫秒)
+ """
+ action = TouchAction(self.driver)
+ action.long_press(element, duration=duration_ms).release().perform()
+
+ # 单点
+ def press(self,x, y, duration_ms=100):
+ """
+ 通过坐标执行点击操作
+ :param x: 横坐标
+ :param y: 纵坐标
+ :param duration_ms: 点击持续时间(毫秒)
+ """
+ action = TouchAction(self.driver)
+ action.press(x=x, y=y).wait(duration_ms).release().perform()
\ No newline at end of file
diff --git a/PageObjct/element_page/IM_page.py b/PageObjct/element_page/IM_page.py
index e1e31b5..1c3ce32 100644
--- a/PageObjct/element_page/IM_page.py
+++ b/PageObjct/element_page/IM_page.py
@@ -20,8 +20,9 @@ class IMPage(BasePage):
el_friend_203 = MobileBy.ACCESSIBILITY_ID, '好友成203(203)'
# 好友202
el_friend_202 = MobileBy.ACCESSIBILITY_ID, 'new202'
- # 群聊“1111”
- el_group_1111 = MobileBy.ACCESSIBILITY_ID, '1111'
+ # 第一个item
+ el_item_first = (MobileBy.XPATH,'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]')
+
'''通讯录'''
# 通讯录
el_address_book = (MobileBy.XPATH, '//XCUIElementTypeStaticText[@name="通讯录"]')
@@ -34,7 +35,7 @@ class IMPage(BasePage):
el_group_chart_list = (MobileBy.XPATH,
'//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]/XCUIElementTypeButton[2]')
# 群聊"1111"
- el_choose_group_1111 = (MobileBy.ACCESSIBILITY_ID,'1111')
+ el_group_1111 = (MobileBy.ACCESSIBILITY_ID, '1111')
'''聊天室'''
# 消息输入框
@@ -123,15 +124,27 @@ class IMPage(BasePage):
# 开红包
el_open_red_package = MobileBy.ACCESSIBILITY_ID,'red_bag_open_button'
- '''单聊设置'''
+ '''群聊设置'''
# 进入聊天设置
el_chart_setting = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="chat setting light"]')
+ # 返回
+ el_setting_go_back = (MobileBy.ACCESSIBILITY_ID,'返回')
# 拉好友建群
el_chart_setting_add = (MobileBy.ACCESSIBILITY_ID,'chat setting add')
# 建群选择第一个好友
el_add_first = (MobileBy.XPATH,'(//XCUIElementTypeButton[@name="group user unselect"])[1]')
# 建群选择第二个好友
- el_add_second = (MobileBy.ACCESSIBILITY_ID, '(//XCUIElementTypeButton[@name="group user unselect"])[2]')
+ el_add_second = (MobileBy.XPATH, '(//XCUIElementTypeButton[@name="group user unselect"])[2]')
+ # 拉人选择我第五位好友
+ el_add_five = (MobileBy.XPATH,'(//XCUIElementTypeButton[@name="group user unselect"])[5]')
# 确认建群
el_add_done1 = (MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="完成(1/9)"]')
- el_add_done2 = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="完成(2/9)"]')
\ No newline at end of file
+ el_add_done2 = (MobileBy.XPATH,'//XCUIElementTypeButton[@name="完成(2/9)"]')
+ # 群聊名称
+ el_setting_group_name = (MobileBy.ACCESSIBILITY_ID,'群聊名称')
+ # 清除名称
+ el_setting_clear_name = (MobileBy.ACCESSIBILITY_ID,'清除文本')
+ # 输入群聊名称
+ el_setting_set_name = (MobileBy.CLASS_NAME,'XCUIElementTypeTextField')
+ # 保存群聊名称
+ el_setting_save_name = (MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="保存"]')
diff --git a/PageObjct/element_page/login_page.py b/PageObjct/element_page/login_page.py
index e10004c..e36b589 100644
--- a/PageObjct/element_page/login_page.py
+++ b/PageObjct/element_page/login_page.py
@@ -2,6 +2,8 @@
from tkinter.font import names
from appium.webdriver.common.mobileby import MobileBy
+from selenium.webdriver.common.by import By
+
from Base.base_page import BasePage
@@ -42,10 +44,15 @@ class LoginPage(BasePage):
'''我的tab'''
# 底部“我的”tab
el_my = MobileBy.ACCESSIBILITY_ID, 'mine_unselected_icon_light'
+ # el_my = By.XPATH,'//XCUIElementTypeImage[@name="mine_unselected_icon_light"]'
# 退出登录
el_logout = MobileBy.XPATH, '(//XCUIElementTypeButton[@name="退出登录"])[2]'
# 退出登录二次确认
el_popup_logout_yes = MobileBy.XPATH, '//XCUIElementTypeButton[@name="确定"]'
# 登录其他账号
el_login_another = MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="登录其他账号"]'
-
+ '''聊天室'''
+ # 返回
+ el_go_back = MobileBy.ACCESSIBILITY_ID, '返回'
+ # 搜索返回
+ el_search_goback = MobileBy.XPATH,'//XCUIElementTypeStaticText[@name="取消"]'
\ No newline at end of file
diff --git a/PageObjct/operation_page/IM_step.py b/PageObjct/operation_page/IM_step.py
index 19bef6b..e2223f3 100644
--- a/PageObjct/operation_page/IM_step.py
+++ b/PageObjct/operation_page/IM_step.py
@@ -1,3 +1,5 @@
+from time import sleep
+
from Base.base_page import BasePage
from PageObjct.element_page.IM_page import IMPage
from PageObjct.element_page.club_page import ClubPage
@@ -127,7 +129,7 @@ def IM_group_message(self, message):
# 点击我的群聊
self.click(self.el_group_chart_list)
# 选择第1个群聊
- self.click(self.el_choose_group_first)
+ self.click(self.el_group_1111)
# 输入框输入消息
self.input(self.el_input_IM, message)
# 点击发送
@@ -143,7 +145,7 @@ def IM_group_picture(self):
# 点击我的群聊
self.click(self.el_group_chart_list)
# 选择第1个群聊
- self.click(self.el_choose_group_first)
+ self.click(self.el_group_1111)
# 点开更多面板
self.click(self.el_IM_more)
# 进入相册
@@ -167,7 +169,7 @@ def IM_group_video(self):
# 点击我的群聊
self.click(self.el_group_chart_list)
# 选择第1个群聊
- self.click(self.el_choose_group_first)
+ self.click(self.el_group_1111)
# 点开更多面板
self.click(self.el_IM_more)
# 进入相册
@@ -182,7 +184,7 @@ def IM_group_video(self):
self.click(self.el_send_picture)
'''拉人建群'''
- def creat_group1(self):
+ def create_group1(self):
# 去消息tab
self.click(self.el_message_icon)
# 点击通讯录
@@ -199,7 +201,7 @@ def creat_group1(self):
self.click(self.el_add_done1)
'''选人创建群聊'''
- def creat_group2(self):
+ def create_group2(self):
# 点击消息tab
self.click(self.el_message_icon)
# 点击+号
@@ -212,3 +214,42 @@ def creat_group2(self):
self.click(self.el_add_second)
# 点击完成
self.click(self.el_add_done2)
+
+ '''修改群名'''
+ def change_group_name(self,name):
+ # 点击消息tab
+ self.click(self.el_message_icon)
+ # 点击消息列表第一个item
+ self.click(self.el_item_first)
+ # 点击群聊设置
+ self.click(self.el_chart_setting)
+ # 点击群聊名称
+ self.click(self.el_setting_group_name)
+ # 清除历史群名
+ self.click(self.el_setting_clear_name)
+ # 输入新群名
+ self.input(self.el_setting_set_name,name)
+ # 保存
+ self.click(self.el_setting_save_name)
+ # 返回聊天室
+ self.click(self.el_setting_go_back)
+
+
+ '''拉人进群'''
+ def add_member(self):
+ # 点击消息tab
+ self.click(self.el_message_icon)
+ # 点击消息列表第一个item
+ self.click(self.el_item_first)
+ # 点击群聊设置
+ self.click(self.el_chart_setting)
+ # 点击添加成员
+ self.press(270,170)
+ # 选择第五位好友
+ self.click(self.el_add_five)
+ # 点击完成
+ self.click(self.el_add_done1)
+ sleep(2)
+ # 手势右滑返回聊天室
+ self.right_slide()
+
diff --git a/PageObjct/operation_page/RedPacket_step.py b/PageObjct/operation_page/RedPacket_step.py
index 2f4fb43..32acd97 100644
--- a/PageObjct/operation_page/RedPacket_step.py
+++ b/PageObjct/operation_page/RedPacket_step.py
@@ -100,20 +100,51 @@ def create_redpacket_alg(self, text, sum, remark, pwd):
'''切换CIQI币发红包'''
- def receive_solo_ciqi(self, sum, remark, pwd):
+ def receive_solo_ciqi(self,text, sum, remark, pwd):
# 点击消息tab
self.click(self.el_message_icon)
- # 点击通讯录
- self.click(self.el_address_book)
- # 加载好友列表,点击第六个好友进入聊天室
- WebDriverWait(self.driver, 10).until(expected_conditions.element_to_be_clickable((By.XPATH,
- '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[7]')))
- self.click(self.el_choose_friend_six)
+ # # 点击通讯录
+ # self.click(self.el_address_book)
+ # # 加载好友列表,点击第六个好友进入聊天室
+ # WebDriverWait(self.driver, 10).until(expected_conditions.element_to_be_clickable((By.XPATH,
+ # '//XCUIElementTypeApplication[@name="Zapry"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[7]')))
+ # self.click(self.el_choose_friend_six)
+ # 搜索好友
+ self.input(self.el_address_search, text)
+ self.click(self.el_address_search)
+ self.click(self.el_search_keyboard)
+ # 选择好友203
+ self.click(self.el_friend_203)
# 聊天室中点击右下角的+号按钮
self.click(self.el_IM_more)
# 点击红包
self.click(self.el_red_packet)
+ # 检查有没有没绑钱包提示,没绑先绑
+ element1 = self.driver.find_elements(By.XPATH, '//XCUIElementTypeButton[@name="立即设置"]')
+ if element1:
+ element1[0].click()
+ self.click(self.el_recognition_skip)
+ # 支付密码设置为6个1
+ for i in range(12):
+ self.click(self.el_PayPwd)
+ try:
+ element2 = WebDriverWait(self.driver, 10).until(
+ expected_conditions.element_to_be_clickable(
+ (By.XPATH, '//XCUIElementTypeNavigationBar[@name="RNSScreen"]/XCUIElementTypeOther[3]')))
+ # 关闭钱包回到聊天室
+ element2.click()
+ except TimeoutError as e:
+ print(f"{e}")
+ except ElementNotInteractableException as e:
+ print(f'{e}')
+ # +号菜单
+ self.click(self.el_IM_more)
+ # 红包
+ self.click(self.el_red_packet)
+
+ else:
+ pass
# 点击下拉icon
self.click(self.el_choose_coin)
# 代币列表浮层中选择CIQI币
@@ -129,19 +160,50 @@ def receive_solo_ciqi(self, sum, remark, pwd):
'''群聊发CIQI拼手气红包'''
- def create_group_redpacket1(self, number, sum, remark, pwd):
+ def create_group_luck_ciqi(self, text,number, sum, remark, pwd):
# 点击“消息”tab
self.click(self.el_message_icon)
- # 点击“通讯录”
- self.click(self.el_address_book)
- # 进入“我的群聊列表”
- self.click(self.el_group_chart_list)
- # 选择群聊"1111"
- self.click(self.el_choose_group_1111)
+ # # 点击“通讯录”
+ # self.click(self.el_address_book)
+ # # 进入“我的群聊列表”
+ # self.click(self.el_group_chart_list)
+ # # 选择群聊"1111"
+ # self.click(self.el_choose_group_1111)
+ # 搜索
+ self.input(self.el_address_search, text)
+ self.click(self.el_address_search)
+ self.click(self.el_search_keyboard)
+ # 选择群聊‘1111’
+ self.click(self.el_group_1111)
# 点击“+”
self.click(self.el_IM_more)
# 点击“红包”
self.click(self.el_red_packet)
+ # 检查有没有没绑钱包提示,没绑先绑
+ element1 = self.driver.find_elements(By.XPATH, '//XCUIElementTypeButton[@name="立即设置"]')
+ if element1:
+ element1[0].click()
+ self.click(self.el_recognition_skip)
+ # 支付密码设置为6个1
+ for i in range(12):
+ self.click(self.el_PayPwd)
+ try:
+ element2 = WebDriverWait(self.driver, 10).until(
+ expected_conditions.element_to_be_clickable(
+ (By.XPATH, '//XCUIElementTypeNavigationBar[@name="RNSScreen"]/XCUIElementTypeOther[3]')))
+ # 关闭钱包回到聊天室
+ element2.click()
+ except TimeoutError as e:
+ print(f"{e}")
+ except ElementNotInteractableException as e:
+ print(f'{e}')
+ # +号菜单
+ self.click(self.el_IM_more)
+ # 红包
+ self.click(self.el_red_packet)
+
+ else:
+ pass
# 选择红包类型
self.click(self.el_choose_redpacket_type)
# 选择拼手气红包
@@ -153,9 +215,9 @@ def create_group_redpacket1(self, number, sum, remark, pwd):
# 输入红包数量
self.input(self.el_group_number, number)
# 输入红包金额
- self.input(self.el_solo_sum, sum)
+ self.input(self.el_channel_sum, sum)
# 输入红包备注
- self.input(self.el_solo_remark, remark)
+ self.input(self.el_channel_remark, remark)
# 点击创建红包
self.click(self.el_create_redpacket)
# 输入支付密码
@@ -163,19 +225,50 @@ def create_group_redpacket1(self, number, sum, remark, pwd):
'''群聊发ALG普通红包'''
- def create_group_redpacket2(self, number, sum, remark, pwd):
+ def create_group_common_alg(self, text,number, sum, remark, pwd):
# 点击“消息”tab
self.click(self.el_message_icon)
- # 点击“通讯录”
- self.click(self.el_address_book)
- # 进入“我的群聊列表”
- self.click(self.el_group_chart_list)
- # 选择群聊"1111"
- self.click(self.el_choose_group_1111)
+ # # 点击“通讯录”
+ # self.click(self.el_address_book)
+ # # 进入“我的群聊列表”
+ # self.click(self.el_group_chart_list)
+ # # 选择群聊"1111"
+ # self.click(self.el_group_1111)
+ # 搜索
+ self.input(self.el_address_search, text)
+ self.click(self.el_address_search)
+ self.click(self.el_search_keyboard)
+ # 选择群聊‘1111’
+ self.click(self.el_group_1111)
# 点击“+”
self.click(self.el_IM_more)
# 点击“红包”
self.click(self.el_red_packet)
+ # 检查有没有没绑钱包提示,没绑先绑
+ element1 = self.driver.find_elements(By.XPATH, '//XCUIElementTypeButton[@name="立即设置"]')
+ if element1:
+ element1[0].click()
+ self.click(self.el_recognition_skip)
+ # 支付密码设置为6个1
+ for i in range(12):
+ self.click(self.el_PayPwd)
+ try:
+ element2 = WebDriverWait(self.driver, 10).until(
+ expected_conditions.element_to_be_clickable(
+ (By.XPATH, '//XCUIElementTypeNavigationBar[@name="RNSScreen"]/XCUIElementTypeOther[3]')))
+ # 关闭钱包回到聊天室
+ element2.click()
+ except TimeoutError as e:
+ print(f"{e}")
+ except ElementNotInteractableException as e:
+ print(f'{e}')
+ # +号菜单
+ self.click(self.el_IM_more)
+ # 红包
+ self.click(self.el_red_packet)
+
+ else:
+ pass
# 选择红包类型
self.click(self.el_choose_redpacket_type)
# 选择普通红包
@@ -187,9 +280,9 @@ def create_group_redpacket2(self, number, sum, remark, pwd):
# 输入红包数量
self.input(self.el_group_number, number)
# 输入红包金额
- self.input(self.el_solo_sum, sum)
+ self.input(self.el_channel_sum, sum)
# 输入红包备注
- self.input(self.el_solo_remark, remark)
+ self.input(self.el_channel_remark, remark)
# 点击创建红包
self.click(self.el_create_redpacket)
# 输入支付密码
@@ -197,7 +290,7 @@ def create_group_redpacket2(self, number, sum, remark, pwd):
'''频道发ALG拼手气红包'''
- def create_channel_redpacket1(self, number, sum, remark, pwd):
+ def create_channel_luck_alg(self, number, sum, remark, pwd):
# 选择“新赛季”部落
self.find_club()
# 选择“日常聊天”房间
@@ -206,6 +299,31 @@ def create_channel_redpacket1(self, number, sum, remark, pwd):
self.click(self.el_IM_more)
# 点击“红包”
self.click(self.el_red_packet)
+ # 检查有没有没绑钱包提示,没绑先绑
+ element1 = self.driver.find_elements(By.XPATH, '//XCUIElementTypeButton[@name="立即设置"]')
+ if element1:
+ element1[0].click()
+ self.click(self.el_recognition_skip)
+ # 支付密码设置为6个1
+ for i in range(12):
+ self.click(self.el_PayPwd)
+ try:
+ element2 = WebDriverWait(self.driver, 10).until(
+ expected_conditions.element_to_be_clickable(
+ (By.XPATH, '//XCUIElementTypeNavigationBar[@name="RNSScreen"]/XCUIElementTypeOther[3]')))
+ # 关闭钱包回到聊天室
+ element2.click()
+ except TimeoutError as e:
+ print(f"{e}")
+ except ElementNotInteractableException as e:
+ print(f'{e}')
+ # +号菜单
+ self.click(self.el_IM_more)
+ # 红包
+ self.click(self.el_red_packet)
+
+ else:
+ pass
# 选择红包类型
self.click(self.el_choose_redpacket_type)
# 选择拼手气红包
@@ -217,9 +335,9 @@ def create_channel_redpacket1(self, number, sum, remark, pwd):
# 输入红包数量
self.input(self.el_channel_number, number)
# 输入红包金额
- self.input(self.el_solo_sum, sum)
+ self.input(self.el_channel_sum, sum)
# 输入红包备注
- self.input(self.el_solo_remark, remark)
+ self.input(self.el_channel_remark, remark)
# 创建红包
self.click(self.el_create_redpacket)
# 输入支付密码
@@ -227,7 +345,7 @@ def create_channel_redpacket1(self, number, sum, remark, pwd):
'''频道发CIQI普通红包'''
- def create_channel_redpacket2(self, number, sum, remark, pwd):
+ def create_channel_common_ciqi(self, number, sum, remark, pwd):
# 选择“新赛季”部落
self.find_club()
# 选择“日常聊天”房间
@@ -236,6 +354,31 @@ def create_channel_redpacket2(self, number, sum, remark, pwd):
self.click(self.el_IM_more)
# 点击“红包”
self.click(self.el_red_packet)
+ # 检查有没有没绑钱包提示,没绑先绑
+ element1 = self.driver.find_elements(By.XPATH, '//XCUIElementTypeButton[@name="立即设置"]')
+ if element1:
+ element1[0].click()
+ self.click(self.el_recognition_skip)
+ # 支付密码设置为6个1
+ for i in range(12):
+ self.click(self.el_PayPwd)
+ try:
+ element2 = WebDriverWait(self.driver, 10).until(
+ expected_conditions.element_to_be_clickable(
+ (By.XPATH, '//XCUIElementTypeNavigationBar[@name="RNSScreen"]/XCUIElementTypeOther[3]')))
+ # 关闭钱包回到聊天室
+ element2.click()
+ except TimeoutError as e:
+ print(f"{e}")
+ except ElementNotInteractableException as e:
+ print(f'{e}')
+ # +号菜单
+ self.click(self.el_IM_more)
+ # 红包
+ self.click(self.el_red_packet)
+
+ else:
+ pass
# 选择红包类型
self.click(self.el_choose_redpacket_type)
# 选择拼手气红包
@@ -247,16 +390,16 @@ def create_channel_redpacket2(self, number, sum, remark, pwd):
# 输入红包数量
self.input(self.el_channel_number, number)
# 输入红包金额
- self.input(self.el_solo_sum, sum)
+ self.input(self.el_channel_sum, sum)
# 输入红包备注
- self.input(self.el_solo_remark, remark)
+ self.input(self.el_channel_remark, remark)
# 创建红包
self.click(self.el_create_redpacket)
# 输入支付密码
self.input(self.el_input_pwd, pwd)
- '''单聊领红包'''
- def receive_solo_alg(self):
+ '''领取单聊ALG红包'''
+ def open_solo_alg(self):
# 点击底部“消息”tab
self.click(self.el_message_icon)
# 进入与好友202的聊天室
@@ -266,4 +409,57 @@ def receive_solo_alg(self):
# 点击开红包
self.click(self.el_open_red_package)
+ '''领取单聊CIQI红包'''
+ def open_solo_ciqi(self):
+ # 点击底部“消息”tab
+ self.click(self.el_message_icon)
+ # 进入与好友202的聊天室
+ self.click(self.el_friend_202)
+ # 选择ALG红包
+ self.click(self.el_solo_CIQI)
+ # 点击开红包
+ self.click(self.el_open_red_package)
+ '''领取群聊ALG普通红包'''
+ def open_group_common_alg(self):
+ # 点击底部“消息”tab
+ self.click(self.el_message_icon)
+ # 进入群聊‘1111’聊天室
+ self.click(self.el_group_1111)
+ # 选择ALG红包
+ self.click(self.el_group_common_ALG)
+ # 点击开红包
+ self.click(self.el_open_red_package)
+
+ '''领取群聊CIQI拼手气红包'''
+ def open_group_lucky_ciqi(self):
+ # 点击底部“消息”tab
+ self.click(self.el_message_icon)
+ # 进入群聊‘1111’的聊天室
+ self.click(self.el_friend_202)
+ # 选择ALG红包
+ self.click(self.el_group_lucky_CIQI)
+ # 点击开红包
+ self.click(self.el_open_red_package)
+
+ '''领取频道ALG拼手气红包'''
+ def open_channel_lucky_alg(self):
+ # 寻找部落‘新赛季’
+ self.find_club()
+ # 进入‘日常聊天’房间
+ self.click(self.el_choose_chart_room)
+ # 选择ALG红包
+ self.click(self.el_channel_lucky_ALG)
+ # 点击开红包
+ self.click(self.el_open_red_package)
+
+ '''领取频道CIQI普通红包'''
+ def open_channel_common_ciqi(self):
+ # 寻找部落‘新赛季’
+ self.find_club()
+ # 进入‘日常聊天’房间
+ self.click(self.el_choose_chart_room)
+ # 选择ALG红包
+ self.click(self.el_channel_common_CIQI)
+ # 点击开红包
+ self.click(self.el_open_red_package)
diff --git a/PageObjct/operation_page/login_step.py b/PageObjct/operation_page/login_step.py
index 0d2d508..7f54301 100644
--- a/PageObjct/operation_page/login_step.py
+++ b/PageObjct/operation_page/login_step.py
@@ -1,10 +1,14 @@
from appium.webdriver.common.mobileby import MobileBy
+from selenium.common import NoSuchElementException, TimeoutException
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions as EC
+from selenium.webdriver.support.wait import WebDriverWait
from PageObjct.element_page.login_page import LoginPage
from time import sleep
-class LoginStep(LoginPage):
+class LoginStep(LoginPage):
'''登录步骤'''
def login1(self, username, password):
@@ -78,13 +82,65 @@ def logout(self):
self.click(self.el_login_another)
def switch_account_203(self):
- go_back = MobileBy.ACCESSIBILITY_ID,'返回'
- self.click(go_back)
+ # # 聊天室返回
+ # self.click(self.el_go_back)
+ # element = self.driver.find_elements(By.XPATH,'//XCUIElementTypeStaticText[@name="取消"]')
+ # if element:
+ # element[0].click()
+ # else:
+ # pass
+ # 搜索页面返回
+ # self.click(self.el_search_goback)
+ # 退出账号
self.logout()
+ # 登录账号
self.login1('new203', 'Sta12345')
def switch_account_202(self):
- go_back = MobileBy.ACCESSIBILITY_ID, '返回'
- self.click(go_back)
+ # # 聊天室返回
+ # self.click(self.el_go_back)
+ # element = self.driver.find_elements(By.XPATH,'//XCUIElementTypeStaticText[@name="取消"]')
+ # if element:
+ # element[0].click()
+ # else:
+ # pass
+ # 搜索页面返回
+ # self.click(self.el_search_goback)
+ # 退出账号
self.logout()
- self.login1('new202', 'Sta12345')
\ No newline at end of file
+ # 登录账号
+ self.login1('new202', 'Sta12345')
+
+ def account_is_202(self):
+ try:
+ # 使用显式等待定位元素
+ element_my = WebDriverWait(self.driver, 10).until(
+ EC.presence_of_element_located((By.XPATH, '//XCUIElementTypeImage[@name="mine_unselected_icon_light"]'))
+ )
+
+ if element_my.is_displayed():
+ element_my.click()
+
+ try:
+ # 检查账号名是否显示
+ element_name = WebDriverWait(self.driver, 5).until(EC.visibility_of_element_located(
+ (By.XPATH, '(//XCUIElementTypeStaticText[@name="new202"])[2]')))
+ self.click(el_club)
+ return True # 已经是目标账号
+
+ except TimeoutException:
+ print("未找到new202账号,正在切换...")
+ self.switch_account_202()
+ return True
+
+ except TimeoutException:
+ # 如果找不到个人资料图标,检查是否在登录页面
+ if WebDriverWait(self.driver, 5).until(
+ EC.presence_of_element_located(
+ (By.XPATH, '//XCUIElementTypeStaticText[@name="账号"]'))).is_displayed():
+ self.login1('new202', 'Sta12345')
+ return True
+
+ except Exception as e:
+ print(f"检查账号时出现意外错误: {str(e)}")
+ return False
diff --git a/TestCase/test_IM.py b/TestCase/test_IM.py
index 57ddb09..167ce19 100644
--- a/TestCase/test_IM.py
+++ b/TestCase/test_IM.py
@@ -15,8 +15,8 @@ def test_im_channel_message(self,start_app):
club_step.IM_channel_message('频道自动化消息')
ass = AppAssertPage(self.driver)
- el = "频道自动化消息"
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID,el) == True
+ el_ass = "频道自动化消息"
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID,el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''在频道发图片'''
def test_im_channel_picture(self,start_app):
@@ -29,7 +29,7 @@ def test_im_channel_picture(self,start_app):
ass = AppAssertPage(self.driver)
# 被检查的元素
el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''在频道发视频'''
def test_im_channel_video(self,start_app):
@@ -41,7 +41,7 @@ def test_im_channel_video(self,start_app):
ass = AppAssertPage(self.driver)
# 被检查的元素
el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''单聊发消息'''
def test_im_solo_message(self,start_app):
@@ -50,7 +50,7 @@ def test_im_solo_message(self,start_app):
step.IM_solo_message("自动化单聊消息")
ass = AppAssertPage(self.driver)
el_ass = '自动化单聊消息'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''在单聊发图片'''
@@ -64,7 +64,7 @@ def test_im_solo_picture(self, start_app):
ass = AppAssertPage(self.driver)
# 被检查的元素
el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''在单聊发视频'''
@@ -77,7 +77,7 @@ def test_im_solo_video(self, start_app):
ass = AppAssertPage(self.driver)
# 被检查的元素
el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''群聊发消息'''
@@ -87,7 +87,7 @@ def test_im_group_message(self, start_app):
step.IM_group_message("自动化群聊消息")
ass = AppAssertPage(self.driver)
el_ass = '自动化群聊消息'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''在群聊发图片'''
@@ -101,7 +101,7 @@ def test_im_group_picture(self, start_app):
ass = AppAssertPage(self.driver)
# 被检查的元素
el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''在群聊发视频'''
@@ -114,26 +114,43 @@ def test_im_group_video(self, start_app):
ass = AppAssertPage(self.driver)
# 被检查的元素
el_ass = '/var/mobile/Containers/Data/Application/0DB0277E-94E9-4047-98E2-4932E00004F5/Library/Caches/1744789632269_4A1D0F12-BD50-4546-BA6F-81505E52941E.jpg'
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''拉人创建群聊'''
- def test_creat_group1(self, start_app):
+ def test_create_group1(self, start_app):
self.driver = start_app
club_step = IMStep(self.driver)
- club_step.creat_group1()
+ club_step.create_group1()
sleep(2)
ass = AppAssertPage(self.driver)
el_ass = '//XCUIElementTypeStaticText[@name="new202创建了群聊"]'
- assert ass.is_element_present(MobileBy.XPATH,el_ass) == True
+ assert ass.is_element_present(MobileBy.XPATH,el_ass) == True,f'断言失败,元素{el_ass}不存在'
'''选人创建群聊'''
- def test_creat_group2(self, start_app):
+ def test_create_group2(self, start_app):
self.driver = start_app
club_step = IMStep(self.driver)
- club_step.creat_group2()
+ club_step.create_group2()
sleep(2)
ass = AppAssertPage(self.driver)
el_ass = '//XCUIElementTypeStaticText[@name="new202创建了群聊"]'
- assert ass.is_element_present(MobileBy.XPATH,el_ass) == True
+ assert ass.is_element_present(MobileBy.XPATH,el_ass) == True,f'断言失败,元素{el_ass}不存在'
+ '''修改群名'''
+ def test_change_group_name(self,start_app):
+ self.driver = start_app
+ club_step = IMStep(self.driver)
+ club_step.change_group_name('自动化群名')
+ ass = AppAssertPage(self.driver)
+ el_ass = 'new202将群名称修改为“自动化群名”'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID,el_ass) == True,f'断言失败,元素{el_ass}不存在'
+
+ '''拉人进群'''
+ def test_add_member(self,start_app):
+ self.driver = start_app
+ club_step = IMStep(self.driver)
+ club_step.add_member()
+ ass = AppAssertPage(self.driver)
+ el_ass = 'new202邀请201加入了群聊'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID,el_ass) == True,f'断言失败,元素{el_ass}不存在'
\ No newline at end of file
diff --git a/TestCase/test_login.py b/TestCase/test_login.py
index 4b6f75d..5376d28 100644
--- a/TestCase/test_login.py
+++ b/TestCase/test_login.py
@@ -6,7 +6,7 @@
from Base.app_assert_page import AppAssertPage
from PageObjct.operation_page.login_step import LoginStep
-
+from common.start_app import start_app
class TestLogin:
@@ -17,7 +17,6 @@ def test_login_202(self,start_app):
self.driver = start_app
step = LoginStep(driver=self.driver)
step.login1('new202', 'Sta12345')
- sleep(1)
ass = AppAssertPage(self.driver)
# 底部“部落”tab
el = 'tribe_unselected_icon_light'
@@ -25,9 +24,9 @@ def test_login_202(self,start_app):
'''新用户注册'''
- def test_login2(self):
+ def test_login2(self,start_app):
+ self.driver = start_app
step = LoginStep(self.driver)
-
# 生成一个随机的令牌,例如用于安全令牌或密码
token = secrets.token_hex(2) # 生成一个2个字节的十六进制字符串,4位
data = 'new'
@@ -41,7 +40,8 @@ def test_login2(self):
'''一键注册'''
- def test_single(self):
+ def test_single(self,start_app):
+ self.driver = start_app
step = LoginStep(self.driver)
step.single()
sleep(1)
@@ -51,7 +51,8 @@ def test_single(self):
'''退出登录'''
- def test_logout(self):
+ def test_logout(self,start_app):
+ self.driver = start_app
step = LoginStep(self.driver)
step.logout()
sleep(1)
@@ -59,7 +60,8 @@ def test_logout(self):
el = '账号'
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True,f'未找到元素{el},断言失败'
- def test_switch_account_203(self):
+ def test_switch_account_203(self,start_app):
+ self.driver = start_app
step = LoginStep(self.driver)
step.switch_account_203()
sleep(1)
@@ -68,7 +70,8 @@ def test_switch_account_203(self):
el = 'tribe_unselected_icon_light'
assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
- def test_switch_account_202(self):
+ def test_switch_account_202(self,start_app):
+ self.driver = start_app
step = LoginStep(self.driver)
step.switch_account_202()
sleep(1)
diff --git a/TestCase/test_redpacket.py b/TestCase/test_redpacket.py
index 4b6d738..26186af 100644
--- a/TestCase/test_redpacket.py
+++ b/TestCase/test_redpacket.py
@@ -1,8 +1,9 @@
-
from time import sleep
import pytest_check as check
from appium.webdriver.common.mobileby import MobileBy
from Base.app_assert_page import AppAssertPage
+from PageObjct.element_page.IM_page import IMPage
+from PageObjct.operation_page.IM_step import IMStep
from PageObjct.operation_page.RedPacket_step import RedPacketStep
from PageObjct.operation_page.login_step import LoginStep
from TestCase.test_login import TestLogin
@@ -10,97 +11,205 @@
class TestRedPacket:
-
'''发红包用例'''
+ '''查看账号是否是202'''
+ def test_account_is_202(self,start_app):
+ self.driver = start_app.driver
+ step = LoginStep(self.driver)
+ step.account_is_202()
+ ass = AppAssertPage(self.driver)
+ el_ass = 'tribe_add_light'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID,el_ass) == True,\
+ f'未找到元素{el_ass},不确定该账号是否为202'
+
'''单聊发ALG红包'''
def test_solo_alg(self, start_app):
-
self.driver = start_app
step = RedPacketStep(self.driver)
- switch = LoginStep(self.driver)
+ # switch = LoginStep(self.driver)
ass = AppAssertPage(self.driver)
-
# 发红包
step.create_redpacket_alg("203", "0.01", "单聊自动化ALG红包", "111111")
- el = '单聊自动化ALG红包'
- sleep(1)
- # 断言:红包发送成功
- assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
- # 切换到203账号
- switch.switch_account_203()
- # 领红包
- step.receive_solo_alg()
+ el_ass = '单聊自动化ALG红包'
sleep(2)
- el2 = '已被领完,1个红包共0.01 CIQI'
- # 断言:领取红包成功
- assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el2) == True, f'未找到元素{el2},测试失败'
-
+ # 断言:红包发送成功
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el_ass) == True, \
+ f'未找到元素{el_ass},单聊发ALG红包失败'
+ # # 切换到203账号
+ # switch.switch_account_203()
+ # # 领红包
+ # step.open_solo_alg()
+ # sleep(2)
+ # el2 = '已被领完,1个红包共0.01 CIQI'
+ # # 断言:领取红包成功
+ # assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el2) == True, f'未找到元素{el2},测试失败'
'''密码错误,发红包提示'''
def test_pwd_fail(self, start_app):
self.driver = start_app
step = RedPacketStep(self.driver)
- step.create_redpacket_alg("203","0.01", "", "111122", )
+ step.create_redpacket_alg("203", "0.01", "", "111122", )
ass = AppAssertPage(self.driver)
- el = '验证失败'
- sleep(1)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, '未找到错误提示消息,测试失败'
+ el_ass = '验证失败'
+ sleep(2)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True, \
+ f'未找到错误提示消息{el_ass},测试失败'
'''单聊切币发CIQI红包'''
def test_solo_ciqi(self, start_app):
self.driver = start_app
step = RedPacketStep(self.driver)
- step.create_redpacket_ciqi("0.01", "单聊自动化CIQI红包", "111111")
+ step.receive_solo_ciqi("203", "0.01", "单聊自动化CIQI红包", "111111")
ass = AppAssertPage(self.driver)
- el = '单聊自动化CIQI红包'
- sleep(1)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, ''
+ el_ass = '单聊自动化CIQI红包'
+ sleep(2)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el_ass) == True, \
+ f'未找到元素{el_ass},单聊发CIQI红包失败'
'''群聊发CIQI拼手气红包'''
- def test_group_redpacket(self, start_app):
+ def test_group_lucky_ciqi(self, start_app):
self.driver = start_app
step = RedPacketStep(self.driver)
- step.create_group_redpacket1('3', '0.04', '群聊自动化CIQI拼手气红包', '111111')
+ step.create_group_luck_ciqi('1111', '3', '0.04', '群聊自动化CIQI拼手气红包', '111111')
ass = AppAssertPage(self.driver)
el = '群聊自动化CIQI拼手气红包'
- sleep(1)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
+ sleep(2)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, \
+ f'未找到元素{el},群聊发CIQI拼手气红包失败'
'''群聊发ALG普通红包'''
- def test_group_redpacket2(self, start_app):
+ def test_group_common_alg(self, start_app):
self.driver = start_app
step = RedPacketStep(self.driver)
- step.create_group_redpacket2('3', '0.03', '群聊自动化ALG普通红包', '111111')
+ step.create_group_common_alg('1111', '3', '0.03', '群聊自动化ALG普通红包', '111111')
ass = AppAssertPage(self.driver)
el = '群聊自动化ALG普通红包'
- sleep(1)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
+ sleep(2)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, \
+ f'未找到元素{el},群聊发ALG普通红包失败'
'''频道发ALG拼手气红包'''
- def test_channel_redpacket(self, start_app):
+ def test_channel_lucky_alg(self, start_app):
self.driver = start_app
step = RedPacketStep(self.driver)
- step.create_channel_redpacket1('3', '0.04', '频道自动化ALG拼手气红包', '111111')
+ step.create_channel_luck_alg('3', '0.04', '频道自动化ALG拼手气红包', '111111')
ass = AppAssertPage(self.driver)
el = '频道自动化ALG拼手气红包'
- sleep(1)
- assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, f'未找到元素{el},测试失败'
+ sleep(2)
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, \
+ f'未找到元素{el},频道发ALG拼手气红包失败'
'''频道发CIQI普通红包'''
- def test_channel_redpacket2(self, start_app):
+ def test_channel_common_ciqi(self, start_app):
self.driver = start_app
step = RedPacketStep(self.driver)
- step.create_channel_redpacket2('3', '0.03', '频道自动化CIQI普通红包', '111111')
+ step.create_channel_common_ciqi('3', '0.03', '频道自动化CIQI普通红包', '111111')
ass = AppAssertPage(self.driver)
el = '频道自动化CIQI普通红包'
- sleep(1)
- check.is_true(ass.is_element_enabled(MobileBy.ACCESSIBILITY_ID, el) == True,f'未找到元素{el},测试失败')
+ sleep(2)
+ assert ass.is_element_enabled(MobileBy.ACCESSIBILITY_ID, el) == True, \
+ f'未找到元素{el},频道发CIQI普通红包失败'
+
+ '''切换账号'''
+
+ def test_change_account_203(self, start_app):
+ self.driver = start_app
+ step = LoginStep(self.driver)
+ step.switch_account_203()
+ ass = AppAssertPage(self.driver)
+ # 底部“部落”tab
+ el = 'tribe_unselected_icon_light'
+ assert ass.is_element_present(MobileBy.ACCESSIBILITY_ID, el) == True, \
+ f'未找到元素{el},切换账号失败'
+
+ '''领取单聊ALG红包'''
+ def test_open_solo_alg(self, start_app):
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ step.open_solo_alg()
+ ass = AppAssertPage(self.driver)
+ el_ass = '已被领完,1个红包共0.01 ALG'
+ # 断言:领取红包成功
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el_ass) == True, \
+ f'未找到元素{el_ass},领取单聊ALG红包失败'
+
+ '''领取单聊CIQI红包'''
+
+ def test_open_solo_ciqi(self, start_app):
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ step.open_solo_ciqi()
+ ass = AppAssertPage(self.driver)
+ el_ass = '已被领完,1个红包共0.01 CIQI'
+ # 断言:领取红包成功
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el_ass) == True, \
+ f'未找到元素{el_ass},领取单聊CIQI红包失败'
+
+ '''领取群聊ALG普通红包'''
+
+ def test_open_group_common_alg(self, start_app):
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ step.open_group_common_alg()
+ ass = AppAssertPage(self.driver)
+ el_ass1 = 'new202的红包'
+ el_ass2 = '群聊自动化ALG普通红包'
+ # 断言:领取红包成功
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el_ass1) == True, \
+ f'未找到元素{el_ass1},领取群聊ALG普通红包失败'
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el_ass2) == True, \
+ f'未找到元素{el_ass2},领取群聊ALG普通红包失败'
+
+ '''领取群聊CIQI拼手气红包'''
+
+ def test_open_group_lucky_ciqi(self, start_app):
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ step.open_group_lucky_ciqi()
+ ass = AppAssertPage(self.driver)
+ el_ass1 = 'new202的红包'
+ el_ass2 = '群聊自动化CIQI拼手气红包'
+ # 断言:领取红包成功
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el_ass1) == True, \
+ f'未找到元素{el_ass1},领取群聊CIQI拼手气红包失败'
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el_ass2) == True, \
+ f'未找到元素{el_ass2},领取群聊CIQI拼手气红包失败'
+
+ '''领取频道ALG拼手气红包'''
+
+ def test_open_channel_lucky_alg(self, start_app):
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ step.open_channel_lucky_alg()
+ ass = AppAssertPage(self.driver)
+ el_ass1 = 'new202的红包'
+ el_ass2 = '频道自动化ALG拼手气红包'
+ # 断言:领取红包成功
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el_ass1) == True, \
+ f'未找到元素{el_ass1},领取频道ALG拼手气红包失败'
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el_ass2) == True, \
+ f'未找到元素{el_ass2},领取频道ALG拼手气红包失败'
+
+ '''领取频道CIQI普通红包'''
+
+ def test_open_channel_common_ciqi(self, start_app):
+ self.driver = start_app
+ step = RedPacketStep(self.driver)
+ step.open_channel_common_ciqi()
+ ass = AppAssertPage(self.driver)
+ el_ass1 = 'new202的红包'
+ el_ass2 = '频道自动化CIQI普通红包'
+ # 断言:领取红包成功
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el_ass1) == True, \
+ f'未找到元素{el_ass1},领取频道CIQI普通红包失败'
+ assert ass.is_element_displayed(MobileBy.ACCESSIBILITY_ID, el_ass2) == True, \
+ f'未找到元素{el_ass2},领取频道CIQI普通红包失败'