def setUp(self): config = ConfigParser() config.read(setting_path()) self.browser = browse_driver.Firefox() self.browser.maximize_window() url = config.get('testUrl', 'url') print(url) self.browser.get(config.get('testUrl', 'url')) self.username = config.get('projectManager', 'taohui') self.password = config.get('operation', 'password') self.manager_username = config.get('management', 'Hujinping') self.area_name = getPeopleName() web_login(self.browser, self.username, self.password)
def setUpClass(cls): config = ConfigParser() cls.path = setting_path() cls.file_path = r'C:\Users\%s\Desktop\UIAutotest\Page\file\1.jpg' % ( str(getpass.getuser())) config.read(cls.path) url = config.get('testUrl', 'perfurl') cls.password = config.get('operation', 'password') # 随机姓名 cls.people_name = getPeopleName() # 随机身份证 cls.identity = getDistrictCode() cls.browser = browse_driver.Firefox() cls.browser.maximize_window() cls.browser.get(url) cls.mobile = get_mobile() cls.code = 11111 web_workman_register(cls.browser, cls.mobile, cls.code, cls.password)
def setUp(self): config = ConfigParser() self.path = setting_path() self.file_path = r'C:\Users\%s\Desktop\UIAutotest\Page\file\1.jpg' % (str(getpass.getuser())) config.read(self.path) url = config.get('testUrl', 'url') self.password = config.get('operation', 'password') # 随机姓名 self.people_name = getPeopleName() # 随机身份证 self.identity = getDistrictCode() self.browser = browse_driver.Firefox() self.browser.maximize_window() self.browser.get(url) self.mobile = get_mobile() self.new_password = 654321 self.code = 11111 self.get_new_mobile = get_mobile()
def setUp(self): config = ConfigParser() self.path = setting_path() self.file_path = r'C:\Users\%s\Desktop\UIAutotest\Page\file\1.jpg' % (str(getpass.getuser())) config.read(self.path) url = config.get('testUrl', 'url') self.username = config.get('labor', 'Wuhuigang') self.username1 = config.get('projectManager', 'taohui') self.password = config.get('operation', 'password') # 随机姓名 self.people_name = getPeopleName() # 随机身份证 # 工件名称 self.artifact = self.people_name + '的工件' self.identity = getDistrictCode() self.browser = browse_driver.Firefox() self.browser.maximize_window() self.browser.get(url) self.mobile = get_mobile() self.new_password = 654321 self.code = 11111
def family_information(driver): sleep(3) try: get_element(driver, ('xpath', "//div[@data-target='#mo-home']")).click() get_element( driver, ('xpath', "//input[@data-duplex-changed='show1']")).click() get_elements( driver, ('xpath', "//div[@class='pi-plane-con-text']/input"))[0].clear() get_elements( driver, ('xpath', "//div[@class='pi-plane-con-text']/input"))[0].send_keys('2') setting_input_time(driver) # 结婚日期 get_elements(driver, ('xpath', "//div[@id='marry']/input"))[0].send_keys( get_pass_dates(100)) get_elements( driver, ('xpath', "//div[@class='pi-plane-con-text']/input"))[1].send_keys( getPeopleName()) get_elements( driver, ('xpath', "//div[@class='pi-plane-con-text']/input"))[2].send_keys( get_mobile()) relation_element = "//div[2]/div/div[6]/select/option[%s]" % str( random.randint(2, 8)) get_element(driver, ('xpath', relation_element)).click() len_province = len( get_elements(driver, ('xpath', "//div[2]/div/div[7]/select/option"))) province_element = "//div[2]/div/div[7]/select/option[%s]" % str( random.randint(2, len_province)) get_element(driver, ('xpath', province_element)).click() sleep(1) len_city = len( get_elements(driver, ('xpath', "//div[2]/div/div[8]/select/option"))) city_element = "//div[2]/div/div[8]/select/option[%s]" % str( random.randint(2, len_city)) get_element(driver, ('xpath', city_element)).click() sleep(1) len_district = len( get_elements(driver, ('xpath', "//div[2]/div/div[9]/select/option"))) district_element = "//div[2]/div/div[9]/select/option[%s]" % str( random.randint(1, len_district)) get_element(driver, ('xpath', district_element)).click() get_element(driver, ('xpath', "//div[2]/div/div[10]/input")).send_keys('塔克拉玛干') get_element(driver, ('xpath', "//div[2]/div/div[11]/input")).send_keys('厄尔') get_elements(driver, ('xpath', "//button[contains(text(),'保存')]"))[1].click() assert get_element(driver, ('id', "LAY_demo2")).text == '更新成功' a = get_element(driver, ('id', "LAY_demo2")).text print(a) except Exception as e: print(e) bug_photo(driver) assert False
def test_04_request_for_overtime(self): # 加班工作流 request_for_overtime(self.browser, getPeopleName(), self.file_path) logout(self.browser) web_login(self.browser, self.username1, self.password) approve_workflow(self.browser, '加班工作流')
def test_02_batch_add_workman(self): # 批量请假工作流 batch_add_workman(self.browser, self.file_path, getPeopleName()) logout(self.browser) web_login(self.browser, self.username1, self.password) approve_workflow(self.browser, '请假工作流')
def test_01_to_apply_for_leave(self): # 单人请假工作流 to_apply_for_leave(self.browser, self.file_path, getPeopleName()) logout(self.browser) web_login(self.browser, self.username1, self.password) approve_workflow(self.browser, '请假工作流')
def test_05_setting_attendance_machine(self): setting_attendance_machine(self.browser, getPeopleName())
def test_NewCompany(self): company_name = getCompanyName() people_name = getPeopleName() mobile = get_mobile() into_one_level(self.driver, '运维面板') into_two_level(self.driver, '注册公司管理') self.driver.find_element_by_xpath( "//button[contains(text(),'新增')]").click() self.driver.find_element_by_xpath( "//input[@placeholder='企业名称']").send_keys(company_name) self.driver.find_element_by_xpath( "//input[@placeholder='0000XX0000']").send_keys(random_str(18)) # a = self.driver.find_element_by_xpath(".//*[@id='company-address']/div/div[1]/select") # a.find_element_by_xpath("//option[@value='北京市']").click() # 方法1 self.driver.find_element_by_xpath( ".//*[@id='company-address']/div/div[1]/select/option[3]").click( ) # 方法2 省 # Select(a).select_by_value('内蒙古自治区') # 方法3 self.driver.find_element_by_xpath( ".//*[@id='company-address']/div/div[2]/select/option[2]").click( ) # 市 self.driver.find_element_by_xpath( ".//*[@id='company-address']/div/div[3]/select/option[3]").click( ) # 区 self.driver.find_element_by_xpath( "//input[@placeholder='输入街道名称']").send_keys('南京路') self.driver.find_element_by_xpath( "//input[@placeholder='门派号、小区名称、房间号']").send_keys('3号') information = '室内装潢及设计、园林绿化、园林绿化工程施工等' self.driver.find_element_by_xpath( "//textarea[@placeholder='长度不超过500个字符']").send_keys(information) self.driver.find_elements_by_class_name("form-control")[10].send_keys( get_org_no()) self.driver.find_element_by_xpath( "//input[@placeholder='输入法人姓名']").send_keys(getRandomName()) self.driver.find_element_by_xpath( "//button[contains(text(),'完成')]").click() self.driver.refresh() sleep(2) # if is_element_present(self.driver, ('xpath', "html/body/div[1]/div[1]/div/div[2]/div[2]/div/div[3]/div[2]/div[4]/div[2]/ul/li[1]/a")): # sleep(0.5) # self.driver.find_element_by_xpath( # "html/body/div[1]/div[1]/div/div[2]/div[2]/div/div[3]/div[2]/div[4]/div[2]/ul/li[1]/a").click() elem = "//td[contains(text(),%s)]" % company_name new_company_name = self.driver.find_elements_by_xpath(elem)[-5].text assert new_company_name == company_name self.driver.find_element_by_xpath( "//input[@placeholder='请输入公司名称筛选']").send_keys(company_name) self.driver.find_element_by_xpath( "//button[contains(text(),'搜索')]").click() elem = "//td[contains(text(),%s)]" % company_name select_company_name = self.driver.find_element_by_xpath(elem).text assert select_company_name == company_name # 全称查询公司 self.driver.find_element_by_xpath( "//input[@placeholder='请输入公司名称筛选']").clear() self.driver.find_element_by_xpath( "//input[@placeholder='请输入公司名称筛选']").send_keys(company_name[1:3]) self.driver.find_element_by_xpath( "//button[contains(text(),'搜索')]").click() assert company_name in select_company_name new_elem = "//td[contains(text(),%s)]" % company_name sleep(0.5) select_companys_name = self.driver.find_elements_by_xpath(new_elem) company_name_list = [] j = 0 # 公司的index 规律是每5个就是公司的text # 获取所有的公司名称 for i in range(int(len(select_companys_name) / 5)): company_name_list.insert( i, self.driver.find_elements_by_xpath(new_elem)[j].text) j += 5 print(company_name_list) assert company_name in company_name_list # 包含这个字段的公司,在列表里面