编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

python web控制testlink,导入测试用例

wxchong 2024-06-23 19:12:54 开源技术 10 ℃ 0 评论

from selenium import webdriver

from time import sleep

from lib.genernalfunction import *

# login test link

drv = webdriver.Chrome()

drv.get("http://192.168.68.248:8081/testlink/testlink_release_rep/login.php?note=expired")

nowhandle1 = drv.current_window_handle

print(nowhandle1)

print(drv.title)

drv.find_element_by_id("login").send_keys("polofan")

# drv.find_elements_by_link_text("login_div").send_keys("polofan")

drv.find_element_by_css_selector("#login_div > form > p:nth-child(4) > input[type=password]").send_keys("FKS110731fks")

drv.find_element_by_css_selector("#login_div > form > input[type=submit]:nth-child(5)").click()

print(drv.title)

# 搜索首页的编辑测试用例,并点击进入项目

drv.switch_to_frame("mainframe")

drv.find_element_by_xpath("//*[@id='testspecification_topics']/a[1]").click()

drv.switch_to_window(drv.current_window_handle)

drv.switch_to_frame("mainframe")

drv.switch_to_frame("treeframe")

sleep(1)

drv.find_element_by_xpath("//*[@id='extdd-6']").click()

dtfile = "../lib/Smart_test_case.xlsx"

drv.switch_to.default_content()

drv.switch_to_frame("mainframe")

drv.switch_to_frame("workframe")

drv.find_element_by_xpath("//*[@id='create_tc']").click()

excel_obj = ExcelOp(dtfile, 0)

# for i in range(23, 15391):

for i in range(27, 15391):

data = excel_obj.get_row_value(1, i) # 从第一列开始,读取第四行的所有数据。

print(data)

if data[0] != None:

b = data[0].splitlines()

dataend = ""

for i in range(len(b)):

dataend = dataend + b[i]

print (dataend)

# 点击测试套件,进入编辑测试用例页面

data = ["No desctiption" if x == None else x for x in data]

print(data)

if "预期结果" in dataend:

drv.find_element_by_xpath("//*[@id='testcase_name']").send_keys(data[1] + "-" + dataend), sleep(1)

drv.find_element_by_xpath("//*[@id='tc_new']/div[3]/div[2]/div/textarea").send_keys([data[2]+dataend]), sleep(1)

drv.find_element_by_xpath("//*[@id='tc_new']/div[3]/div[4]/div/textarea").send_keys(data[3]), sleep(1)

drv.find_element_by_xpath("//*[@id='tc_new'

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表