def get_driver(cls, path): contents = Utility.get_json(path) from selenium import webdriver driver = getattr(webdriver, contents['BROWSER'])() driver.implicitly_wait(10) driver.maximize_window() return driver
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': 'userName', 'value': contents['userName']}) driver.add_cookie({'name': 'userPass', 'value': contents['userPass']}) driver.add_cookie({'name': 'token', 'value': contents['token']}) driver.add_cookie({'name': 'workId', 'value': contents['workId']}) # driver.add_cookie({'name':'rememberMe','value':contents['rememberMe']}) cls.open_page(driver, base_config_path)
def get_session(cls, sum): base_info = Utility.get_json('..\\config\\base.conf') login_url = "%s://%s:%s/%s/" % ( base_info['PROTOCOL'], base_info['HOSTNAME'], base_info['PORT'], base_info['AURL'], ) print(login_url) base_data = Utility.get_json('..\\config\\Account.conf') login_data = { 'userName': base_data[sum]['userName'], 'userPass': base_data[sum]['userPass'], 'checkcode': base_data[sum]['checkcode'] } print(login_data) session = requests.session() resp = session.post(login_url, login_data) print(resp.text) return session
import time import unittest from parameterized import parameterized from selenium.webdriver.common.by import By from woniuboss2_ui.lib.renshi_manage import EmployManage from woniuboss2_ui.tools.service import Service from woniuboss2_ui.tools.utility import Utility test_config_info = Utility.get_json('..\\config\\testdataduyuexin.conf') technical_interview_info = Utility.get_excel_GUI_tuple(test_config_info[2]) mock_interview_info = Utility.get_excel_GUI_tuple(test_config_info[3]) path = Service.choose_path() class EmployTest(unittest.TestCase): def setUp(self): self.driver = Service.get_driver(path) self.employ = EmployManage(self.driver) def tearDown(self): self.driver.quit() @parameterized.expand(technical_interview_info) def test_technical_interview(self, q_content, e_content, expect): technical_interview_data = { 'question_content': q_content, 'evalute_content': e_content } # 执行技术面试的操作
from parameterized import parameterized import unittest import time # 获取测试数据 from woniuboss2_ui.lib.job import Job from woniuboss2_ui.tools.service import Service from woniuboss2_ui.tools.utility import Utility jpb_datas = Utility.get_json('../config/testdata_dengyu.conf') tech_data = Utility.get_excel_GUI_tuple(jpb_datas[11]) edit_one_data = Utility.get_excel_GUI_tuple(jpb_datas[12]) edit_two_data = Utility.get_excel_GUI_tuple(jpb_datas[13]) edit_three_data = Utility.get_excel_GUI_tuple(jpb_datas[14]) path = Service.choose_path() class Testjob(unittest.TestCase): def setUp(self): print('test start') self.driver = Service.get_driver(path) Service.miss_login(self.driver, path) self.driver.find_element_by_link_text(u'就业管理').click() self.job = Job(self.driver) def tearDown(self): print('test over') time.sleep(2) self.driver.quit()
import unittest import time from selenium.webdriver.common.by import By from parameterized import parameterized from woniuboss2_ui.lib.training_ui import Train from woniuboss2_ui.tools.service import Service from woniuboss2_ui.tools.utility import Utility train_data = Utility.get_json('..\\config\\testdata.conf') query_seek = Utility.get_excel_GUI_tuple(train_data[0]) query_add = Utility.get_excel_GUI_tuple(train_data[1]) query_edit = Utility.get_excel_GUI_tuple(train_data[2]) query_tail = Utility.get_excel_GUI_tuple(train_data[3]) query_delt = Utility.get_excel_GUI_tuple(train_data[4]) query_deliver = Utility.get_excel_GUI_tuple(train_data[5]) query_look = Utility.get_excel_GUI_tuple(train_data[6]) query_public = Utility.get_excel_GUI_tuple(train_data[7]) query_resource = Utility.get_excel_GUI_tuple(train_data[8]) query_prorate = Utility.get_excel_GUI_tuple(train_data[9]) print(query_prorate) path = Service.choose_path() class Training(unittest.TestCase): def setUp(self):
from selenium.webdriver.common.by import By from parameterized import parameterized import unittest import time # 获取测试数据 from woniuboss2_ui.lib.login import Login from woniuboss2_ui.tools.service import Service from woniuboss2_ui.tools.utility import Utility login_datas = Utility.get_json("../config/testdata_dengyu.conf") login_data = Utility.get_excel_GUI_tuple(login_datas[0]) path = Service.choose_path() class TestLogin(unittest.TestCase): def setUp(self): print('test start') self.driver = Service.get_driver(path) Service.open_page(self.driver, path) self.login = Login(self.driver) def tearDown(self): print('test over') time.sleep(2) self.driver.quit() # 测试登录功能 @parameterized.expand(login_data)
from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait from parameterized import parameterized import unittest import time # 获取测试数据 from woniuboss2_ui.lib.enterprise import Enterprise from woniuboss2_ui.tools.service import Service from woniuboss2_ui.tools.utility import Utility enterprise_datas = Utility.get_json('../config/testdata_dengyu.conf') enterprise_add_data = Utility.get_excel_GUI_tuple(enterprise_datas[4]) enterprise_edit_data = Utility.get_excel_GUI_tuple(enterprise_datas[5]) enterprise_query_data = Utility.get_excel_GUI_tuple(enterprise_datas[6]) path = Service.choose_path() class TestEnterprise(unittest.TestCase): def setUp(self): print('test start') self.driver = Service.get_driver(path) Service.miss_login(self.driver, path) self.driver.find_element_by_link_text(u'企业客户').click() self.enterprise = Enterprise(self.driver) def tearDown(self): print('test over') time.sleep(2)
#Author: #CreatDate: #Version: #====#====#====#==== from selenium.webdriver.common.by import By from parameterized import parameterized import unittest import time # 获取测试数据 from woniuboss2_ui.lib.student import Student from woniuboss2_ui.tools.service import Service from woniuboss2_ui.tools.utility import Utility student_datas = Utility.get_json("../config/testdata.conf") student_data = Utility.get_excel_GUI_tuple(student_datas[1]) path = Service.choose_path() class TestStudent(unittest.TestCase): def setUp(self): print('test start') self.driver = Service.get_driver(path) Service.open_page(self.driver, path) self.student = Student(self.driver) def tearDown(self): print('test over') time.sleep(2)
def open_page(cls, driver, path): contents = Utility.get_json(path) URL = 'http://%s:%s/%s' % (contents['HOSTNAME'], contents['PORT'], contents['AURL']) driver.get(URL)
#Author: #CreatDate: #Version: #====#====#====#==== from selenium.webdriver.common.by import By from parameterized import parameterized import unittest import time # 获取测试数据 from woniuboss2_ui.lib.student_leave import StudentLeave from woniuboss2_ui.tools.service import Service from woniuboss2_ui.tools.utility import Utility student_leave_datas = Utility.get_json("../config/testdatawangqi.conf") student_leave_data = Utility.get_excel_GUI_tuple(student_leave_datas[2]) path = Service.choose_path() class TestLeave(unittest.TestCase): def setUp(self): print('test start') self.driver = Service.get_driver(path) Service.open_page(self.driver, path) self.leave = StudentLeave(self.driver) def tearDown(self): print('test over') time.sleep(2) self.driver.quit()