import pandas as pd
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
# 读取Excel文件
df = pd.read_excel('bug_case.xlsx')
# 显示前5行数据
# print(df.head())
#3. 打开浏览器并登录Tapd
s = Service('D:\python\PyCharm Community Edition 2020.3.1\chromedriver.exe')
driver = webdriver.Chrome(service=s)
driver.implicitly_wait(10)#智能等待时间
# 打开Tapd登录页面
driver.get('https://www.tapd.cn/cloud_logins/login')
# 填写用户名和密码
driver.find_element(By.XPATH,'//*[@id="username"]').send_keys('xxxxx@qq.com')
time.sleep(1)
driver.find_element(By.XPATH,'//*[@id="password_input"]').send_keys('xxxx23..')
# 点击登录按钮
driver.find_element(By.XPATH,'//*[@id="tcloud_login_button"]').click()
driver.maximize_window()#窗口最大化
y = 0
# 循环遍历Excel表格的每一行
for index, row in df.iterrows():
# 配置TAPD相关信息
title = df['title'].values[0] # 标题
msg = df['msg'].values[0] # 图片
processing = df['processing staff'].values[0] # 处理人
severity = df['order of severity'].values[0] # 严重程度
priority = df['priority'].values[0] # 优先级
# 将一个值映射成中文
info = {
'致命': 'fatal',
'严重': 'serious',
'一般': 'normal',
'提示': 'prompt',
'建议': 'advice'
}
# 进入Bug管理页面
driver.get('https://www.tapd.cn/tapd_fe/52952058/bug/list?page=1&confId=1152952058001018825')
# 点击“创建Bug”按钮
driver.find_element(By.XPATH,'//*[@id="root"]/div/div[2]/div[2]/div/div/div[1]/div[1]/div[1]/div[1]/div/button').click()
aa=driver.window_handles#将所有窗口的句柄(索引)赋值给aa的变量
driver.switch_to.window(aa[1])#选择第二个窗口
# 填写Bug信息
# 输入标题
driver.find_element(By.XPATH,'//*[@id="BugTitle"]').send_keys(df['title'].values[y])
#本地上传图片
uploadBtn =driver.find_element(By.XPATH,'//*[@id="file_input"]').send_keys(df['msg'].values[y])
# 处理人
driver.find_element(By.XPATH,'//*[@id="BugCurrentOwnerValue"]').click()
driver.find_element(By.XPATH,'//*[@id="BugCurrentOwnerValue"]').send_keys(df['processing staff']+Keys.ENTER)
# #严重程度
driver.find_element(By.XPATH, '//*[@id="BugSeverity"]').send_keys(df['order of severity'] + Keys.ENTER)
#优先级
driver.find_element(By.XPATH,'//*[@id="BugPriority"]').send_keys(df['priority']+Keys.DOWN+Keys.ENTER)
# 点击“创建”按钮
driver.find_element(By.XPATH,'//*[@id="_view"]').click()
print('创建bug成功',df['title'].values[y])
y+=1
driver.close()#关闭当前窗口
aa = driver.window_handles # 将所有窗口的句柄(索引)赋值给aa的变量
driver.switch_to.window(aa[0]) # 选择第一个窗口
TAPD自动创建bug优化版
最新推荐文章于 2024-09-23 18:57:12 发布