コード例 #1
0
ファイル: testsuite_06.py プロジェクト: hufengping/percolata
 def test_01_login(self):
     u'''登录'''
     driver = self.driver
     driver.get(self.base_url)
     logins = root.getElementsByTagName('user')
     #获得null 标签的username、passwrod 属性值
     username=logins[0].getAttribute("username")
     password=logins[0].getAttribute("password")
     prompt_info = logins[0].firstChild.data
     #登录
     Autotest.login(self,username,password)
     #获取断言信息进行断言
     text = driver.find_element_by_xpath("/html/body/div[2]/div/div[3]/div/div[2]/div/table/tbody/tr/td").text
     try:
         self.assertEqual(text,prompt_info)
     except AssertionError,e:
         print e
         print ' 请查看截图文件 '+now+'.png'
         driver.get_screenshot_as_file(xmlpath2+"log\\"+now+U'登录信息验证不通过.png')#如果没有找到上面的元素就截取当前页面。
コード例 #2
0
ファイル: testsuite_05.py プロジェクト: hufengping/percolata
 def test_01_login(self):
     u"""login"""
     driver = self.driver
     driver.get("http://manager.percolata.com/")
     logins = root.getElementsByTagName("user")
     # 获得null 标签的username、passwrod 属性值
     username = logins[0].getAttribute("username")
     password = logins[0].getAttribute("password")
     prompt_info = logins[0].firstChild.data
     # 登录
     Autotest.login(self, username, password)
     # 获取断言信息进行断言
     text = driver.find_element_by_xpath("/html/body/div[2]/div/div[3]/div/div[2]/div/table/tbody/tr/td").text
     try:
         self.assertEqual(text, prompt_info, u"登录信息验证失败,请检查网络或登录信息!")
     except AssertionError, e:
         print e
         print " 请查看截图文件 " + now + ".png"
         driver.get_screenshot_as_file(xmlpath2 + "log\\" + now + u"登录信息验证不通过.png")  # 如果没有找到上面的元素就截取当前页面。
コード例 #3
0
ファイル: run_01_test.py プロジェクト: hufengping/percolata
#获取当前时间
now = time.strftime("%Y-%m-%d_%H_%M_%S")
#定义报告存放地点
xmlpath = os.path.split(os.path.realpath(__file__))[0] #获取当前路径
xmlpath2 = xmlpath.split('src')[0]
filename = xmlpath2+'log\\'+now+'result.html'
source1 = xmlpath2+r"log" 
target_dir1 = "D:\\jenkins\\workspace\\POS_001"
#获取ini路径
inipath = xmlpath2+'testdata\\config.ini' 
#ini文件载入
config = ConfigParser.ConfigParser()
config.readfp(open(inipath))
mail_from = config.get('mail','from')
mail_to = config.get('mail', 'to')


fp = file(filename, 'wb')
runner =HTMLTestRunner.HTMLTestRunner(
                                      stream=fp,
                                      title=u'个险保全系统测试报告',
                                      description=u'用例执行情况:')
if __name__ == '__main__':
    #检查数据文件是否需要更新
    db2file.updataFile()
    alltestnames = creatsuite()
    runner.run(alltestnames)
    fp.close()
    reportname = Autotest.newfile(xmlpath2+'log\\')
    Autotest.sendMail(mail_from,mail_to, '核心系统自动化运行结果', reportname)   
    Autotest.copynewfiles(source1,target_dir1)
コード例 #4
0
ファイル: testsuite_06.py プロジェクト: hufengping/percolata
 def tearDownClass(cls):
     Autotest.dataDelline(db2file.case3datafile) #删除一行数据文件
     cls.driver.quit()
コード例 #5
0
ファイル: all_test.py プロジェクト: hufengping/percolata
now = time.strftime("%Y-%m-%d_%H_%M_%S")
# Define director for test report
xmlpath = os.path.split(os.path.realpath(__file__))[0]  # Execution path
xmlpath2 = xmlpath.split('src')[0]
LOGFILE = xmlpath2 + 'log/' + now + '_result.html'

# read credentials
CREDENTIALS_FILE = 'public/.credentials'
config = configparser.ConfigParser()
config.read(CREDENTIALS_FILE)
mail_from = config['MAIL']['FROM']
mail_to = config['MAIL']['TO']

fp = file(LOGFILE, 'wb')
runner = HTMLTestRunner.HTMLTestRunner(
	stream=fp,
	title=u'Percolata Test Repot',
	description=u'Test case execution:')
if __name__ == '__main__':
	# Check test data for updates
	#db2file.updataFile()

	alltestnames = creatsuite()
	runner.run(alltestnames)
	fp.close()
	reportname = Autotest.newfile(xmlpath2 + 'log/')
	f = open(reportname)
	txt = f.read()
	Autotest.mail(mail_to, 'Auto test results', txt, reportname)
# copy files to jenkins log
コード例 #6
0
ファイル: test.py プロジェクト: hufengping/percolata
__author__ = "fengpinghu"
# coding=utf-8
import os
from public import Autotest

xmlpath = os.path.split(os.path.realpath(__file__))[0]  # Execution path
xmlpath2 = xmlpath.split("src")[0]
reportname = Autotest.newfile(xmlpath2 + "log/")

f = open(reportname)
txt = f.read()
Autotest.mail("*****@*****.**", "Test Report", txt, reportname)