searched_qq_number = datas['searched_qq_number']['second']
message = chat_mesage["段子"]["段子0"]
start_time='2021-01-23 13:33:00'
end_time='2021-01-23 13:33:59'
ontime_message='你好'
action = EnterIntoChatPage(searched_qq_number, message,start_time,end_time,ontime_message)
action.enter_chat_page()
action.send_message()
action.send_message_on_time()
action.enter_personal_data_page()
---------------------------------------------------------------
class EnetrQzone():
"""
用于进入个人信息展示页面进行点赞和进入QQ空间
1.首先进入个人信息展示页面
2.点赞
3.进入QQ空间
"""
def int(self):
""""""
def enter_personal_data_page(self):
"""
1.在聊天界面点击右上角【聊天设置】按钮
2.点击个人头像和昵称一栏进入个人信息展示界面
3.进入个人信息展示页面
"""
#1.调用EnterIntoChatPage()类的enter_chat_page()方法进入聊天界面
EnterIntoChatPage(searched_qq_number, message,start_time,end_time,ontime_message).enter_chat_page()
#2.点击在聊天界面点击右上角【聊天设置】按钮
driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/ivTitleBtnRightImage']").click()
#3.点击个人头像和昵称一栏进入个人信息展示界面
driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/clv']").click()
sleep(5)
def give_like(self):
"""
点赞
TODO:赞显示为花样赞时,无法进行点赞
"""
pass
def qzone_like(self):
"""
1.对个人QQ空间进行点赞
2.通过对话框界面进入,调用send_message函数
:return:
"""
# 1.点击进入空间的按钮(进行判断,若已经开通了小世界,则第二个入口为QQ空间,否则为第一个)
elements = driver.find_elements_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/dkv']")
elements[0].click()
#2.判断空间是否是禁止访问的状态
'''
if driver.find_element_by_xpath("//*[@text='主人设置了权限']"):
print("主人设置了权限")
# 发送返回键模拟手机返回按钮
driver.press_keycode(4)
else:
pass
'''
# 首次进入空间需要滑动一段距离,以防点赞按钮加赞不处理来
# sleep(3)
origin_ele = driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/c53']")
destination_ele = driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/hto']")
driver.drag_and_drop(origin_ele, destination_ele)
# 先找昵称和说说发表时间所在的方框,进行遍历
while True:
elements = driver.find_elements_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/c7p']")
print("Current page click_like_button number is:" + str(len(elements)))
# if current page click_lkie_button number is one,click it one times
if len(elements) == 1:
elements[0].click()
# pass
# if current page click_like_button number >=2,the button is iterated over
elif len(elements) >= 2:
elements[1].click()
# pass
print("------------点赞一轮结束---------------")
origin_eles = driver.find_elements_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/c7y']")
destination_eles = driver.find_elements_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/c4r']")
print("Current page origin_eles numbers:" + str(len(origin_eles)))
print("Current page destination_eles numbers:" + str(len(destination_eles)))
# if current page only have one origin_eles and one destination_eles,direct use of
if len(origin_eles) == 1 and len(destination_eles) == 1:
driver.drag_and_drop(origin_eles[0],destination_eles[0])
# if current page have two desttination_eles and one origin_eles,than Slide from the destination_eles[1] to the destination_eles[1]
elif len(destination_eles) == 2 and len(origin_eles) == 1:
driver.drag_and_drop(destination_eles[1],destination_eles[0])
# if current page have two desttination_eles and one origin_eles,than Slide from the origin_eles[1] to the origin_eles[0]
elif len(origin_eles) == 2 and len(destination_eles) == 1:
driver.drag_and_drop(origin_eles[1],origin_eles[0])
# 如果当前页面有2个滑动起点和2个滑动终点,那么从第2个滑动终点滑动到第1个滑动终点
elif len(origin_eles) == 2 and len(destination_eles) == 2:
driver.drag_and_drop(destination_eles[1],destination_eles[0])
# 如果当前界面有1个滑动起点和0个滑动终点
elif len(origin_eles) == 1 and len(destination_eles) == 0:
origin_ele = driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/c4r']")
destination_ele = driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/c7y']")
driver.drag_and_drop(origin_ele, destination_ele)
# 如果当前界面有1个滑动终点和0个滑动起点
elif len(destination_eles) == 1 and len(origin_eles) == 0:
pass
---------------以下是对EnetrQzone(EnterIntoChatPage)类的测试---------------
action = EnetrQzone()
action.enter_personal_data_page()
action.qzone_like()
---------------------------------------------------------------
`