def get_driver(cls, base_config_path):
     contents = Utility.get_json(base_config_path)
     from selenium import webdriver
     driver = getattr(webdriver, contents['BROWSER'])()
     driver.implicitly_wait(6)
     driver.maximize_window()
     return driver
Ejemplo n.º 2
0
    def test_train_query_pool(self, pool, expect):
        self.train.select_pooltype(pool)
        total_number = self.train.total_info()
        if pool == '临时池':
            db_pool = 'temp'
        elif pool == '公共池':
            db_pool = 'public'
        elif pool == '个人池':
            db_pool = 'private'
        elif pool == '学生池':
            db_pool = 'student'
        elif pool == '全部':
            db_pool = '""or 1=1'
        else:
            db_pool = 0
        sql = 'select count(*)as total from customer where pool_type="%s"' % (
            db_pool)
        result = Utility().db_query_dict('..\\config\\base.conf',
                                         sql)[0]['total']
        if int(total_number) == result:
            actual = 'pass'
        else:
            actual = 'fail'

        self.assertEqual(actual, expect)
Ejemplo n.º 3
0
    def setUp(self) -> None:
        self.driver = Service.get_driver('..\\config\\base.conf')
        test_base_info = Utility.get_json('..\\config\\base.conf')
        self.train = TrainSource(self.driver)

        self.train.send_sencpass(test_base_info['erji_pwd_zixun_manager'])
        self.train.click_train_source()
 def do_login_zixun_manager(self, base_config_path):
     Service.open_page(self.driver, base_config_path)
     info = Utility.get_json(base_config_path)
     self.input_name(info['username_zixun_manager'])
     self.input_upass(info['password_zixun_manager'])
     self.input_vfcode(info['verifycode'])
     self.click_button()
    def miss_login(cls, driver, base_config_path):
        cls.open_page(driver, base_config_path)
        # 通过字典方式传递cookie信息

        contents = Utility.get_json(base_config_path)
        driver.add_cookie({'name': 'token', 'value': contents['token']})
        driver.add_cookie({'name': 'workId', 'value': contents['workId']})
        cls.open_page(driver, base_config_path)
 def start(self):
     ts = unittest.TestSuite()
     loader = unittest.TestLoader()
     testcase_names = Utility.trans_str('..\\config\\test.conf')
     # print(testcase_names)
     tests = loader.loadTestsFromNames(testcase_names)
     ts.addTests(tests)
     # 测试报告文件名称的格式为:xxxx-xx-xx_xx_xx_xx_report.html
     import time
     ctime = time.strftime('%Y-%m-%d_%H-%M-%S', time.localtime())
     with open('..\\report\\%s_report.html' % (ctime), 'w') as file:
         runner = HTMLTestRunner(stream=file, verbosity=2)
         runner.run(ts)
Ejemplo n.º 7
0
 def test_train_query_status(self, status, expect):
     self.driver.refresh()
     time.sleep(3)
     self.train.select_status(status)
     total_number = self.train.total_info()
     sql = 'SELECT COUNT(*)AS total from customer a,dictionary_data b WHERE a.last_status=b.dict_key and b.dict_value="%s"AND pool_type NOT IN ("public")' % status
     result = Utility().db_query_dict('..\\config\\base.conf',
                                      sql)[0]['total']
     if int(total_number) == result:
         actual = 'pass'
     else:
         actual = 'fail'
     self.assertEqual(actual, expect)
Ejemplo n.º 8
0
    def test_train_query_worker(self, worker_name, expect):
        time.sleep(1)
        self.train.select_worker(worker_name)
        total_number = self.train.total_info()
        time.sleep(2)
        sql = 'SELECT COUNT(*)AS total FROM  customer a,employee b WHERE b.work_id=a.work_id AND employee_name="%s"' % worker_name
        result = Utility().db_query_dict('..\\config\\base.conf',
                                         sql)[0]['total']
        if int(total_number) == result:
            actual = 'pass'
        else:
            actual = 'fail'

        self.assertEqual(actual, expect)
 def setUp(self) -> None:
     test_base_info = Utility.get_json('..\\config\\base.conf')
     self.driver = Service.get_driver('..\\config\\base.conf')
     self.staff = Staffadd(self.driver)
     self.staff.click_train_source()
