精华内容
下载资源
问答
  • Python3+Selenium3实现web自动化测试项目入门 环境及工具 · 系统:windows 64位 · 开发工具:Python 3 · 自动化测试工具 Selenium3 · 脚本工具 sublime Text3 · 浏览器:Firefox Selenium作为WebUI自动化测试...

    Python3+Selenium3实现web自动化测试项目入门

    环境及工具

    · 系统:windows 64位
    · 开发工具:Python 3
    · 自动化测试工具 Selenium3
    · 脚本工具 sublime Text3
    · 浏览器:Firefox

    Selenium作为WebUI自动化测试工具的优势

    · 主流且开源
    · 支持主流浏览器如Firefox、chrome、IE
    · 支持多种开发语言如python、Java、PHP
    · 跨平台,支持多种操作系统mac、windows、linux等64位系统
    常用的自动化测试工具

    安装说明

    1. 安装Python3
    2. 自动化测试环境搭建Selenium3安装:
      (1)下载地址:https://pypi.org/project/selenium/
      (2)在解压好的目录下进行安装 python setup.py install
    3. 安装浏览器驱动
      火狐:https://github.com/mozilla/geckodriver/releases
      下载driver、拷贝到浏览器安装路径、配置环境变量

    selenium打开Firefox

    from selenium import webdriver
    driver = webdriver.Firefox()
    driver.get("https://baidu.com")
    

    selenium定位元素的8种方法

    1. 采用ID 属性 :find_element_by_id()
    2. 采用class name属性:find_element_by_class_name()
    3. 采用class name属性:find_element_by_name()

    定位到元素后的方法

    clear() 清空;send_keys() 输入; back() 后退页面;maximize_windows() 最大化窗口; click() 点击; submit() 提交表单

    定位到元素后的属性

    tag_name: 标签名
    text: 文本内容

    1. 采用tag_name属性:find_element_by_tag_name()
    2. 超链接内容:find_element_by_link_text()
    3. 超链接内容定位,模糊匹配:find_element_by_partial_link_text()
    4. css_selector: find_element_by_css_selector()
      根据CSS属性定位,一般class是用.标记,id是用#标记,定位方式也会比xpath快
      技巧:通过firebug的拷贝css路径
      路径:检查元素-》右键-》复制-》css选择器
    5. xpath: find_element_by_xpath()
      xpath语法

    ActionChains模拟用户行为

    需要模拟鼠标才能进行的情况,如单击,双击,右击,拖拽等
    selenium提供了一个类来处理这类事件selenium.webdriver.common.action_chains.ActionChains(driver)

    导入模块

    from selenium.webdriver.common.action_chains import ActionChains
    

    调用ActionChains的方法时不会立即执行,会将所有的操作按顺序存放在一个队列里,当调用perform()方法时,队列中的事件会依次执行
    如:

    ActionChains(driver).click(ele).perform()
    

    事件列表:

    perform() 执行链中的所有动作
    
    click(on_element=None) 单击鼠标左键
    
    context_click(on_element=None) 点击鼠标右键
    
    double_click(on_element=None) 双击鼠标左键
    
    move_to_element(to_element) 鼠标移动到某个元素
    		
    ele.send_keys(keys_to_send) 发送某个词到当前焦点的元素
    
    ========== 不常用 ==========
    
    click_and_hold(on_element=None) 点击鼠标左键,不松开
    
    release(on_element=None) 在某个元素位置松开鼠标左键
    
    key_down(value, element=None) 按下某个键盘上的键
    
    key_up(value, element=None) 松开某个键
    
    drag_and_drop(source, target) 拖拽到某个元素然后松开
    
    drag_and_drop_by_offset(source, xoffset, yoffset) 拖拽到某个坐标然后松开
    
    move_by_offset(xoffset, yoffset) 鼠标从当前位置移动到某个坐标
    
    move_to_element_with_offset(to_element, xoffset, yoffset) 移动到距某个元素(左上角坐标)多少距离的位置
    
    send_keys_to_element(element, keys_to_send) 发送某个键到指定元素
    

    网页等待时间

    网页需要加载对应的资源文件,页面渲染,窗口处理等等

    1. 强制等待:
    from time import sleep   
    sleep(5)  # 强制等待5秒再执行下一步,缺点是不管资源是不是完成,都必须等待
    
    1. 隐性等待:
      设置了一个最长等待时间,如果在规定时间内网页加载完成,则执行下一步,否则一直等到时间截止,然后执行下一步。弊端就是程序会一直等待整个页面加载完成,到浏览器标签栏那个加载圈不再转
      注意:对driver起作用,所以只要设置一次即可,没有必要到处设置,在unittest框架中放入Test_setUp()中
    driver.implicitly_wait(10)  # 隐性等待,最长等10秒
    
    1. 显性等待:
      WebDriverWait 需要配合 until和until_not,程序每隔N秒检查一次,如果成功,则执行下一步,否则继续等待,直到超过设置的最长时间
      语法:WebDriverWait(driver, timeout, poll_frequency=0.5, ignored_exceptions=None)
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    url = 'https://baidu.com'
    # url = 'https://www.tmall.com'
    # 拿到diver
    driver = webdriver.Firefox()
    
    
    # 跳转网页
    driver.get(url)
    # print(driver.title) # 使用python判断网页名称是否正确
    
    try:
    	# 显性等待
        search_ele = WebDriverWait(driver,5,0.5).until(EC.presence_of_element_located((By.ID,"kw")))
        search_ele.send_keys("小D课堂")
        print("资源加载成功")
        print(driver.title)
    except:
    	print("资源加载失败,发送报警邮件或短信")
    finally:
    	print("不管有没有成功,都打印,用于资源清理")
    	driver.quit() # 退出
    

    弹窗处理

    弹窗常用方法(需要先切换窗口 switch_to_alert() )
    accept() 表示接受
    dismiss() 表示取消

    错误截图

    driver.get_screenshot_as_file("./error_png.png")

    单元测试unittest

    单元测试是指对软件中的最小可测试单元进行检查和验证。对于单元测试中单元的含义,一般来说,要根据实际情况去判定其具体含义。
    如C语言中单元指一个函数,Java中指一个类,而图形化的软件可以指一个窗口或菜单。
    总的来说单元就是人为规定的最小的被测功能模块。单元测试是在软件开发过程中要进行的最低级别的测试活动,软件的独立单元将在与程序的其他部分相隔离的情况下进行测试。

    unittest是python中的单元测试框架
    unittest = TestCase + Testresult 执行用例 + 结果

    # -*- coding: UTF-8 -*-
    # 1、用import语句引入unittest模块
    import unittest
    # 2、测试的类都继承于TestCase类
    class UserTestCase(unittest.TestCase):
        # setUp() 测试前的初始化工作
        # 所有类中方法的入参为self,定义方法的变量也要“self.变量
        def setUp(self):
            pass
        # tearDown()测试后的清除工作
        def tearDown(self):
            pass
        # 定义测试用例,以“test”开头命名的方法,方法的入参为self
        def test_name(self): 
            pass    
    if __name__ == '__main__':
        # unittest.main()方法会搜索该模块下所有以test开头的测试用例方法,并自动执行它们
        unittest.main()
        #  输出 成功是 . 失败是 F
    

    TestSuite测试套件

    unittest.TestSuite() 类来表示一个测试用例集,用来确定测试用例的顺序,哪个先执行哪个后执行

    TextTestRunner(verbosity) 文本测试用例运行器 verbosity参数可以控制执行结果的输出,0 是简单报告、1 是一般报告、2 是详细报告 默认1 会在每个成功的用例前面有个“.” 每个失败的用例前面有个 “F”

    run()方法是运行测试套件的测试用例,入参为suite测试套件

    # -*- coding: UTF-8 -*-
    import unittest
    
    class XdclassTestCase(unittest.TestCase):
    
        def setUp(self):
            self.age = 32
            self.name = "小D课堂"
            print(" setUp method=======")
    
    
        def tearDown(self):
            print(" tearDown method=======")
            #断言是否相同
            self.assertEqual('foo'.upper(), 'FOO')
    
    
        def test_one(self):        
            print(" test_one 二当家小D 来了")
            #断言是否相同
            self.assertEqual(self.name, "小D课堂",msg="名字不对")
    
    
        def test_two(self):
            print(" test_two 前端 来了")
            #断言是否为 true, msg是断言错误的提示信息
            self.assertFalse('XD'.isupper(), msg="不是大写")
            
    
    
        def test_three(self):
            print(" test_three 后端 来了")
            self.assertEqual(self.age,32)
    
    
    
        def test_four(self):
            print(" test_four 小D课堂官网上线啦 https://www.xdclass.net")
            self.assertEqual(self.age,32)
    
    
    
    
    if __name__ == '__main__':
    
        # 利用unittest执行流程测试而非单元测试,需要控制unittest的执行顺序
    
        # 用unittest.TestSuite()类来表示一个测试用例集,以确定测试用例的执行顺序
        suite = unittest.TestSuite()
        suite.addTest(XdclassTestCase("test_one"))
        suite.addTest(XdclassTestCase("test_two"))
        suite.addTest(XdclassTestCase("test_three"))
        suite.addTest(XdclassTestCase("test_four"))
    
        # unittest.TextTestRunner()是文本测试用例运行器,通过该类下的run()方法来运行suite所组装的测试用例,入参为suite测试套件
        # verbosity参数可以控制执行结果的输出,0 是简单报告、1 是一般报告(默认)、2 是详细报告
        runner = unittest.TextTestRunner(verbosity=2)
        runner.run(suite)
    

    HTMLTestRunner生成测试报告

    HTMLTestRunner 是 Python 标准库的 unittest 模块的一个扩展,它可以生成 HTML的 测试报告,无法通过pip安装。python2和python3,语法不一样,导致HTMLTestRunner在python3不兼容。

    # -*- coding: UTF-8 -*-
    
    import unittest
    # 导入HTMLTestRunner模块,HTMLTestRunner 是 Python 标准库的 unittest 模块的一个扩展,它可以生成 HTML的 测试报告,无法通过pip安装。 
    # 首先要下 HTMLTestRunner.py 文件,将下载的文件放入…\python\Lib目录下 (或者同个路径)
    import HTMLTestRunner
    import time
    
    
    class XdclassTestCase(unittest.TestCase):
        def setUp(self):
            self.age = 32
            self.name = "小D课堂"
            print(" setUp method=======")
    
    
        def tearDown(self):
            print(" tearDown method=======")
            #断言是否相同
            self.assertEqual('foo'.upper(), 'FOO')
    
    
        def test_one(self):
            # 测试用例报告优化,添加说明
            u"登录测试" 
    
            print(" test_one 二当家小D 来了")
            #断言是否相同
            self.assertEqual(self.name, "小D课堂",msg="名字不对")
    
    
        def test_two(self):
            u"跳转测试"
            print(" test_two 前端 来了")
            #断言是否为 true, msg是断言错误的提示信息
            self.assertFalse('XD'.isupper(), msg="不是大写")
            
    
    
        def test_three(self):
            print(" test_three 后端 来了")
            self.assertEqual(self.age,32)
    
    
    
        def test_four(self):
            print(" test_four 小D课堂官网上线啦 https://www.xdclass.net")
            self.assertEqual(self.age,32)
    
    
    
    
    if __name__ == '__main__':
        suite = unittest.TestSuite()
        suite.addTest(XdclassTestCase("test_two"))
        suite.addTest(XdclassTestCase("test_one"))
        
        suite.addTest(XdclassTestCase("test_three"))
        suite.addTest(XdclassTestCase("test_four"))
    
        #verbosity参数可以控制执行结果的输出,0 是简单报告、1 是一般报告(默认)、2 是详细报告
        #runner = unittest.TextTestRunner(verbosity=2)
        #runner.run(suite)
    
        file_prefix = time.strftime("%Y-%m-%d %H_%M_%S", time.localtime())
    
        with open('./'+file_prefix+'_result.html','wb') as fp:
    
            runner = HTMLTestRunner.HTMLTestRunner(stream=fp,title=u'<小D课堂>test report', description=u'用例执行情况:')
            runner.run(suite)
    
    
    
        # #文件名中加了当前时间,每次生成不同的测试报告
        # file_prefix = time.strftime("%Y-%m-%d %H_%M_%S",time.localtime())
    
        # #创测试报告的result.html文件,此时还是个空文件   
        # #wb 以二进制格式打开一个文件只用于写入。如果该文件已存在则将其覆盖。如果该文件不存在,创建新文件
        # fp = open('./'+file_prefix+'_result.html', 'wb')
        # #stream 定义报告所写入的文件;title 为报告的标题;description 为报告的说明与描述
        # runner =HTMLTestRunner.HTMLTestRunner(stream=fp, title=u'<小D课堂>test report', description=u'用例执行情况:')
    
        # #运行测试容器中的用例,并将结果写入的报告中
        # runner.run(suite)
    
        # #关闭文件流,将HTML内容写进测试报告文件
        # fp.close()
    

    发送测试报告邮件

    from : xxx@xx.com 发件人
    to: xxx@xx.com 收件人
    subject: hello 主题
    body: 欢迎 内容体

    邮件传输协议

    SMTP协议:全称为 Simple Mail Transfer Protocol,简单邮件传输协议。它定义了邮件客户端软件和SMTP邮件服务器之间,以及两台SMTP邮件服务器之间的通信规则

    POP3协议:全称为 Post Office Protocol,邮局协议。它定义了邮件客户端软件和POP3邮件服务器的通信规则

    IMAP协议:全称为 Internet Message Access Protocol,Internet消息访问协议,它是对POP3协议的一种扩展,也是定义了邮件客户端软件和IMAP邮件服务器的通信规则

    参考资料

    #coding=utf-8
    import smtplib
    import os ,time,datetime
    from email.header import Header
    from email.mime.multipart import MIMEMultipart
    from email.mime.text import MIMEText 
    
    
    
    #邮件信息配置. 授权码 xdclass123
    sender = 'waitforxy@126.com'
    receiver = 'waitfordev@126.com' 
    auth_code = 'xdclass123'  #设置客户端授权码,不是密码
    
    smtpserver = 'smtp.126.com'
    subject = '自动化测试报告'
    
    
    #读取文件内容
    f = open("./result.html", 'rb')
    mail_body = f.read()
    f.close()
    
    
    
    #HTML 形式的文件内容
    html = MIMEText(mail_body, _subtype='html', _charset='utf-8')
    html['Subject'] = subject
    html['from'] = sender
    html['to'] = receiver
    
    
    
    # html附件 将测试报告放在附件中发送
    att1 = MIMEText(mail_body, 'base64', 'gb2312')
    att1["Content-Type"] = 'application/octet-stream'
    att1["Content-Disposition"] = 'attachment; filename="XdclassTestReport.html"'  # 这里的filename可以任意写
    
    
    
    msg = MIMEMultipart()
    msg['Subject'] = subject  # 邮件的标题
    msg['from'] = sender
    msg['to'] = receiver
    msg.attach(html)  # 将html附加在msg里
    msg.attach(att1)  # 新增一个附件 
    
    
    
    #连接 登录 上smtp服务器
    smtp = smtplib.SMTP() 
    smtp.connect('smtp.126.com') 
    smtp.login(sender, auth_code) 
    
    #发送邮件
    smtp.sendmail(sender, receiver, msg.as_string()) 
    smtp.quit()
    

    如出现以下错误:
    smtplib.SMTPDataError: (554, b’DT:SPM 163 smtp9,DcCowAAXV49UMXtfVYYRJw–.35470S2 1601909076,please see http://mail.163.com/help/help_spam_16.htm?ip=123.151.21.189&hostid=smtp9&time=1601909076’)
    可能是邮件内容包含未被允许的信息,或被系统识别为垃圾邮件
    解决办法:1. 确保发件人和收件人为常用联系人(在列表中),msg中From和To使用发件人和收件人真实邮箱地址
    解决链接

    实战

    需求1:百度登录测试

    # coding=utf-8
    '''
    Created on 2016-7-22
    @author: Jennifer
    Project:登录百度测试用例
    '''
    from selenium import webdriver
    import unittest, time
    from time import sleep
    # from selenium.webdriver.common.action_chains import ActionChains
    
    class BaiduLoginTest(unittest.TestCase):
    
    	def setUp(self):
    		print("---开始测试---")
    		self.driver = webdriver.Firefox()
    		self.driver.implicitly_wait(10)
    		self.base_url = "https://www.baidu.com/"
    
    	def tearDown(self):
    		print("---结束测试---")
    		self.driver.quit()
    
    	def test_Login(self):
    		u"百度登录测试"
    		driver = self.driver
    		driver.get(self.base_url)
    		# 登录键
    		login_ele = driver.find_element_by_css_selector(".s-top-login-btn")
    		# 触发点击事件
    		login_ele.click()
    		# 选择登录方式
    		driver.find_element_by_css_selector("#TANGRAM__PSP_11__footerULoginBtn").click()
    		# 出现用户名登录界面 输入用户名及密码并登录
    		driver.find_element_by_css_selector("#TANGRAM__PSP_11__userName").send_keys("15222629237") # 输入账号
    		
    		driver.find_element_by_css_selector("#TANGRAM__PSP_11__password").send_keys("330sds3dsd")   # 输入密码
    		
    		driver.find_element_by_css_selector("#TANGRAM__PSP_11__submit").click()
    
    		# 获取用户名检测是否登录成功
    		user_ele = driver.find_element_by_css_selector(".user-name")
    		# ActionChains(driver).move_to_element(usern_ele)
    		self.assertEqual(user_ele.text,"清dd",msg="登录失败")
    
    
    if __name__ == '__main__':
    	unittest.main()
    

    需求2:有道翻译测试

    # coding=utf-8
    '''
    Created on 2016-7-22
    @author: Jennifer
    Project: 有道翻译测试用例
    '''
    from selenium import webdriver
    import unittest,time
    # from time import sleep
    # from selenium.webdriver.common.action_chains import ActionChains
    
    class YoudaoTransTest(unittest.TestCase):
    
    	def setUp(self):
    		print("---开始测试---")
    		self.driver = webdriver.Firefox()
    		self.driver.implicitly_wait(10)
    		self.base_url = "http://fanyi.youdao.com/"
    
    	def tearDown(self):
    		print("---结束测试---")
    		self.driver.quit()
    
    	def test_Trans(self):
    		u"有道翻译测试"
    		driver = self.driver
    		driver.get(self.base_url)
    		# 找到输入框输入翻译内容
    		driver.find_element_by_css_selector("#inputOriginal").send_keys("你好")
    		# 触发点击事件
    		# driver.find_element_by_id("transMachine").click()
    		trans_ele = driver.find_element_by_css_selector("#transTarget > p:nth-child(1) > span:nth-child(1)")
    		print(trans_ele.text)
    		self.assertEqual(trans_ele.text,"hello",msg="翻译出错")
    
    
    if __name__ == '__main__':
    	unittest.main()
    
    

    需求3:整合生成测试报告以邮件发送

    # coding=utf-8
    '''
    Created on 2016-7-22
    @author: Jennifer
    Project: mail
    '''
    import smtplib
    from email.mime.multipart import MIMEMultipart
    from email.mime.text import MIMEText
    from email.header import Header
    
    class MailUtils():
        # 表示一个类方法,不需要实例化,可以直接调用
        @classmethod
        def send_test_report(cls):
    
        	# 邮件信息配置,授权码
        	sender = "1522435456@163.com"
        	receiver = "3330839834@qq.com"
        	auth_code = "WJLOXWQGBMKGLAQO" #设置客户端授权码,不是密码
    
        	smtpserver = "smtp.163.com" # 163邮件服务器地址
        	subject = "Web自动化测试报告"
    
        	# 读取文件内容
        	with open("./result.html","rb") as f:
        		mail_body = f.read()
    
        	# HTML 形式的邮件内容
        	html = MIMEText(mail_body,_subtype="html",_charset='utf-8')
        	html['Subject'] = subject
        	html['from'] = sender
        	html['to'] = receiver
    
        	# html附件 将测试报告放在附件中发送
        	att1 = MIMEText(mail_body,'base64','gb2312')
        	att1["Content-Type"] = 'application/octet-stream'
        	att1["Content-Disposition"] = 'attachment; filename="WebTestReport"'
    
        	msg = MIMEMultipart()
        	msg['Subject'] = subject # 邮件主题
        	msg['from'] = sender
        	msg['to'] = receiver
        	msg.attach(html) # 将html附加在msg里
        	msg.attach(att1) # 新增附件
    
        	# 连接 登录 上smtp服务器
        	smtp = smtplib.SMTP()
        	smtp.connect("smtp.163.com")
        	smtp.login(sender,auth_code)
    
        	smtp.sendmail(sender,receiver,msg.as_string())
        	# smtp.sendmail(sender,receiver,html.as_string())
        	smtp.quit()
    
    
    # coding=utf-8
    '''
    Created on 2016-7-22
    @author: Jennifer
    Project: Web测试用例
    '''
    
    import unittest,time,HTMLTestRunner
    from Baidu_login import BaiduLoginTest
    from Youdao_Trans import YoudaoTransTest
    from new_mail import MailUtils
    
    # 创建测试集合
    def create_suite():
    
    	suite = unittest.TestSuite()
    	suite.addTest(unittest.makeSuite(BaiduLoginTest))
    	suite.addTest(unittest.makeSuite(YoudaoTransTest))
    	return suite
    
    if __name__ == '__main__':
    	
    	suite = create_suite()
    
    	# 文件名加当前时间
    	# file_prefix = time.strftime("%Y-%m-%d %H_%M_%S",time.localtime())
    
    	# with open("./"+file_prefix+"_result.html","wb") as fp:
    	with open("./result.html","wb") as fp:
    		runner = HTMLTestRunner.HTMLTestRunner(stream=fp,title=u"Web 项目测试报告",description="测试用例执行情况",verbosity=2)
    		runner.run(suite)
    
    	MailUtils.send_test_report()
    
    
    展开全文
  • 为避免每次版本迭代上线后,回归不全导致未改动的模块产生新的问题,同时为了解放重复的流程回归测试,所以有了这个业务流程自动化回归项目的初版。 项目基于Python2.7、selenium3.0、unittest框架组合而成 使用...

    为避免每次版本迭代上线后,回归不全导致未改动的模块产生新的问题,同时为了解放重复的流程回归测试,所以有了这个业务流程自动化回归项目的初版。


    项目基于Python2.7、selenium3.0、unittest框架组合而成
    使用POM模式,即Page Object Model页面对象模式来使测试代码更易阅读、维护、复用
        POM下,应用程序每一个页面都有一个对应的page class
        每一个page class维护改web页的元素集和操作这些元素的方法
        page class中的方法都是相对应的业务场景


    主要目录:(和后台系统中的项目保持一致)
        --base
            --各目录中的__init__.py是为了声明当前目录是一个Package,便于其他模块import调用
            --Base.py   各公共方法的二次封装以及定义,如抛弃selenium最外层的定位方法,直接传入By类的变量,既避免过长的函数定义也规范了元素定位的变量定义;同时由于系统中部分控件用鼠标点击不好定位,不能灵活
               的传参,所以根据控件类型封装各type_xx函数,调用js来替代原生方法;考虑到代码的运行速度远高于浏览器的渲染速度以及网络加载速度,在隐式等待30秒的基础上,基类中的定位方法在操作前都设置强制等待
               0.2s的时间,避免page页中的每个操作后都加强制等待时间的繁琐
            --Login.py  登录页的元素定位及操作方法
            --Page.py   各web页面的实际地址,供其他pageClass中的操作方法调用
            --SQL.py    对数据库的操作,目前只做对测试数据的清理
            --test.py   自动化测试的入口,继承unittest框架,实例化各pageClass并调用其对应的业务操作方法。目前只定义了一个用例,因为当前关心的是流程,不是各case。后期稳定的基础上,加入大量case后,会使用
                套件去管理各case
        --user
            --系统中用户管理模块中的各page
        --house
            --系统中的房源管理模块中的各page
        --contract
            --系统中的合同管理模块中的各page
        --......






    展开全文
  • #HouseContracPage.py #新增委托合同 # -*- coding:utf8 -*- from base.Base import Base from base import Page from selenium.webdriver.common.by import By from selenium.common.exceptions import ...

    #HouseContracPage.py

    #新增委托合同

    # -*- coding:utf8 -*-
    
    
    from base.Base import Base
    from base import Page
    from selenium.webdriver.common.by import By
    from selenium.common.exceptions import NoSuchElementException
    import time
    from base.Base import log
    from base.Base import consoleLog
    
    
    class HouseContractPage(Base):
        houseSearchMould = {
            'residential_name_loc' : (By.ID,'residential_name_house_code_search'),
            'search_button_loc' : (By.ID,'search_btn'),
            'tr_house' : (By.CSS_SELECTOR,'tr[datagrid-row-index="0"]'),
            'add_house_contract_button' : (By.CSS_SELECTOR,'#edit_btn + button')
        }
        contractSearchMould = {
            'contract_num_loc': (By.CSS_SELECTOR, '#contract_num_search + span > input:nth-child(1)'),
            'search_button_loc': (By.ID, 'search_btn'),
            'tr_contract': (By.CSS_SELECTOR, 'tr[datagrid-row-index="0"]'),
            'edit_loc': (By.ID, 'edit_btn')
        }
        addHouseContractMould = {
            'edit_loc' : (By.CSS_SELECTOR,'#edit_btn + button'), #列表页加载的等待元素
            'delete_button': (By.ID, 'del_btn'),  # 删除
            'delete_button_confirm': (By.CSS_SELECTOR, '.dialog-button.messager-button > a:nth-child(1) > span'),  # 删除确认
            #合同信息
            'tab_info_loc' : (By.CSS_SELECTOR ,'.tabs-inner'), #0-合同信息、1-租金明细、2-业主信息、3-资料上传
            'inside_space_loc' : (By.CSS_SELECTOR ,'#first_contract_base > table > tbody > tr:nth-child(3) > td:nth-child(4) > span > input:nth-child(1)'), #使用面积
            'rent_loc' : (By.CSS_SELECTOR, 'input#rent + span > input:nth-child(1)'),   #房租
            'parking_loc' : (By.CSS_SELECTOR, 'input#parking+ span > input:nth-child(1)'),  #车位费
            'service_fee_loc' : (By.CSS_SELECTOR, 'input#year_service_fee + span > input:nth-child(1)'),    #服务费
            'pledge_loc' : (By.ID,'pledge'),     #抵押情况-有
            'contract_num_loc' : (By.CSS_SELECTOR,'input#contract_num + span >input:nth-child(1)'),  #合同编号
            'payment_cycle_loc_1' : (By.CSS_SELECTOR,'input#payment_cycle + span > span > a'), #付款周期
            'payment_cycle_loc_2': (By.CSS_SELECTOR, 'body > div:nth-child(44) > div >div:nth-child(1)'),  # 月付
            'next_loc_1' : (By.ID,'form_btn'), #合同信息下一步
            #租金明细
            'rent_detail_selectAll' : (By.CLASS_NAME,'check-all'),  #租金明细全选
            'rent_audit_loc' : (By.ID,'payableAudit'),  #租金审核
            'audit_pass_loc' : (By.CSS_SELECTOR,'[value="AUDITED"]'),   #审核通过
            'rent_audit_confirm' : (By.CSS_SELECTOR,'[οnclick="customer_pay.AuditButtonConfirm()"]'),    #租金审核确认
            'next_loc_2': (By.ID, 'form_next_btn'),  # 租金明细下一步
            #业主信息
            'landlord_name_loc' : (By.CSS_SELECTOR,'td[field="landlord_name"]>div>table>tbody>tr>td>span>input:nth-child(1)'),  #业主姓名
            'landlord_card_loc': (By.CSS_SELECTOR, 'td[field="id_card"]>div>table>tbody>tr>td>span>input:nth-child(1)'),  #业主证件号码
            'landlord_phone_loc': (By.CSS_SELECTOR, 'td[field="phone"]>div>table>tbody>tr>td>span>input:nth-child(1)'),  # 业主联系电话
            'landlord_address_loc': (By.CSS_SELECTOR, 'td[field="mailing_address"]>div>table>tbody>tr>td>span>input:nth-child(1)'), #业主通讯地址
            'signFlag_loc': (By.CSS_SELECTOR, 'td[field="signFlag"]>div>input'),    #是否签约人
            #签约人信息
            'address_loc':(By.CSS_SELECTOR,'input#address + span > input:nth-child(1)'),    #签约人通讯地址
            'email_loc': (By.CSS_SELECTOR, 'input#email + span > input:nth-child(1)'),  # 签约人电子邮件
            'other_contact_loc': (By.CSS_SELECTOR, 'input#other_contact + span > input:nth-child(1)'),  # 签约人其他联系方式
            #紧急联系人
            'emergency_name_loc': (By.CSS_SELECTOR, 'input#emergency_name + span > input:nth-child(1)'),  # 联系人姓名
            'emergency_phone_loc': (By.CSS_SELECTOR, 'input#emergency_phone + span > input:nth-child(1)'),  # 联系人电话
            'emergency_id_card_loc': (By.CSS_SELECTOR, 'input#emergency_id_card + span > input:nth-child(1)'),  # 证件号
            'emergency_address_loc': (By.CSS_SELECTOR, 'input#emergency_address + span > input:nth-child(1)'),  # 通讯地址
            #收款人信息
            'account_bank_loc': (By.CSS_SELECTOR, 'input#account_bank + span > input:nth-child(1)'),  # 通讯地址
            'account_num_loc': (By.CSS_SELECTOR, 'input#account_num + span > input:nth-child(1)'),  # 通讯地址
            'next_loc_3':(By.CSS_SELECTOR,'#owner_button > div > p > button#form_btn'),    #业主信息下一步
            # 资料上传
            'submit_loc' : (By.CSS_SELECTOR, '#imageupload_button > div > p > button'),
            #审核相关
            'chushen_loc' : (By.CSS_SELECTOR,'button[status="PASS"]'),  #初审,index=1
            'fushen_loc': (By.CSS_SELECTOR, 'button[status="APPROVED"]'),  # 复审,index=1
            'bohui_loc': (By.CSS_SELECTOR, 'button[status="REJECTED"]'),  # 驳回,index=1
            'contract_audit_content' : (By.ID,'iszCommonWorkflowContext'),  #合同审核意见
            'contract_audit_confirm' : (By.ID,'iszCommonWorkflowPageSure') #合同审核确认
        }
    
        typeMould = {
            #合同信息
            'property_type' : '#property_type', #产权类型
            'apartment_type' : '#apartment_type',   #公寓类型
            'reform_way': '#reform_way',    #改造方式
            'entrust_type': '#entrust_type',    #合同类型
            'sign_body': '#sign_body',  #签约公司
            'sign_date':'#sign_date',   #签约日期
            'owner_sign_date': '#owner_sign_date',  #业主交房日
            'fitment_start_date': '#fitment_start_date',    #装修起算日
            'fitment_end_date': '#fitment_end_date',    #装修截止日
            'entrust_start_date': '#entrust_start_date',    #委托起算日
            'entrust_end_date': '#entrust_end_date',    #委托到期日
            'delay_date': '#delay_date',    #延长到期日
            'freeType': '#freeType',    #免租期类别
            'free_start_date': '#free_start_date',  #免租开始日
            'free_end_date':'#free_end_date',    #免租到期日
            'first_pay_date': '#first_pay_date',    #首次付款日
            'second_pay_date': '#second_pay_date',  #第二次付款日
            'payment_cycle': '#payment_cycle',   #付款周期
            #业主信息
            'ownerCardType':'td[field="ownerCardType"] > div > table > tbody > tr > td > input',    #业主证件类型
            #签约人信息
            'gender':'#gender',  #性别
            'card_type':'#card_type',   #签约人证件类型
            #紧急联系人
            'emergency_card_type': '#emergency_card_type',  # 证件类型
            #收款人信息
            'account_name': '#account_name'  # 证件类型
        }
        @log
        def addHouseContract(self):
            """新增委托合同"""
            self.open(Page.devHousePage,self.addHouseContractMould['edit_loc'])
            self.input_text(self.houseSearchMould['residential_name_loc'],'AutoTest')
            #审核房源之后,solr的增量需要时间,所以在此需要多次等待,首次查询后没有发现房源,则等待一分钟后再次查询,重复五次,一旦某次查询后,发现了房源,则结束循环
            for i in range(1,11):
                self.click(self.houseSearchMould['search_button_loc'])
                time.sleep(1)
                try:
                    test = self.driver.find_element(*self.houseSearchMould['tr_house'])
                    if i > 1:
                        consoleLog('已查找到数据')
                    break
                except:
                    info = '未找到house-core的solr增量房源数据,尝试第%s次查找' % i
                    consoleLog(info ,level='WARNING')
                    time.sleep(5)
            #self.script("$('#edit_btn + button')[0].click()")   #点击列表页第一行的新增委托
            #合同信息
            self.click(self.houseSearchMould['add_house_contract_button'],index=0)
            self.input_text(self.addHouseContractMould['inside_space_loc'],100)
            self.type_select(self.typeMould['property_type'],'HAVECARD')   #有产证商品房
            self.click(self.addHouseContractMould['pledge_loc'])
            self.type_select(self.typeMould['apartment_type'],'BRAND')  #品牌公寓
            self.type_select(self.typeMould['reform_way'],'OLDRESTYLE')    #老房全装
            self.type_select(self.typeMould['entrust_type'],'SHARE')    #合租
            self.input_text(self.addHouseContractMould['contract_num_loc'],'AutoTest')
            self.type_select(self.typeMould['sign_body'],'ISZTECH')    #杭州有限公司
            self.type_date(self.typeMould['sign_date'], '2017-02-01')
            self.type_date(self.typeMould['owner_sign_date'], '2017-02-01')
            self.type_date(self.typeMould['fitment_start_date'], '2017-02-01')
            self.type_date(self.typeMould['fitment_end_date'], '2017-02-28')
            self.type_date(self.typeMould['entrust_start_date'], '2017-02-01')
            self.type_date(self.typeMould['entrust_end_date'], '2020-02-29')
            self.type_date(self.typeMould['delay_date'], '2020-05-31')
            self.type_select(self.typeMould['freeType'],'STARTMONTH')  #首月
            self.type_date(self.typeMould['free_start_date'], '2017-02-01')
            self.type_date(self.typeMould['free_end_date'], '2017-02-01')
            self.type_date(self.typeMould['first_pay_date'], '2017-02-28')
            self.type_date(self.typeMould['second_pay_date'], '2017-03-01')
            self.input_text(self.addHouseContractMould['rent_loc'],4321,first=False)
            self.input_text(self.addHouseContractMould['parking_loc'],123)
            self.input_text(self.addHouseContractMould['service_fee_loc'],234,first=False)
            #self.type_select(self.typeMould['payment_cycle'], '半年付')   因为租金策略的机制是点击付款周期后触发,直接赋值不会触发,所以此select不直接赋值,采用点击方式
            self.click(self.addHouseContractMould['payment_cycle_loc_1'])
            self.click(self.addHouseContractMould['payment_cycle_loc_2'])
            self.click(self.addHouseContractMould['next_loc_1'])
            self.click(self.addHouseContractMould['next_loc_2'])
            #业主信息
            self.input_text(self.addHouseContractMould['landlord_name_loc'],'AutoTest')
            self.type_select(self.typeMould['ownerCardType'],'IDNO')    #身份证
            self.input_text(self.addHouseContractMould['landlord_card_loc'], '42062119910828541X')
            self.click(self.addHouseContractMould['landlord_name_loc'])
            self.input_text(self.addHouseContractMould['landlord_phone_loc'],'13666666666')
            self.click(self.addHouseContractMould['landlord_name_loc'])
            self.input_text(self.addHouseContractMould['landlord_address_loc'], u'浙江省杭州市')
            self.click(self.addHouseContractMould['signFlag_loc'])
            time.sleep(0.5)
            #签约人信息
            self.type_select(self.typeMould['card_type'],'IDNO')    #身份证
            self.type_select(self.typeMould['gender'],'MALE')   #男
            self.input_text(self.addHouseContractMould['email_loc'],'test@mail.com')
            self.input_text(self.addHouseContractMould['other_contact_loc'],u'浙江省杭州市')
            #紧急联系人
            self.input_text(self.addHouseContractMould['emergency_name_loc'],u'紧急联系人')
            self.input_text(self.addHouseContractMould['emergency_phone_loc'],'13777777777')
            self.type_select(self.typeMould['emergency_card_type'],'IDNO')  #身份证
            self.input_text(self.addHouseContractMould['emergency_id_card_loc'],'411722197508214014')
            self.input_text(self.addHouseContractMould['emergency_address_loc'],u'浙江省杭州市')
            #收款人信息
            self.type_select(self.typeMould['account_name'],'AutoTest')
            self.input_text(self.addHouseContractMould['account_bank_loc'],u'农业银行')
            self.input_text(self.addHouseContractMould['account_num_loc'],'1234567890')
            self.click(self.addHouseContractMould['next_loc_3'])
            self.click(self.addHouseContractMould['submit_loc'])
            self.check_submit()
            Base.succeed += 1
            consoleLog('新增委托合同成功')
        @log
        def auditHouseContract(self):
            """审核委托合同"""
            #审核的相关按钮的disable属性不知道为什么是false,导致无法通过Base类中的对元素属性的校验,所以关于审核按钮的操作都改为js来控制
            self.open(Page.entrustContractPage,self.contractSearchMould['tr_contract'],havaFrame=False)
            self.input_text(self.contractSearchMould['contract_num_loc'],'AutoTest')
            self.click(self.contractSearchMould['search_button_loc'])
            self.staleness_of(self.contractSearchMould['tr_contract'])
            self.dblclick(self.contractSearchMould['tr_contract'],checkLoc=self.addHouseContractMould['contract_num_loc'])
            #驳回
            self.click(self.addHouseContractMould['tab_info_loc'], index=3)
            self.script('$("button[status=\'REJECTED\']")[1].click()')
            self.input_text(self.addHouseContractMould['contract_audit_content'],u'自动化测试审核数据')
            self.click(self.addHouseContractMould['contract_audit_confirm'])
            self.staleness_of(self.contractSearchMould['tr_contract'])
            self.dblclick(self.contractSearchMould['tr_contract'],checkLoc=self.addHouseContractMould['contract_num_loc'])
            #审核租金
            self.click(self.addHouseContractMould['tab_info_loc'], index=1)
            self.click(self.addHouseContractMould['rent_detail_selectAll'])
            self.click(self.addHouseContractMould['rent_audit_loc'])
            self.click(self.addHouseContractMould['audit_pass_loc'])
            self.click(self.addHouseContractMould['rent_audit_confirm'])
            #初审
            self.click(self.addHouseContractMould['tab_info_loc'],index=3)
            self.script('$("button[status=\'PASS\']")[2].click()')
            self.click(self.addHouseContractMould['contract_audit_confirm'])
            self.staleness_of(self.contractSearchMould['tr_contract'])
            self.dblclick(self.contractSearchMould['tr_contract'],checkLoc=self.addHouseContractMould['contract_num_loc'])
            #复审
            self.click(self.addHouseContractMould['tab_info_loc'], index=3)
            self.script('$("button[status=\'APPROVED\']")[1].click()')
            self.click(self.addHouseContractMould['contract_audit_confirm'])
            self.check_submit()
            consoleLog('委托合同审核成功')
        @log
        def delContract(self):
            """删除委托合同"""
            self.open(Page.entrustContractPage, self.contractSearchMould['tr_contract'], havaFrame=False)
            self.input_text(self.contractSearchMould['contract_num_loc'], 'AutoTest')
            self.click(self.contractSearchMould['search_button_loc'])
            self.staleness_of(self.contractSearchMould['tr_contract'])
            self.click(self.addHouseContractMould['delete_button'])
            self.click(self.addHouseContractMould['delete_button_confirm'])
            self.check_submit()
            consoleLog('委托合同删除成功')


    #HouseContractEndPage.py

    ###新增委托合同终止结算

    # -*- coding:utf8 -*-
    
    from base.Base import Base
    from base import Page
    from selenium.webdriver.common.by import By
    import time
    from base.Base import log
    from base.Base import consoleLog
    
    class HouseContractEndPage(Base):
        searchMould = {
            'export_button' : (By.ID,'export_excel_btn'),
            'contract_num_loc' : (By.CSS_SELECTOR,'#contract_num_search + span > input:nth-child(1)'),   #委托合同号
            'contract_search_button_loc' : (By.ID,'search_btn'),    #委托合同列表页的搜索
            'end_contract_num_loc' : (By.CSS_SELECTOR,'#contract_num_wt + span > input:nth-child(1)'),  #委托合同终止列表页的合同号
            'end_search_button_loc': (By.ID, 'end_search_btn'), #委托合同终止列表页的搜索
            'tr_contract_end' : (By.CSS_SELECTOR, '#ContractReceivable_table_wt > div:nth-child(1) > div:nth-child(2) > div.datagrid-view > div.datagrid-view2 > div.datagrid-body > table > tbody > tr:nth-child(1)'),  # 列表页第一行
        }
        addContractEndMould = {
            'detail_button' : (By.CSS_SELECTOR,'[οnclick="HouseEnd.detailDialog(0)"]'), #详情 index:0-操作列中、1-右键中
            'delete_button' : (By.CSS_SELECTOR,'[οnclick="HouseEnd.detailDialog(0)"] + button'),    #删除
            'delete_button_confirm' : (By.CSS_SELECTOR,'.dialog-button.messager-button > a:nth-child(1) > span'),   #删除确认
            'tab_info' : (By.CLASS_NAME,'tabs-inner'),  #index 0-出租合同终止结算、1-委托合同终止结算
            'tr_contract': (By.CSS_SELECTOR, 'tr[datagrid-row-index="0"]'),  # 列表页第一行
            'end_button_loc' : (By.CSS_SELECTOR,'[οnclick=\'contractIndex.end("0")\']'),    #0为操作列中,1为右键中
            'check_loc' : (By.ID,'end_type'),   #用来确认双击是否成功的元素-结算类型
            #结算-收款明细
            'penalty_loc': (By.CSS_SELECTOR, '#penalty + span > input:nth-child(1)'),  # 违约金陪入
            'return_rent_loc': (By.CSS_SELECTOR, '#return_rent + span > input:nth-child(1)'),  # 返还房租
            'no_charge_loc': (By.CSS_SELECTOR, '#no_charge + span > input:nth-child(1)'),  # 未扣款项
            'fitment_charge_loc': (By.CSS_SELECTOR, '#fitment_charge + span > input:nth-child(1)'),  # 装修扣款
            'other_loc': (By.CSS_SELECTOR, '#other + span > input:nth-child(1)'),  # 其他
            'penalty_remark_loc': (By.CSS_SELECTOR, '#penalty_remark + span > input:nth-child(1)'),
            'return_rent_remark_loc': (By.CSS_SELECTOR, '#return_rent_remark + span > input:nth-child(1)'),
            'no_charge_remark_loc': (By.CSS_SELECTOR, '#no_charge_remark + span > input:nth-child(1)'),
            'fitment_charge_remark_loc': (By.CSS_SELECTOR, '#fitment_charge_remark + span > input:nth-child(1)'),
            'other_remark_loc': (By.CSS_SELECTOR, '#other_remark + span > input:nth-child(1)'),
            #结算-代垫费用退款明细
            'tool_bar' : (By.CSS_SELECTOR,'.datagrid-toolbar > table > tbody > tr > td > a > span'), #0-新增、1-删除
            'return_money_loc' : (By.CSS_SELECTOR,'[field="return_money"] > div > table > tbody > tr > td > span > input:nth-child(1)'),    #退款金额
            #打款信息
            'pay_name_loc' : (By.CSS_SELECTOR,'#pay_name + span > input:nth-child(1)'), #姓名
            'pay_bank_loc' : (By.CSS_SELECTOR,'#pay_bank  + span > input:nth-child(1)'),    #开户银行
            'pay_bank_no_loc': (By.CSS_SELECTOR, '#pay_bank_no  + span > input:nth-child(1)'),  # 银行卡号
            'company_no_loc': (By.CSS_SELECTOR, '#company_no  + span > input:nth-child(1)'),  # 还款公司
            'remark_loc' : (By.ID,'remark'), #备注
            'submit_loc' : (By.ID,'form_save_btn'),    #提交
            # 审核相关
            'chushen_loc': (By.CSS_SELECTOR, 'button[status="PASS"]'),  # 初审
            'fushen_loc': (By.CSS_SELECTOR, 'button[status="REVIEW"]'),  # 复审
            'bohui_loc': (By.CSS_SELECTOR, 'button[status="RE_JECT"]'),  # 驳回
            'contract_audit_content': (By.ID, 'iszCommonWorkflowContext'),  # 合同审核意见
            'contract_audit_confirm': (By.ID, 'iszCommonWorkflowPageSure')  # 合同审核确认
        }
        typeMould = {
            'end_date' : '#end_date',
            'end_type' : '#end_type',   #终止类型
            'return_type_loc' : '[field="return_type"] > div > table > tbody > tr > td > input',    #退款项目
            'bear_type_loc' : '[field="bear_type"] > div > table > tbody > tr > td > input',    #承担方
            'bear_name' : '[field="bear_name"] > div > table > tbody > tr > td > input',    #承担方姓名
            'money_start_date' : '[field="start_date"] > div > table > tbody > tr > td > input',  #费用开始时间
            'money_end_date' : '[field="end_date"] > div > table > tbody > tr > td > input',  #费用结束时间
            'explain' : '[field="explain"] > div > table > tbody > tr > td > input',  # 情况说明
            'dispute': '[field="dispute"] > div > table > tbody > tr > td > input',  # 是否纠纷
            'receivable_date' : '#receivable_date',  #应收日期
            'pay_type' : '#pay_type'    #打款类型
        }
        @log
        def addContractEnd(self):
            """新增委托合同终止结算"""
            self.open(Page.entrustContractPage,self.addContractEndMould['tr_contract'],havaFrame=False)
            self.input_text(self.searchMould['contract_num_loc'],'AutoTest')
            self.click(self.searchMould['contract_search_button_loc'])
            self.staleness_of(self.addContractEndMould['tr_contract'])
            self.context_click(self.addContractEndMould['tr_contract'])
            self.click(self.addContractEndMould['end_button_loc'],index=1)
            self.input_text(self.addContractEndMould['penalty_loc'], 111)
            self.type_select(self.typeMould['end_type'],'RETREATING')   #结算类型-正退
            self.type_date(self.typeMould['end_date'],'2017-08-08')
            #结算扣款
            self.input_text(self.addContractEndMould['penalty_remark_loc'], u'违约金陪入')
            self.input_text(self.addContractEndMould['return_rent_loc'], 222)
            self.input_text(self.addContractEndMould['return_rent_remark_loc'], u'返还房租')
            self.input_text(self.addContractEndMould['no_charge_loc'], 333)
            self.input_text(self.addContractEndMould['no_charge_remark_loc'], u'未扣款项')
            self.input_text(self.addContractEndMould['fitment_charge_loc'], 444)
            self.input_text(self.addContractEndMould['fitment_charge_remark_loc'], u'装修扣款')
            self.input_text(self.addContractEndMould['other_loc'], 555)
            self.input_text(self.addContractEndMould['other_remark_loc'], u'其他信息')
            #代垫费用
            self.click(self.addContractEndMould['tool_bar'],index=0)
            self.type_select(self.typeMould['return_type_loc'],'LIQUIDATED')    #违约金赔出
            self.input_text(self.addContractEndMould['return_money_loc'],666)
            self.type_select(self.typeMould['bear_type_loc'],'COMPANY')  #承担方-公司
            self.type_select(self.typeMould['bear_name'],'ISZTECH')
            self.type_date(self.typeMould['money_start_date'],'2017-07-07')
            self.type_date(self.typeMould['money_end_date'],'2017-08-08')
            self.type_select(self.typeMould['explain'],'VACANCY')   #情况说明-空置期
            self.type_select(self.typeMould['dispute'],'N')
            self.type_date(self.typeMould['receivable_date'],'2017-08-08')
            #打款信息
            self.type_select(self.typeMould['pay_type'],'OWNER')    #打款类别-业主收款
            self.input_text(self.addContractEndMould['pay_name_loc'],'AutoTest')
            self.input_text(self.addContractEndMould['pay_bank_loc'],u'中国银行')
            self.input_text(self.addContractEndMould['pay_bank_no_loc'],'12345678910')
            self.input_text(self.addContractEndMould['company_no_loc'],u'杭州有限公司')
            self.click(self.addContractEndMould['submit_loc'])
            self.check_submit()
            consoleLog('委托合同终止结算新增成功')
        @log
        def auditContractEnd(self):
            """审核委托合同终止结算"""
            self.open(Page.contractEndPage,self.searchMould['contract_search_button_loc'],havaFrame=False)
            self.click(self.addContractEndMould['tab_info'],index=1)
            self.input_text(self.searchMould['end_contract_num_loc'],'AutoTest')
            self.click(self.searchMould['end_search_button_loc'])
            self.staleness_of(self.searchMould['tr_contract_end'])
            self.dblclick(self.searchMould['tr_contract_end'],checkLoc=self.addContractEndMould['check_loc'])
            #驳回
            self.click(self.addContractEndMould['bohui_loc'])
            self.input_text(self.addContractEndMould['contract_audit_content'],u'自动化测试审核数据')
            self.click(self.addContractEndMould['contract_audit_confirm'])
            self.check_submit()
            self.dblclick(self.searchMould['tr_contract_end'],checkLoc=self.addContractEndMould['check_loc'])
            #初审
            self.click(self.addContractEndMould['chushen_loc'])
            self.click(self.addContractEndMould['contract_audit_confirm'])
            self.check_submit()
            self.dblclick(self.searchMould['tr_contract_end'],checkLoc=self.addContractEndMould['check_loc'])
            # 复审
            self.click(self.addContractEndMould['fushen_loc'])
            self.click(self.addContractEndMould['contract_audit_confirm'])
            consoleLog('委托合同终止结算审核成功')
        @log
        def delContractEnd(self):
            """删除委托合同终止结算"""
            self.open(Page.contractEndPage, self.searchMould['contract_search_button_loc'], havaFrame=False)
            self.click(self.addContractEndMould['tab_info'], index=1)
            self.input_text(self.searchMould['end_contract_num_loc'], 'AutoTest')
            self.click(self.searchMould['end_search_button_loc'])
            self.staleness_of(self.searchMould['tr_contract_end'])
            self.click(self.addContractEndMould['delete_button'])
            self.click(self.addContractEndMould['delete_button_confirm'])
            self.check_submit()
            consoleLog('委托合同终止结算删除成功')



    #ApartmentContractPage.py

    ###签约出租合同

    # -*- coding:utf8 -*-
    
    
    from base.Base import Base
    from base import Page
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    import time
    from base.Base import log
    from base.Base import consoleLog
    
    class ApartmentContractPage(Base):
        customerSignMould = {
            #签约从租客端发起,选择租客
            'search_customer_name_loc' : (By.ID,'customer_code_name_mobile_search'),    #租客姓名查询
            'search_button_loc' : (By.ID,'search_btn'), #查询按钮
            'tr_customer' : (By.CSS_SELECTOR,'[datagrid-row-index="0"]'),
            'sign_button' : (By.CSS_SELECTOR,'[οnclick="CustomerIndex.signAvailability(0)"]'),  #index:0-操作列中、1-右键中
            #选择房源
            'share': (By.CSS_SELECTOR,'#search_panel_customer_book_availability_source > div > div > div > ul > li:nth-child(2) > a > span'),#合租按钮
            'search_apartment_loc' : (By.ID,'residential_name_house_code_search'),  #楼盘名称查询
            'search_apartment_button_loc' : (By.ID,'search_btn'),   #查询按钮 【2】
            'apartment_loc' : (By.CSS_SELECTOR,'#search_panel_customer_book_availability_source > div > div > div:nth-child(2) > div > div > div > div > div > div > table > tbody > tr:nth-child(1)')   #第一条房源
        }
        searchContractMould = {
            'contract_num_loc' : (By.CSS_SELECTOR,'#apartment_contract_num + span > input:nth-child(1)'),   #承租合同号
            'search_button_loc' : (By.ID,'apartment_search_btn'),   #搜索
            'tr_contract' : (By.CSS_SELECTOR,'tr[datagrid-row-index="0"]')  #列表页第一行
        }
        addApartmentContractMould = {
            'delete_button_confirm': (By.CSS_SELECTOR, '.dialog-button.messager-button > a:nth-child(1) > span'),  # 删除确认
            #合同信息
            'tab_info_loc': (By.CSS_SELECTOR, '.tabs-inner'),  # 0-合租、1-整租、2-合同信息、3-应收款项、4-租客详情
            'contract_num_loc' : (By.CSS_SELECTOR,'#contract_num + span > input:nth-child(1)'),  #合同编号
            'deposit_loc' : (By.CSS_SELECTOR,'#deposit + span > input:nth-child(1)'),    #应收押金
            #合同租金
            'rent_strategy_menu_loc': (By.CSS_SELECTOR, '#contract_strategy_table > div > a > span > span:nth-child(1)'),    #租金策略:[0]为新增,[1]为删除
            'rent_strategy_price_loc': (By.CSS_SELECTOR, '#contract_strategy_table > table > tbody > tr > td:nth-child(6) > input'),    #月租金
            'rent_strategy_contain_loc': (By.CSS_SELECTOR, '#contract_strategy_table > table > tbody > tr > td:nth-child(9) > div > button'),   #月租金包含按钮
            'contain_fee_loc': (By.CSS_SELECTOR, '#money_add + span > input:nth-child(1)'),     #月租金包含费用金额
            'contain_fee_save_loc': (By.CSS_SELECTOR, '#apartmentContract_money_panel_add > div > p > button'),     #月租金包含的保存
            'agent_fee_loc': (By.CSS_SELECTOR, '#agency_fee + span > input:nth-child(1)'),  # 中介服务费
            'remark_loc': (By.ID, 'remark'),    #备注
            'next_loc_1': (By.CSS_SELECTOR, '#base_button > div > p > button#form_btn'),   #第一页的下一步
            'next_loc_2': (By.CSS_SELECTOR, '#base_button > div > p > button#form_next_btn'),   #第二页的下一步
            #租客详情
            'sign_name_loc' : (By.CSS_SELECTOR,'#sign_name + span > input:nth-child(1)'),  #签约人姓名
            'sign_id_no_loc' : (By.CSS_SELECTOR,'#sign_id_no + span > input:nth-child(1)'),    #签约人证件号
            'sign_phone_loc' : (By.CSS_SELECTOR,'#sign_phone + span > input:nth-child(1)'),   #签约人联系电话
            'sign_address_loc': (By.CSS_SELECTOR,'#postal_address + span > input:nth-child(1)'),  #签约人通讯地址
            #紧急联系人
            'urgent_customer_name_loc': (By.CSS_SELECTOR,'#urgent_customer_name + span > input:nth-child(1)'),    #紧急联系人姓名
            'urgent_phone_loc': (By.CSS_SELECTOR,'#urgent_phone + span > input:nth-child(1)'),    #紧急联系人电话
            'urgent_id_card_loc': (By.CSS_SELECTOR,'#urgent_id_card + span > input:nth-child(1)'),    #紧急联系人证件号
            'urgent_postal_address_loc': (By.CSS_SELECTOR,'#urgent_postal_address + span > input:nth-child(1)'),  #紧急联系人地址
            #承租人信息
            'trade_loc': (By.CSS_SELECTOR,'#trade + span > input:nth-child(1)'),  #行业
            'email_loc': (By.CSS_SELECTOR,'#email + span > input:nth-child(1)'),  #电子邮件
            'tent_contact_address_loc': (By.CSS_SELECTOR,'#tent_contact_address + span > input:nth-child(1)'),    #联系地址
            #入住人信息
            'del_person_loc' : (By.CSS_SELECTOR,'#check_person_info > div > div > div:nth-child(1) > table > tbody > tr > td:nth-child(3) > a > span'),    #删除入住人按钮
            'add_person_loc': (By.CSS_SELECTOR,'#check_person_info > div > div > div:nth-child(1) > table > tbody > tr > td:nth-child(1) > a > span > span:nth-child(1)'),  # 新增入住人按钮
            'person_count_loc' : (By.CSS_SELECTOR,'#check_person_info > div > div > div.datagrid-view > div:nth-child(2) > div:nth-child(2) > table > tbody > tr '),   #入住人个数
            'person_name_loc' : (By.CSS_SELECTOR,'td[field="customer_name"] > div > table > tbody > tr > td > span > input:nth-child(1)'),        #入住人姓名
            'person_cardType_loc': (By.CSS_SELECTOR,'td[field="id_card"] > div > table > tbody > tr > td > span > input:nth-child(1)'),       # 入住人证件号码
            'person_phone_loc' : (By.CSS_SELECTOR,'td[field="phone"] > div > table > tbody > tr > td > span > input:nth-child(1)'),    #入住人联系电话
            # 审核相关
            'chushen_loc': (By.CSS_SELECTOR, 'button[status="PASS"]'),  # 初审
            'fushen_loc': (By.CSS_SELECTOR, 'button[status="APPROVED"]'),  # 复审,index=1
            'bohui_loc': (By.CSS_SELECTOR, 'button[status="REJECTED"]'),  # 驳回
            'contract_audit_content': (By.ID, 'iszCommonWorkflowContext'),  # 合同审核意见
            'contract_audit_confirm': (By.ID, 'iszCommonWorkflowPageSure'),  # 合同审核确认
            'submit_loc' : (By.CSS_SELECTOR,'#owner_button > div > p > button#form_submit')   #合同提交
        }
    
        typeMould = {
            #合同信息
            'sign_date' : '#sign_date',  #签约日期
            'rent_start_date' : '#rent_start_date',     #承租起算日
            'rent_end_date' : '#rent_end_date',     #承租到期日
            'payment_date' : '#payment_date',   #首次付款日
            'payment_type': '#payment_type',    #付款方式
            'payment_cycle' : '#payment_cycle',     #付款周期
            #合同租金
            'rent_strategy_start_loc': '#contract_strategy_table > table > tbody > tr > td:nth-child(7) > input',   #租金策略开始日
            'rent_strategy_end_loc': '#contract_strategy_table > table > tbody > tr > td:nth-child(8) > input',     #租金策略结束日
            'contain_fee_type': '#fee_type',    #月租金包含费用类型
            #其他费用
            'agency_fee': '#agency_fee',        #中介服务费
            #签约人
            'sign_id_type': '#sign_id_type',        #签约人证件类型
            'sign_is_customer': '#sign_is_customer',    #是否承租人
            #紧急联系人
            'urgent_card_type': '#urgent_card_type',    #紧急联系人证件类型
            #承租人信息
            'customer_type': '#customer_type',  #租客类型
            'gender': '#gender',    #租客性别
            'education': '#education',  #学历
            'yesNo': '#yesNo',  #是否入住
            #入住人信息
            'cardType': 'td[field="cardType"] > div > table > tbody > tr > td > input',   #入住人证件类型
            'sex': 'td[field="sex"] > div > table > tbody > tr > td > input',   #入住人性别
            'staydate': 'td[field="staydate"] > div > table > tbody > tr > td > input'    #入住日期
        }
        @log
        def addApartmentContract(self):
            """新增出租合同"""
            self.open(Page.customerListPage,self.customerSignMould['tr_customer'],havaFrame=False)
            try:
                self.input_text(self.customerSignMould['search_customer_name_loc'], 'AutoTest')
            except:
                consoleLog(Exception.message,level='ERROR')
                consoleLog('发现分配租客界面,需先执行关闭操作')
                self.click((By.CSS_SELECTOR, '.panel.window > div:nth-child(1) > div.panel-tool > a'))  #可能会有分配租客的弹窗出现,此为关闭
            self.click(self.customerSignMould['search_button_loc'])
            self.staleness_of(self.customerSignMould['tr_customer'])
            self.script("$('button#edit_btn')[2].click()")  # 点击列表页第一行的签约
            #此处为查询房源
            self.click(self.customerSignMould['share'])
            self.input_text(self.customerSignMould['search_apartment_loc'],'AutoTest')
            self.input_text(self.customerSignMould['search_apartment_loc'],Keys.ENTER)
            self.staleness_of(self.customerSignMould['apartment_loc'])
            self.dblclick(self.customerSignMould['apartment_loc'],checkLoc=self.addApartmentContractMould['contract_num_loc'])  #对查询结果的第一条房源数据双击发起签约
            self.input_text(self.addApartmentContractMould['contract_num_loc'],'AutoTest')  #合同号
            self.type_date(self.typeMould['sign_date'],'2017-02-02')    #签约日期
            self.type_date(self.typeMould['rent_start_date'], '2017-02-02') #承租起算日
            self.type_date(self.typeMould['rent_end_date'], '2018-08-08')   #承租到期日
            self.input_text(self.addApartmentContractMould['deposit_loc'],1234,first=False)
            self.type_select(self.typeMould['payment_type'],'NORMAL')   #正常付款
            self.type_select(self.typeMould['payment_cycle'], 'TOW_MONTH')  #二月付
            #self.input_text(self.addApartmentContractMould['rent_strategy_price_loc'],4321)     #月租金:需求变更,单条情况下无需手动录入
            #self.type_date(self.typeMould['rent_strategy_end_loc'],'2018-08-08')    #租金策略结束日:不知道为什么自动化打开的DOM和正常情况下的DOM不一样,所以直接用jquery赋值
            self.script("$('#contract_strategy_table > table > tbody > tr > td:nth-child(8) > input').val('2018-08-08')")
            self.click(self.addApartmentContractMould['rent_strategy_contain_loc'])     #月租金包含按钮
            self.type_select(self.typeMould['contain_fee_type'],'PARKING')  #包含车位费
            self.input_text(self.addApartmentContractMould['contain_fee_loc'],123)  #车位费
            self.click(self.addApartmentContractMould['contain_fee_save_loc'])  #保存包含
            self.input_text(self.addApartmentContractMould['agent_fee_loc'],234,first=False)    #中介服务费
            self.input_text(self.addApartmentContractMould['remark_loc'],'this is autotest date')   #备注
            self.click(self.addApartmentContractMould['next_loc_1'])    #
            self.click(self.addApartmentContractMould['next_loc_2'])
            #租客详情
            self.input_text(self.addApartmentContractMould['sign_name_loc'],'AutoTest')
            self.type_select(self.typeMould['sign_id_type'],'IDNO')
            self.input_text(self.addApartmentContractMould['sign_id_no_loc'],'42062119910828541X')
            self.input_text(self.addApartmentContractMould['sign_phone_loc'], '15168368432')
            self.input_text(self.addApartmentContractMould['sign_address_loc'], u'浙江省杭州市')
            self.type_select(self.typeMould['sign_is_customer'], 'Y')
            self.input_text(self.addApartmentContractMould['urgent_customer_name_loc'], 'AutoTest')
            self.input_text(self.addApartmentContractMould['urgent_phone_loc'], '13666666666')
            self.type_select(self.typeMould['urgent_card_type'], 'IDNO')
            self.input_text(self.addApartmentContractMould['urgent_id_card_loc'], '42062119910828541X')
            self.input_text(self.addApartmentContractMould['urgent_postal_address_loc'], u'浙江省杭州市')
            self.type_select(self.typeMould['customer_type'],'EMPLOYEE')
            self.type_select(self.typeMould['gender'],'MALE')
            self.type_select(self.typeMould['education'], 'BACHELOR')
            self.input_text(self.addApartmentContractMould['trade_loc'],u'计算机软件')
            self.input_text(self.addApartmentContractMould['email_loc'], 'test@ishangzu.com')
            self.type_select(self.typeMould['yesNo'], 'Y')
            self.click(self.addApartmentContractMould['add_person_loc'])
            self.input_text(self.addApartmentContractMould['person_name_loc'],'test')
            self.type_select(self.typeMould['cardType'],'PASSPORT')
            self.input_text(self.addApartmentContractMould['person_cardType_loc'],'abcdefghijk')
            self.type_select(self.typeMould['sex'], 'MALE')
            self.input_text(self.addApartmentContractMould['person_phone_loc'], '13777777777')
            self.type_date(self.typeMould['staydate'],'2017-08-08')
            self.click(self.addApartmentContractMould['submit_loc'])
            Base.succeed += 1
            self.check_submit()
            consoleLog('出租合同新增成功')
        @log
        def auditApartmentContract(self):
            """审核出租合同"""
            self.open(Page.apartmentContractPage,self.searchContractMould['tr_contract'],havaFrame=False)
            self.input_text(self.searchContractMould['contract_num_loc'],'AutoTest')
            self.click(self.searchContractMould['search_button_loc'])
            self.staleness_of(self.searchContractMould['tr_contract'])
            self.dblclick(self.searchContractMould['tr_contract'])
            for i in range(0,5):
                try:
                    self.click(self.addApartmentContractMould['tab_info_loc'],index=4)
                    break
                except:
                    time.sleep(1)
            #驳回
            self.click(self.addApartmentContractMould['bohui_loc'])
            self.input_text(self.addApartmentContractMould['contract_audit_content'],u'自动化测试审核数据')
            self.click(self.addApartmentContractMould['contract_audit_confirm'])
            self.staleness_of(self.searchContractMould['tr_contract'])
            self.dblclick(self.searchContractMould['tr_contract'])
            for i in range(0,5):
                try:
                    self.click(self.addApartmentContractMould['tab_info_loc'],index=4)
                except:
                    time.sleep(1)
                else:
                    pass
            #初审
            self.click(self.addApartmentContractMould['chushen_loc'])
            self.click(self.addApartmentContractMould['contract_audit_confirm'])
            self.staleness_of(self.searchContractMould['tr_contract'])
            self.dblclick(self.searchContractMould['tr_contract'])
            for i in range(0,5):
                try:
                    self.click(self.addApartmentContractMould['tab_info_loc'],index=4)
                except:
                    time.sleep(1)
                else:
                    pass
            #复审
            self.click(self.addApartmentContractMould['fushen_loc'])
            self.click(self.addApartmentContractMould['contract_audit_confirm'])
            self.check_submit()
            consoleLog('审核出租合同成功')
        @log
        def delContract(self):
            """删除出租合同"""
            self.open(Page.apartmentContractPage, self.searchContractMould['tr_contract'], havaFrame=False)
            self.input_text(self.searchContractMould['contract_num_loc'], 'AutoTest')
            self.click(self.searchContractMould['search_button_loc'])
            self.staleness_of(self.searchContractMould['tr_contract'])
            self.script("$('#data_perm_btn').click()")
            self.click(self.addApartmentContractMould['delete_button_confirm'])
            self.check_submit()
            consoleLog('出租合同删除成功')
    


    #ApartmentContractEndPage.py

    ###新增委托合同终止结算

    # -*- coding:utf8 -*-
    
    from base.Base import Base
    from base import Page
    from selenium.webdriver.common.by import By
    from base.Base import log
    from base.Base import consoleLog
    
    class ApartmentContractEndPage(Base):
        searchMould = {
            'contract_num_loc' : (By.CSS_SELECTOR,'#contract_num_search + span > input:nth-child(1)'),   #承租合同号
            'search_button_loc' : (By.ID,'search_btn'),
            'tr_contract_end' : (By.CSS_SELECTOR, 'tr[datagrid-row-index="0"]'),  # 列表页第一行
        }
        addContractEndMould = {
            'tr_contract': (By.CSS_SELECTOR, 'tr[datagrid-row-index="0"]'),  # 列表页第一行
            'end_button_loc' : (By.CSS_SELECTOR,'[οnclick=\'apartmentContractList.end("0")\']'),    #0为操作列中,1为右键中
            'delete_button': (By.CSS_SELECTOR, '[οnclick="ApartmentEnd.detailDialog(0)"] + button'),  # 删除
            'delete_button_confirm': (By.CSS_SELECTOR, '.dialog-button.messager-button > a:nth-child(1) > span'),  # 删除确认
            'before_end_loc' : (By.CSS_SELECTOR,'[οnclick="apartmentContractList.isEndTpye(\'PREEND\')"]'),    #预约终止
            'now_end_loc': (By.CSS_SELECTOR, '[οnclick="apartmentContractList.isEndTpye(\'NORMAL\')"]'),  # 立刻终止
            'end_reason_loc' : (By.CSS_SELECTOR,'#end_reason + span > input:nth-child(1)'), #终止原因
            'receipt_num_loc' : (By.CSS_SELECTOR,'#receipt_bank_no + span > input:nth-child(1)'),   #收款卡号
            'bank_loc' : (By.CSS_SELECTOR,'#receipt_bank_location + span > input:nth-child(1)'),    #开户银行
            'weiyuejin_loc' : (By.CSS_SELECTOR,'[field="project_type"] + td'),   #违约金 index=12
            'receivable_money_loc' : (By.CSS_SELECTOR,'[datagrid-row-index="11"] > [field="receivable_money"] > div > table > tbody > tr > td > span > input:nth-child(1)'),    #违约金应收
            'payable_money_loc': (By.CSS_SELECTOR,'[datagrid-row-index="11"] > [field="payable_money"] > div > table > tbody > tr > td > span > input:nth-child(1)'),    #违约金应付
            'remark_loc' : (By.ID,'remark'), #备注
            'submit_loc' : (By.ID,'form_submit_btn'),    #提交
            # 审核相关
            'chushen_loc': (By.CSS_SELECTOR, 'button[status="PASS"]'),  # 初审
            'fushen_loc': (By.CSS_SELECTOR, 'button[status="REVIEW"]'),  # 复审
            'bohui_loc': (By.CSS_SELECTOR, 'button[status="RE_JECT"]'),  # 驳回
            'contract_audit_content': (By.ID, 'iszCommonWorkflowContext'),  # 合同审核意见
            'contract_audit_confirm': (By.ID, 'iszCommonWorkflowPageSure'),  # 合同审核确认
            'submit_loc': (By.CSS_SELECTOR, '#owner_button > div > p > button#form_submit')  # 合同提交
        }
        typeMould = {
            'end_date' : '#end_date',
            'end_type' : '#end_type',   #终止类型
            'receipt_type_loc' : '#contractEndPayerAgintType',   #收款人类型
            'receipt_name_loc' : '#receipt_name'    #收款人姓名
        }
        @log
        def addContractEnd(self):
            """新增出租合同终止结算"""
            self.context_click(self.addContractEndMould['tr_contract'])
            self.click(self.addContractEndMould['end_button_loc'],index=1)
            self.click(self.addContractEndMould['now_end_loc'])
            self.input_text(self.addContractEndMould['receipt_num_loc'],'AutoTest')
            self.type_date(self.typeMould['end_date'],'2017-07-07')
            self.input_text(self.addContractEndMould['end_reason_loc'],u'承租周期已完')
            self.type_select(self.typeMould['end_type'],'RETREATING')  #正退
            self.type_select(self.typeMould['receipt_type_loc'],'PAYER')    #承租人
            self.input_text(self.addContractEndMould['bank_loc'],u'中国银行')
            self.dblclick(self.addContractEndMould['weiyuejin_loc'],index=12)
            self.input_text(self.addContractEndMould['receivable_money_loc'],'888.88')
            self.input_text(self.addContractEndMould['payable_money_loc'],'666.66')
            self.input_text(self.addContractEndMould['remark_loc'],'AutoTest')
            #self.click(self.addContractEndMould['submit_loc'])     #不知道这步为什么会报错,改用js执行
            self.script('$("#form_submit_btn").click()')
            self.check_submit()
            consoleLog('出租合同终止结算新增成功')
        @log
        def auditContractEnd(self):
            """审核出租合同终止结算"""
            self.open(Page.contractEndPage,self.searchMould['tr_contract_end'],havaFrame=False)
            self.input_text(self.searchMould['contract_num_loc'],'AutoTest')
            self.click(self.searchMould['search_button_loc'])
            self.staleness_of(self.searchMould['tr_contract_end'])
            self.dblclick(self.searchMould['tr_contract_end'])
            #驳回
            self.click(self.addContractEndMould['bohui_loc'])
            self.input_text(self.addContractEndMould['contract_audit_content'],u'自动化测试审核数据')
            self.click(self.addContractEndMould['contract_audit_confirm'])
            self.staleness_of(self.searchMould['tr_contract_end'])
            self.dblclick(self.searchMould['tr_contract_end'])
            #初审
            self.click(self.addContractEndMould['chushen_loc'])
            self.click(self.addContractEndMould['contract_audit_confirm'])
            self.staleness_of(self.searchMould['tr_contract_end'])
            self.dblclick(self.searchMould['tr_contract_end'])
            # 复审
            self.click(self.addContractEndMould['fushen_loc'])
            self.click(self.addContractEndMould['contract_audit_confirm'])
            consoleLog('出租合同终止结算审核成功')
        @log
        def delContractEnd(self):
            """删除出租合同终止结算"""
            self.open(Page.contractEndPage, self.searchMould['tr_contract_end'], havaFrame=False)
            self.input_text(self.searchMould['contract_num_loc'], 'AutoTest')
            self.click(self.searchMould['search_button_loc'])
            self.staleness_of(self.searchMould['tr_contract_end'])
            self.click(self.addContractEndMould['delete_button'])
            self.click(self.addContractEndMould['delete_button_confirm'])
            self.check_submit()
    

    展开全文
  • #CustomerPage.py ###租客信息 # -*- coding:utf8 -*- from base.Base import Base from base import Page from selenium.webdriver.common.by import By from base.Base import log from base.Base import ...

    #CustomerPage.py

    ###租客信息

    # -*- coding:utf8 -*-
    
    
    from base.Base import Base
    from base import Page
    from selenium.webdriver.common.by import By
    from base.Base import log
    from base.Base import consoleLog
    import time
    
    class CustomerPage(Base):
        listMould = {
            'customer_name_search' : (By.ID,'customer_code_name_mobile_search'),
            'search_button' : (By.ID,'search_btn'),
            'add_customer_loc' : (By.ID,'customerAdd'),
            'delete_button' : (By.ID,'del_btn'),
            'alert_confirm': (By.CSS_SELECTOR, '.dialog-button.messager-button > a:nth-child(1) > span'),
            'tr_customer': (By.CSS_SELECTOR, '[datagrid-row-index="0"]'),
            'is_tr_customer' : (By.CSS_SELECTOR,'[οnclick="CustomerIndex.del(5)"]')
        }
        addCustomerMould = {
            #租客信息
            'customer_name_loc' : (By.CSS_SELECTOR,'#customer_name + span > input:nth-child(1)'),  #姓名
            'customer_phone_loc' : (By.CSS_SELECTOR,'#phone + span > input:nth-child(1)'),    #手机号
            'customer_gender_loc' : (By.CSS_SELECTOR,'[name="gender"]'),    #性别 0男 1女 2未知
            'customer_marriage_loc' : (By.CSS_SELECTOR,'[name = "marriage"]'),  #婚姻 0未婚 1已婚 2未知
            'customer_email_loc' : (By.CSS_SELECTOR,'#email + span > input:nth-child(1)'),  #邮箱
            'customer_wechat_loc': (By.CSS_SELECTOR, '#wechat + span > input:nth-child(1)'),  # 邮箱
            'rent_price_min_loc': (By.CSS_SELECTOR, '#rent_from_price + span > input:nth-child(1)'),  #求租最小价
            'rent_price_max_loc': (By.CSS_SELECTOR, '#rent_to_price + span > input:nth-child(1)'),  # 求租最大价
            #求租需求
            'rent_people_loc': (By.CSS_SELECTOR, '#rent_people + span > input:nth-child(1)'),  # 入住人数
            'area_loc': (By.CSS_SELECTOR, '#area + span > input:nth-child(1)'),  # 求租面积
            'rent_other': (By.ID, 'rent_other'),  # 其他需求
    
            'submit_loc' : (By.ID,'form_btn')   #提交
        }
        typeMould = {
            #租客信息
            'constellation' : '#constellation',     #星座
            'education': '#education',  # 学历
            'customer_from': '#customer_from',  # 来源
            #求租需求
            'rent_class': '#rent_class',  # 求租等级
            'rent_type': '#rent_type',  # 求租类型
            'rent_use': '#rent_use',  # 求租用途
            'rent_fitment': '#rent_fitment',  # 装修情况
            'rent_area_code': '#rent_area_code',  # 求租城区
            'rent_business_circle': '#rent_business_circle_ids',  # 求租商圈
            'rent_date': '#rent_date'  # 希望入住日
        }
        @log
        def addCustomer(self):
            """新增租前客户"""
            #租客信息
            self.open(Page.customerListPage,self.listMould['add_customer_loc'],havaFrame=False)
            self.click(self.listMould['add_customer_loc'])
            self.input_text(self.addCustomerMould['customer_name_loc'],'AutoTest')
            self.input_text(self.addCustomerMould['customer_phone_loc'], '13666666666')
            self.click(self.addCustomerMould['customer_gender_loc'],index=1)
            self.click(self.addCustomerMould['customer_marriage_loc'], index=1)
            self.input_text(self.addCustomerMould['customer_email_loc'], 'mail@mail.com')
            self.input_text(self.addCustomerMould['customer_wechat_loc'], 'AutoTest')
            self.type_select(self.typeMould['constellation'],'VIRGO')
            self.type_select(self.typeMould['education'], 'BACHELOR')
            self.type_select(self.typeMould['customer_from'], 'LOCAL58')
            #求租需求
            self.type_select(self.typeMould['rent_class'], 'CLASSA')    #求租等级-A级
            self.type_select(self.typeMould['rent_type'], 'GATHERHOUSE')    #求租类型-不限
            self.type_select(self.typeMould['rent_use'], 'RESIDENCE')   #求租用途-住宅
            self.type_select(self.typeMould['rent_fitment'], 'FITMENT_ROUGH')   #装修情况-毛坯
            self.type_select(self.typeMould['rent_area_code'], '330108')    #求租城区-滨江
            self.type_select(self.typeMould['rent_business_circle'], '4')     #求租商圈-浦沿
            self.input_text(self.addCustomerMould['rent_price_min_loc'],'1111')
            self.input_text(self.addCustomerMould['rent_price_max_loc'], '2222')
            self.type_date(self.typeMould['rent_date'],'2017-02-02')
            self.input_text(self.addCustomerMould['rent_people_loc'],'3')
            self.input_text(self.addCustomerMould['area_loc'],'88.88')
            self.input_text(self.addCustomerMould['rent_other'],u'浙江省杭州市')
            self.click(self.addCustomerMould['submit_loc'])
            self.check_submit()
            Base.succeed += 1
            consoleLog('新增租客成功')
    
        def delCustomer(self):
            """删除租前客户"""
            #租客信息
            self.open(Page.customerListPage,self.listMould['tr_customer'],havaFrame=False)
            self.input_text(self.listMould['customer_name_search'],'AutoTest')
            self.click(self.listMould['search_button'])
            self.staleness_of(self.listMould['tr_customer'])
            self.click(self.listMould['delete_button'])
            self.click(self.listMould['alert_confirm'])
            self.check_submit()
            consoleLog('租前客户删除成功')

    展开全文
  • #DesignSharePage.py ###设计工程,派单改造交房 # -*- coding:utf8 -*- from base.Base import Base from base import Page from selenium.webdriver.common.by import By from base import SQL ...
  • #ReimbuisementPage.py ###审核,删除报销单 # -*- coding:utf8 -*- from base.Base import Base from base import Page from selenium.webdriver.common.by import By from base.Base import log ...
  • #Login.py ###封装登录系统 # -*- coding:utf8 -*- from base.Base import Base from selenium.webdriver.common.by import By from base.Base import log from base.Base import consoleLog ...
  • u'自动化测试街道地址' ) self .click( self .addResidentialMould[ 'get_location_btn' ]) self .input_text( self .addResidentialMould[ 'search_address' ] , u'海创基地' , first = False ) self ....
  • havaFrame:是否有frame,默认为有(目前项目中页面基本都存在frame),切换至最近的一个frame """ self .driver.get(url) if havaFrame == True : self .switch_frame( 0 ) WebDriverWait( self .driver...
  • Web自动化测试

    2021-03-18 16:16:13
    Web自动化测试一、概念二、什么web项目适合做自动化测试三、如何进行Web自动化测试(主流测试-工具)四、主流测试工具--汇总 一、概念 Web自动化测试:让程序代替人为自动验证web项目功能的过程。 二、什么web项目...
  • web自动化测试项目

    2021-02-19 13:38:11
    项目说明 对网页计算器,进行加减乘除的测试操作。... 使用参数传入测试数据 框架具体概述 测试用例可以使用混合正交表工具生成正交表 生成了这样的数据,然后根据具体情况写测试用例 json文件中的数据 ...
  • 电商项目Web自动化测试实战

    千次阅读 2020-02-26 16:56:54
    电商项目自动化测试实战 前言: Web自动化主要是功能自动化和部分功能的兼容性测试 Web自动化主要针对:主要流程和重要功能的自动化(有效等价类、异常场景) 测试准备: TPshop开源电商项目 测试业务场景: 登录-&...
  • web自动化测试

    2019-04-20 11:56:55
    web自动化测试概念:让程序代替人为自动验证web项目功能的过程 什么样的web项目适合做自动化测试: 1.需求变动不频繁 2.项目周期长(因为有时候项目时间3个月结束你写个自动化脚本需要1个半月) 3.项目需要回归测试 ...
  • jpress_selenium:jpress开源项目web自动化测试

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 2,862
精华内容 1,144
关键字:

web自动化测试项目