# Author:zhang
# -*- coding:utf-8 -*-
"""https://workyun.com/ 云端工作
"""
import unittest
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
import time
class LoginCase(unittest.TestCase):
def setUp(self):
"前置条件"
self.driver=webdriver.Chrome()
self.driver.maximize_window() #最大化
def driverxpath(self,xpath): #定义方法去查看页面元素是否粗在
for i in range(30):
try:
element = self.driver.find_element_by_xpath(xpath)
if element.is_displayed():
return self.driver.find_element_by_xpath(xpath)
break
except:pass
time.sleep(1)
else:
print("time-out")
def login(self,name,passwd): #定义登录的方法
"登录"
self.driver.get("http://www.effevo.com ")
self.driver.implicitly_wait(5)
self.driver.find_element_by_class_name("login-in").click()
self.driver.find_element_by_id("passname").send_keys(name)
self.driver.find_element_by_id("password").send_keys(passwd)
self.driver.find_element_by_class_name("ee-btn-ok").click() #登录参数化
def zeng(self,tuanname,hao):
"增加团队"
self.driverxpath(".//*[@id='leftNav']/div[2]/div[1]/ul/li/a/i").click()
time.sleep(5)
self.driverxpath("html/body/div[4]/div/div[2]/div/input").send_keys(tuanname) #团队名称
self.driverxpath("html/body/div[4]/div/div[3]/button[1]").click()
# 选择用户 self.driver.find_element_by_xpath("html/body/div[4]/div/div[2]/div/div[2]/div/div/div/div/div[1]/div/div/ul/li[1]/a").click()
self.driverxpath("html/body/div[4]/div/div[2]/div/div[2]/div/div/div/div/div[1]/div/input").send_keys(hao) #手机号码
self.driverxpath("html/body/div[4]/div/div[2]/div/div[2]/div/div/div/div/div[1]/div/div/button").click() #选择管理员
time.sleep(3)
self.driverxpath("html/body/div[4]/div/div[2]/div/div[2]/div/div/div/div/div[1]/div/div/ul/li[1]/a").click()
time.sleep(3)
self.driverxpath("/html/body/div[4]/div/div[3]/button[1]").click()
time.sleep(10)
def tianjia(self,tihao):
"添加成员"
# self.driver.implicitly_wait(30)
# self.driver.find_element_by_xpath(".//*[@id='mCSB_1_container']/li[2]/a/div[1]").click()
self.driver.implicitly_wait(35)
self.driverxpath(".//*[@id='team-index']/div/ul/li[2]/span").click()
self.driver.find_element_by_css_selector(".user-new-text").click()
self.driver.find_element_by_css_selector(".user-invite-input.ng-pristine.ng-valid").send_keys(tihao)
self.driverxpath("html/body/div[4]/div/div[2]/div/div[2]/div/div/div/div/div[1]/div/div/button").click()
time.sleep(5)
self.driverxpath("html/body/div[4]/div/div[2]/div/div[2]/div/div/div/div/div[1]/div/div/ul/li[3]/a").click()
self.driverxpath("html/body/div[4]/div/div[3]/button[1]").click() #保存新增的用户
def delte(self,mima):
"删除端对"
self.driver.refresh() #刷新页面
time.sleep(20) #显示等待
self.driverxpath(".//*[@id='mCSB_1_container']/li[2]/a/div[1]").click() #点击下左侧的团队名
time.sleep(20)
self.driverxpath(".//*[@id='team-index']/div/ul/li[3]/span").click() #设置按钮
self.driverxpath(".//*[@id='team-index']/ui-view/div/p[10]/button").click()
self.driverxpath(".//*[@id='re-verify-password-modal']/div/div/div[2]/input").send_keys(mima)
self.driverxpath(".//*[@id='re-verify-password-modal']/div/div/div[3]/div/button[2]").click()
time.sleep(5)
# def test_login(self):
# "这个是正常的e"
# self.login("[email protected]","x1400184")
# time.sleep(5)
# s=self.driver.title
# self.assertIn(u"列表",s)
# self.driver.implicitly_wait(10)
# def test_zeng(self):
# #增加团队
# self.login("[email protected]","x1460184")
# time.sleep(5)
# self.zeng("ceshi","[email protected]")
# #self.assertEqual()
# #s=self.driver.find_element_by_link_text(".//*[@id='mCSB_1_container']/li[2]/a/div[1]"). #怎样进行验证
def xiangmu(self,projectname,description):
"在团队下面添加项目"
self.driver.refresh() #刷新页面
time.sleep(20)
self.driverxpath(".//*[@id='mCSB_1_container']/li[2]/a/div[1]").click() #点击团队名称
self.driverxpath(".//*[@id='team-project-overview']/div[5]/div").click() #点击创建项目
self.driverxpath(".//*[@id='project-edit-modal']/div/div/div[2]/div[2]/input").send_keys(projectname) #项目名
self.driverxpath(".//*[@id='project-edit-modal']/div/div/div[2]/div[3]/textarea").send_keys(description) #项目描述
self.driverxpath(".//*[@id='project-edit-modal']/div/div/div[3]/div/span[2]").click() #保存项目
def renwu(self,renwuname):
self.driver.refresh() #刷新页面
time.sleep(3)
self.driver.refresh()
time.sleep(20)
self.driverxpath(".//*[@id='mCSB_1_container']/li[2]/a/div[1]").click() #点击团队名称
self.driverxpath(".//*[@id='team-project-overview']/div[2]/div/table/tbody/tr/td[1]").click() #点击项目
#self.driver.switch_to(".//*[@id='mCSB_2_container']")
# WebDriverWait(self.driver,20).until(lambda x:x.find_element__by_xpath(".//*[@id='mCSB_2_container']/div[2]/input")).click
self.driverxpath(".//*[@id='mCSB_2_container']/div[2]/input").click
# self.driver.find_element_by_xpath(".//*[@id='mCSB_2_container']/div[2]/input").click() #点击任务名
#//*[@id='mCSB_2_container']/div[2]/input
#WebDriverWait(self.driver, 20).until(lambda x: x.find_element_by_xpath(".//*[@id='mCSB_2_container']/div[2]/input"))
self.driverxpath(".//*[@id='mCSB_2_container']/div[2]/input").send_keys(renwuname)
self.driver.switch_to.default_content()
def test_dele(self):
#删除团队
self.login("[email protected]","01660184")
time.sleep(5)
self.zeng("rrrr","[email protected]")
self.tianjia("[email protected]")
time.sleep(5)
self.xiangmu("xinu","beautiful")
self.renwu("renwuming")
def tearDown(self):
"后置条件"
time.sleep(5)
# self.driver.quit()
if __name__=='__main__':
unittest.main() #执行用例