#--------------------------------------------------------------------------------------
# @Author  : WANG
# @FileName: test_staff_add.py
# @Software: PyCharm
# @Time    : 2020/4/26
#---------------------------------------------------------------------------------------

from woniuboss4_GUI.common.login import Login
from woniuboss4_GUI.common.staff_add import Staffadd
import time, unittest
from parameterized import parameterized

from woniuboss4_GUI.util.service import Service
from woniuboss4_GUI.util.utility import Utility

test_config_info = Utility.get_json('..\\config\\testdata.conf')
train_add_info = Utility.get_excel_to_tuple(test_config_info[10])


class TrainAddTest(unittest.TestCase):
    def setUp(self) -> None:
        test_base_info = Utility.get_json('..\\config\\base.conf')
        self.driver = Service.get_driver('..\\config\\base.conf')
        self.staff = Staffadd(self.driver)
        self.staff.click_train_source()

    @parameterized.expand(train_add_info)
    def test_add_cus(self, cus_zone, cus_section, cus_job, cus_name, cus_phone,
                     cus_jobnum, expect):

        self.staff.add_tel_verify(cus_zone, cus_section, cus_job, cus_name,
 def total_info(self):
     total_str = self.driver.find_element_by_xpath(
         '//div[@class="pull-left pagination-detail"]/span').text
     total_number = Utility.get_number(total_str, '总共')
     return total_number
    def open_page(cls, driver, base_config_path):

        contents = Utility.get_json(base_config_path)
        URL = 'http://%s:%s/%s' % (contents['HOSTNAME'], contents['PORT'],
                                   contents['AURL'])
        driver.get(URL)
Ejemplo n.º 13
0
from woniuboss4_GUI.common.train_source import TrainSource
import unittest, time
from parameterized import parameterized
from woniuboss4_GUI.util.service import Service
from woniuboss4_GUI.util.utility import Utility

test_config_info = Utility.get_json('..\\config\\testdata.conf')

train_info = Utility.get_excel_to_tuple(test_config_info[1])
train_worker = Utility.get_excel_to_tuple(test_config_info[2])
train_status = Utility.get_excel_to_tuple(test_config_info[3])
train_source = Utility.get_excel_to_tuple(test_config_info[4])
train_time = Utility.get_excel_to_tuple(test_config_info[5])
train_keywords = Utility.get_excel_to_tuple(test_config_info[6])
train_whole = Utility.get_excel_to_tuple(test_config_info[7])


class TrainsourceTest(unittest.TestCase):
    def setUp(self) -> None:
        self.driver = Service.get_driver('..\\config\\base.conf')
        test_base_info = Utility.get_json('..\\config\\base.conf')
        self.train = TrainSource(self.driver)

        self.train.send_sencpass(test_base_info['erji_pwd_zixun_manager'])
        self.train.click_train_source()

    @parameterized.expand(train_info)
    def test_train_query_pool(self, pool, expect):
        self.train.select_pooltype(pool)
        total_number = self.train.total_info()
        if pool == '临时池':
Ejemplo n.º 14
0
from woniuboss4_GUI.common.login import Login
from woniuboss4_GUI.util.service import Service

import unittest
from parameterized import parameterized
import time
from woniuboss4_GUI.util.utility import Utility

test_config_info = Utility.get_json('..\\config\\testdata.conf')
login_info = Utility.get_excel_to_tuple(test_config_info[0])


class TestLogin(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        cls.driver = Service.get_driver('..\\config\\base.conf')
        cls.login = Login(cls.driver)

    @parameterized.expand(login_info)
    def test_login(self, uname, upass, vfcode, expect):
        data = {'username': uname, 'password': upass, 'verfifycode': vfcode}
        self.login.do_login('..\\config\\base.conf', data)
        from selenium.webdriver.common.by import By
        time.sleep(2)
        if Service.is_element_present(self.driver, By.PARTIAL_LINK_TEXT, '注销'):
            actual = 'pass'

            self.driver.find_element_by_partial_link_text('注销').click()
        else:
            actual = 'fail'
            self.driver.refresh()