Commit d2bc4ec8 by Administrator

2.88提交

parent c0a37b75
import time
import pyautogui
import pyperclip
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from Util.Util import DriverUtils
import logging
......@@ -19,6 +21,12 @@ class BasePage:
# 查找元素
def find_el(self, loc, time=10, fre=0.5):
ele = WebDriverWait(self.driver, time, fre).until(lambda x: x.find_element(*loc))
# wait = WebDriverWait(self.driver, time)
# ele = wait.until(
# EC.element_to_be_clickable(loc))
return ele
# 输入文本内容
......@@ -30,6 +38,7 @@ class BasePage:
# 再输入
ele.send_keys(value)
# 滚动条
def scroll(self, x, y):
# 横着滚动调整x值,竖着滚动调整y值
......@@ -48,9 +57,25 @@ class BasePage:
# 选择文件
def select_document(self,path_str=None):
time.sleep(1)
pyautogui.write(path_str)
pyperclip.copy("D:") # 将路径字符串复制到剪贴板
time.sleep(1)
pyautogui.hotkey('ctrl', 'v') # 模拟粘贴操作
time.sleep(1)
pyautogui.press('enter') # 模拟按下回车键
time.sleep(1)
time.sleep(1)
pyperclip.copy("txt") # 将路径字符串复制到剪贴板
time.sleep(1)
pyautogui.hotkey('ctrl', 'v') # 模拟粘贴操作
time.sleep(1)
pyautogui.press('enter') # 模拟按下回车键
pyperclip.copy(path_str) # 将路径字符串复制到剪贴板
time.sleep(1)
pyautogui.hotkey('ctrl', 'v') # 模拟粘贴操作
time.sleep(1)
pyautogui.press('enter')
pyautogui.press('enter') # 模拟按下回车键
time.sleep(2)
# 设置日志记录器
......
......@@ -154,6 +154,7 @@ class BusinessKnowledgePage(BasePage):
# 移除订阅的网站
def removeSubscriptionWebsite(self,count=None):
for i in range(count):
self.find_el(self.removeButton).click()
# 确定订阅网站
......@@ -187,7 +188,6 @@ class BusinessKnowledgePage(BasePage):
'//*[@id="website"]/div/div[2]/div[1]/div[contains(@class,"website-item")]')
for subscriptionWebsiteOption in subscriptionWebsiteOptions:
subscriptionWebsiteOption.click() # 选中
# 确定订阅
self.find_el(self.ensureSubscriptionWebsite).click()
......@@ -203,21 +203,22 @@ class UploadDocumentHelper(BasePage):
self.clickUploadButton = (By.XPATH,'/html/body/div[3]/div/div[2]/div/div[2]/div[2]/div/div[2]/div[2]/div[1]/div') # 点击上传
self.titleText = (By.XPATH,'//*[@id="docName"]') # 文档名称
self.contentText = (By.XPATH,'//*[@id="content"]') # 文档内容
self.ensureButton = (By.XPATH,'/html/body/div[3]/div/div[2]/div/div[2]/div[3]/div/button[2]') # 确定
self.urlText = (By.XPATH,'//*[@id="url"]')
self.getContentButton = (By.CLASS_NAME,'ant-btn ant-btn-primaryx')
"""
方式一:上传文档
文档类型
文档大小
"""
def uploadDocumentControl(self,str_path):
def uploadDocumentControl(self,str_paths):
time.sleep(1)
# for str_path in str_paths:
# time.sleep(1)
# self.find_el(self.uploadDocumentButton).click() # 点击 弹出弹窗
# logging.info(str_path)
# time.sleep(1)
# self.find_el(self.clickUploadButton).click() # 弹窗,选择文件
# self.select_document(str_path)
# time.sleep(1)
for str_path in str_paths:
time.sleep(1)
self.find_el(self.uploadDocumentButton).click() # 点击 弹出弹窗
logging.info(str_path)
......@@ -226,19 +227,37 @@ class UploadDocumentHelper(BasePage):
self.select_document(str_path)
time.sleep(1)
"""
粘贴文本
"""
def pasteTextControl(self,title,content):
self.find_el(self.pasteTextButton).click()
self.input_text(self.titleText,title)
self.input_text(self.contentText,content)
self.find_el(self.ensureButton).click()
"""
导入网站
"""
def uploadUrlControl(self,url_link):
self.find_el(self.importWebsiteButton).click()
time.sleep(1)
self.input_text(self.urlText,url_link)
time.sleep(2)
button = self.find_el(self.getContentButton)
# 使用 ActionChains 将鼠标移动到按钮上再点击
action = ActionChains(driver)
action.move_to_element(button).click().perform()
# 使用JavaScript将焦点移动到页面其他元素,使文本域失去焦点
# driver.execute_script("arguments[0].blur();", text_area)
time.sleep(2)
time.sleep(1)
"""
文档列表操作
"""
"""
文档对话
"""
......@@ -259,15 +278,29 @@ if __name__ == '__main__':
time.sleep(1)
businessKnowledge.entranceBusinessKnowledge()
time.sleep(1)
businessKnowledge.upload_document_helper.uploadUrlControl("https://blog.csdn.net/FezZZZ/article/details/120878765")
time.sleep(2)
# businessKnowledge.upload_document_helper.pasteTextControl("标题","内容内内容内内容内内容内内容内内容内内容内内容内内容"
# "内内容内内容内内容内内容内内容内内容内内容内内容内内容内"
# "内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内"
# "容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容"
# "内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内"
# "内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容"
# "内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容"
# "内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容"
# "内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容"
# "内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容"
# "内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内内容内")
# time.sleep(2)
stry_paths = []
for i in range(15):
stry_paths.append('D:/Word/WORD'+str(i+1)+".docx")
# stry_paths = []
# for i in range(3):
# stry_paths.append("t"+str(i+1)+".txt")
# businessKnowledge.upload_document_helper.uploadDocumentControl(stry_paths)
# time.sleep(4)
businessKnowledge.upload_document_helper.uploadDocumentControl('D:/Word/WORD1.docx')
time.sleep(4)
# businessKnowledge.subscriptionWebsiteStart()
# time.sleep(1)
# businessKnowledge.subscriptionWebsiteFrequencySelect("三天更新一次")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment