list_1 =[]
list_1.extend([i.text for i in WebDriverWait.until(ec.visibility_of_all_elements_located((by.ID,'元素id')))])whileTrue:
f1 = driver.page_source # 源码"""滑动的操作"""# 滑动方式一
driver.swipe(start_x=500, start_y=1700, end_x=500, end_y=600)# 滑动方式二
action = TouchAction(driver)
action.press(x=500, y=1700)
action.move_to(x=500, y=600)
action.release()
action.perform()# 滑动方式三from selenium.webdriver import ActionChains
from selenium.webdriver.common.actions import interaction
from selenium.webdriver.common.actions.action_builder import ActionBuilder
from selenium.webdriver.common.actions.pointer_actions import PointerInput
actions = ActionChains(driver)'''
POINTER_MOUSE = "mouse",鼠标事件
POINTER_TOUCH = "touch",触控事件
POINTER_PEN = "pen",触控笔事件
'''
actions.w3c_actions = ActionBuilder(driver, mouse=PointerInput(interaction.POINTER_TOUCH,'touch'))
actions.w3c_actions.pointer_action.move_to_location(x=500, y=1700)# 起始点击
actions.w3c_actions.pointer_action.pointer_down()# 按下
actions.w3c_actions.pointer_action.move_to_location(x=500, y=600)# 终止位置
actions.w3c_actions.pointer_action.release()# 释放
actions.perform()"""判断去重 和 添加列表的操作"""
elements = WebDriverWait.until(ec.visibility_of_all_elements_located((by.ID,'元素id')))
elements_text =[i.text for i in elements]# for i in elements_text:# if i not in list_1: # 判断 list_1 中不存在 i ,则添加到 list_1 中# list_1.append(i)[list_1.append(i)for i in elements_text if i notin list_1]# 同上已注释代码效果一致"""判断 f1 是否和 driver.page_source 一致,一致则退出循环"""if f1 == driver.page_source:breakprint(list_1[::-1])# 倒序查看列表