def __init__(self,driver,base_config_path): self.driver = driver Service.open_page(self.driver, base_config_path) Service.miss_login(self.driver, base_config_path) time.sleep(5) self.driver.find_element_by_partial_link_text('资源管理').click() time.sleep(5)
def do_login_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_manager']) self.input_upass(info['password_manager']) self.input_vfcode(info['verifycode']) self.click_button()
def do_login(self,base_config_path,login_data): Service.open_page(self.driver,base_config_path) self.input_uname(login_data['username']) self.input_upass(login_data['password']) self.input_vfcode(login_data['verifycode']) self.click_button()
def send_sencpass(self, secp): self.driver.find_element_by_id('btn-decrypt').click() time.sleep(2) sec = self.driver.find_element_by_xpath( '//div[@id="secondPass-modal"]/div/div/div[2]/input') Service.send_input(sec, secp) self.driver.find_element_by_xpath( '//div[@id="secondPass-modal"]/div/div/div[3]/button').click()
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_submit(self, cus_region, user_dept, user_name, cus_status, cus_source, region_name, dept_name, worker_name): self.click_transmit() self.select_origin_region(cus_region) self.select_origin_dept(user_dept) self.select_origin_emp(user_name) self.select_status(cus_status) self.select_source(cus_source) time.sleep(1) total_before = int(self.get_total()) self.select_transmit_region(region_name) self.select_transmit_dept(dept_name) self.select_transmit_worker(worker_name) time.sleep(2) self.click_option() self.click_submit() time.sleep(2) self.click_confirm() time.sleep(2) if Service.is_element_present( self.driver, By.XPATH, '/html/body/div[7]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr[1]/td[1]/input' ): total_after = int(self.get_total()) print(total_after) else: total_after = 0 total = total_before - total_after print(total) return total
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 if Service.is_element_present(self.driver,By.LINK_TEXT,'注销'): actual='pass' self.driver.find_element_by_link_text('注销').click() else: actual = 'fail' self.driver.refresh() self.assertEqual(actual,expect)
def input_vfcode(self, verifycode): vfcode = self.driver.find_element_by_xpath( '//div[@class="modal-body"]/div[3]/input') Service.send_input(vfcode, verifycode)
def input_upass(self, password): upass = self.driver.find_element_by_xpath( '//div[@class="modal-body"]/div[2]/input') Service.send_input(upass, password)
def select_source(self,cus_source): source=self.driver.find_element_by_xpath('//form[@id="addCus"]/div/div[5]/div/select') Service.select_by_name(source,cus_source)
def setUpClass(cls): cls.driver = Service.get_driver('..\\config\\base.conf') cls.common = ManageResource(cls.driver, '..\\config\\base.conf')
def publick_keyward_query(self, value): key = self.driver.find_element_by_xpath( '//div[@id="content"]/div[2]/div/input').click() Service.send_input(key, value) self.driver.find_element_by_xpath( '//div[@id="content"]/div[2]/div/button').click()
def input_keyward(self,cus_keyw): keyward=self.driver.find_element_by_xpath('//div[@id="content"]/div[2]/div[2]/input') Service.send_input(keyward,cus_keyw)
def send_end_time(self, etime): date = self.driver.find_element_by_id('date2') Service.send_input(date, etime)
def send_start_time(self, stime): date = self.driver.find_element_by_id('date1') Service.send_input(date, stime)
def select_source(self, source_name): select = self.driver.find_element_by_xpath( '//div[@id="content"]/div[2]/div/select[3]') Service.select_by_name(select, source_name)
def select_worker(self, work_name): select = self.driver.find_element_by_css_selector( 'div.col-lg-12:nth-child(8) > select:nth-child(1)') select.click() Service.select_by_name(select, work_name)
def select_pooltype(self, pool_name): # Service.miss_login(self.driver,'..\\config\\base.conf') select = self.driver.find_element_by_xpath( '//div[@id="content"]/div[2]/div/select[1]') Service.select_by_name(select, pool_name)
def select_grade(self,cus_grade): grade=self.driver.find_element_by_xpath('//form[@id="addCus"]/div/div[3]/div[2]/select') Service.select_by_name(grade,cus_grade)
def input_name(self, username): uname = self.driver.find_element_by_xpath( '//div[@class="modal-body"]/div[1]/input') Service.send_input(uname, username)
def select_channel(self,cus_channel): channel=self.driver.find_element_by_name('source') Service.select_by_name(channel,cus_channel)
def send_keywords(self, keywords): input_cusinfo=self.driver.find_element_by_xpath\ ('//div[@id="content"]/div[2]/div/input[3]') Service.send_input(input_cusinfo, keywords)
def assign_curriculum(self,cus_curriculum): curriculum=self.driver.find_element_by_xpath('//div[@id="content"]/div[2]/div[3]/select') Service.select_by_name(curriculum,cus_curriculum)
def __init__(self): self.session = Service.get_session()
def setUp(self) -> None: self.driver = Service.get_driver('..\\config\\base.conf') self.transmit = TrainTransmit(self.driver)
def remark(self, value): remark = self.driver.find_element_by_xpath( "//form[@id='formFollow']/div[2]/div/textarea") Service.send_input(remark, value)
def select_status(self, status_name): status = self.driver.find_element_by_id('newStatus') Service.select_by_name(status, status_name)
def select_experience(self,experience_name): experience=self.driver.find_element_by_xpath('//form[@id="addCus"]/div/div[4]/div[2]/select') Service.select_by_name(experience,experience_name)
def __init__(self, driver, base_config_path): self.driver = driver Service.miss_login(self.driver, base_config_path) time.sleep(1) self.driver.find_element_by_partial_link_text('报表中心').click()
def select_priority(self, priority_name): priority = self.driver.find_element_by_xpath( '//form[@id="formFollow"]/div/div[2]/select') Service.select_by_name(priority, priority_name)