import time
from selenium import webdriver
from selenium.webdriver.common.by import By
d = webdriver.Firefox()
d.get('http://127.0.0.1/zentao')
'''登录'''
d.find_element(By.CSS_SELECTOR, '#account').send_keys('admin')
d.find_element(By.XPATH, '//*[@class="form-control" and @type="password" and @name="password"]').send_keys('QWERASDF123456')
d.find_element(By.CSS_SELECTOR, '#submit').click()
time.sleep(3)
'''点组织,添加用户'''
d.find_element(By.LINK_TEXT, '组织').click()
d.find_element(By.XPATH,'//*[@href="/zentao/user-create-0.html" and @class="btn btn-primary"]').click()
# 添加用户
d.find_element(By.CSS_SELECTOR, '#account').send_keys('test1')
d.find_element(By.CSS_SELECTOR, '#password1').send_keys('TEST1test1test1') # 密码
d.find_element(By.CSS_SELECTOR, '#password2').send_keys('TEST1test1test1') # 重复密码
d.find_element(By.CSS_SELECTOR, '#realname').send_keys('测试1号') # 真实姓名
d.find_element(By.CSS_SELECTOR, '#verifyPassword').send_keys('QWERASDF123456') # 系统登录密码
time.sleep(3)
d.execute_script('window.scrollBy(0,30000)') # 拉滚动条到最下
d.find_element(By.ID, 'submit').click() # 提交
'''添加一个测试用例'''
d.find_element(By.LINK_TEXT, '测试').click()
d.find_element(By.LINK_TEXT, '用例').click()
# time.sleep(2)
# 建用例
# d.find_element(By.XPATH, '//*[@href="/zentao/testcase-create-1-0-0.html" and @class="btn btn-info"]').click()
d.find_element(By.XPATH,'//*[@href="/zentao/testcase-create-1-0-0.html" and @class="btn btn-primary"]').click()
#输入标题
d.find_element(By.NAME, 'title').send_keys('连缘站立状态自动中断')
d.execute_script('window.scrollBy(0,30000)') # 拉滚动条到最下
# time.sleep(2)
d.find_element(By.XPATH, '//*[@class="btn btn-wide btn-primary"]').click() # 提交
time.sleep(6)
d.quit()
07-19
10-16
458
07-16