Exemple #1
0
 def setUp(self):
     conf = ConfigParser()
     self.file_path = file_path('1')
     conf.read(setting_path())
     self.username = conf.get('teamLeader', 'Zhenglinlin')
     self.password = conf.get('operation', 'password')
     self.username1 = conf.get('management', 'yangyinghua')
     appPackage = conf.get('android', 'appPackage')
     appActivity = conf.get('android', 'appActivity')
     print(appPackage + '\n' + appActivity)
     self.people = get_people_name()
     self.mobile = get_mobile()
     device_name = get_android_udid()
     stop_android_appium()
     sleep(2)
     start_android_appium(device_name)
     desired_caps = {
         'platformName': 'Android',
         'deviceName': device_name,
         'platformVersion': get_android_version(),
         'appPackage': 'com.zld.zld_face_rec_app',
         'appActivity': '.Login.LaunchActivity',
         # 'appPackage': appPackage,
         # 'appActivity': appActivity,
         'chromeOptions': {
             'androidProcess': 'com.zld.zld_face_rec_app'
         },
         'showChromedriverLog': True,
         'recreateChromeDriverSessions': True,
         # 'automationName':  'Uiautomator2'
     }
     self.driver = android_driver.Remote('http://127.0.0.1:4723/wd/hub',
                                         desired_caps)
     sleep(3)
Exemple #2
0
    def setUp(self):
        conf = ConfigParser()
        self.path = r'C:\Users\%s\Desktop\UIAutotest\TeseCase\Web\setting.ini' % (
            str(getpass.getuser()))
        self.file_path = r'C:\Users\%s\Desktop\UIAutotest\Page\file\1.jpg' % (
            str(getpass.getuser()))
        conf.read(self.path)
        self.username = conf.get('labor', 'Wuhuigang')
        # self.username = conf.get('teamLeader', 'Zhenglinlin')
        self.password = conf.get('operation', 'password')
        self.username1 = conf.get('projectManager', 'taohui')
        url = conf.get('testUrl', 'perfurl')
        self.browser = browse_driver.Firefox()
        self.browser.maximize_window()
        self.browser.implicitly_wait(5)
        # 需要特别说明的是:隐性等待对整个driver的周期都起作用,所以只要设置一次即可,
        # 我曾看到有人把隐性等待当成了sleep在用,走哪儿都来一下…
        self.browser.get(url)
        self.mobile = get_mobile()
        # self.mobile = 15308222551
        web_login(self.browser, self.username, self.password)
        change_workman_contract_date(self.browser)
        logout(self.browser)
        web_login(self.browser, self.username1, self.password)
        approve_workflow(self.browser, '修改用工合同结束时间')

        # general_contract(self.browser, '总包合同', '杭州', '浙江', '测试试试试试')
        # select_city(self.browser)
        pass
 def setUp(self):
     # 实例化一个火狐配置文件
     fp = browse_driver.FirefoxProfile()
     # 设置各项参数,参数可以通过在浏览器地址栏中输入about:config查看。
     # 设置成0代表下载到桌面,1代表浏览器默认下载路径;设置成2则可以保存到指定目录
     fp.set_preference("browser.download.folderList", 2)
     # 是否显示开始,(个人实验,不管设成True还是False,都不显示开始,直接下载)
     fp.set_preference("browser.download.manager.showWhenStarting", False)
     # 下载到指定目录
     fp.set_preference("browser.download.dir", test_report_path())  # 路径名称文件夹设置成英文,不然不能下载到指定目录
     # 不询问下载路径;后面的参数为要下载页面的Content-type的值
     fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.ms-excel")
     config = ConfigParser()
     config.read(setting_path())
     self.file_path = r'C:\Users\%s\Desktop\UIAutotest\Page\file\1.jpg' % (str(getpass.getuser()))
     self.driver = browse_driver.Firefox(firefox_profile=fp)
     self.driver.maximize_window()
     self.driver.get(config.get('testUrl', 'url'))
     self.username = config.get('labor', 'Wuhuigang')
     self.password = config.get('operation', 'password')
     ws_url = config.get('testUrl', 'ws_test_url')
     ws = create_connection("ws://%s/wsapi" % ws_url)
     self.ws_driver = BuilderBaseFunc(ws, ws_url)
     self.payroll_name = get_people_name()
     self.mobile = get_mobile()
     self.code = '11111'
     self.people_name = get_people_name()
     # 随机身份证
     self.identity = getDistrictCode()
 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()
Exemple #5
0
 def setUp(self):
     config = ConfigParser()
     self.path = setting_path()
     self.file_path = file_path('1')
     config.read(self.path)
     url = config.get('testUrl', 'url')
     ws_url = config.get('testUrl', 'ws_test_url')
     ws = create_connection("ws://%s/wsapi" % ws_url)
     self.ws_driver = BuilderBaseFunc(ws, ws_url)
     self.username = config.get('operation', 'username')
     self.password = config.get('operation', 'password')
     # 随机姓名
     self.people_name = get_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
     self.get_new_mobile = get_mobile()
def web_employee_registration(browser, name, mobile, password, company_name):
    # 企业员工注册
    """

    :param browser:
    :param name:
    :param mobile:
    :param password:
    :param company_name:
    :return:
    """
    browser.find_element_by_xpath("//button[contains(text(),'注册')]").click()
    sleep(0.5)
    browser.find_element_by_xpath("//div[contains(text(),'企业员工')]").click()
    get_element(browser, ('xpath', "//input[@data-pattern-message='请输入正确的手机号码']")).send_keys(mobile)
    sleep(0.5)
    get_elements(browser, ('xpath', "//span[contains(text(),'点击获取验证码')]"))[0].click()
    if is_element_present_3s(browser, ('xpath', "//div[contains(text(),'此号码已经存在,无需注册')]"), 5):
        get_element(browser, ('id', 'username')).send_keys(get_mobile())
    if is_element_present_3s(browser, ('xpath', "//input[@data-tip='请输入真实姓名']"), 4):
        get_element(browser, ('xpath', "//input[@placeholder='手机验证码']")).send_keys('11111')
    else:
        browser.find_element_by_xpath("//div[contains(text(),'企业员工')]").click()
        get_element(browser, ('xpath', "//input[@data-pattern-message='请输入正确的手机号码']")).send_keys(mobile)
        get_element(browser, ('xpath', "//input[@placeholder='短信校验码']")).clear()
        get_element(browser, ('xpath', "//input[@placeholder='短信校验码']")).send_keys('11111')
    get_element(browser, ('xpath', "//input[@data-tip='请输入真实姓名']")).send_keys(name)
    get_element(browser, ('id', "password1")).send_keys(password)
    get_element(browser, ('xpath', "//input[@data-tip='请再新输入密码']")).send_keys(password)
    get_element(browser, ('xpath', "//b[@role='presentation']")).click()
    get_element(browser, ('xpath', "//input[@class='select2-search__field' and @type='search']")).send_keys(
        company_name)
    sleep(0.5)
    get_element(browser, ('xpath', "//input[@class='select2-search__field' and @type='search']")).send_keys(Keys.ENTER)
    get_element(browser, ('xpath', "//input[@class='agree-input']")).click()
    get_element(browser, ('xpath', "//button[contains(text(),'创建账户')]")).click()
    sleep(0.5)
    a = get_element(browser, ('xpath', "//div[contains(text(),'成功:公司职员注册')]")).text
    if '成功:公司职员注册' == a:
        pass
    else:
        print("失败:公司职员注册")
        bug_photo(browser)
        assert False
    sleep(2)
    browser.find_element_by_xpath("//button[contains(text(),'登录')]").click()
    get_element(browser, ('id', "username")).send_keys(mobile)
    get_element(browser, ('id', "password")).send_keys(password)
    get_element(browser, ('id', "loginButton")).click()
 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', 'url')
     cls.password = config.get('operation', 'password')
     # 随机姓名
     cls.people_name = get_people_name()
     # 随机身份证
     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)
Exemple #8
0
 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 setUp(self):
     config = ConfigParser()
     self.path = setting_path()
     self.file_path = file_path('1')
     config.read(self.path)
     url = config.get('testUrl', 'url')
     self.ws_url = config.get('testUrl', 'ws_test_url')
     self.username = config.get('labor', 'Wuhuigang')
     self.username1 = config.get('operation', 'username')
     self.password = config.get('operation', 'password')
     # 随机姓名
     self.people_name = get_people_name()
     # 随机身份证
     # 工件名称
     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 web_workman_register(browser, mobile, code, password):
    # 工人注册
    """

    :param browser:
    :param mobile:
    :param code:
    :param password:
    :return:
    """
    try:
        browser.find_element_by_xpath("//button[contains(text(),'注册')]").click()
        sleep(1)
        get_element(browser, ('id', 'username')).send_keys(mobile)
        browser.find_element_by_xpath("//span[contains(text(),'点击获取验证码')]").click()
        new_mobile = get_mobile()
        if is_element_present_3s(browser, ('xpath', "//div[contains(text(),'此号码已经存在,无需注册')]"), 3):
            get_element(browser, ('id', 'username')).send_keys(new_mobile)
            browser.find_element_by_xpath("//span[contains(text(),'点击获取验证码')]").click()
            get_elements(browser, ('xpath', "//input[@placeholder='短信校验码']"))[0].send_keys(code)
            get_element(browser, ('id', "password")).send_keys(password)
            get_element(browser, ('id', 'repassword')).send_keys(password)
            sleep(1)
            get_element(browser, ('id', 'repassword')).click()
            get_element(browser, ('xpath', "//input[@class='agree-input']")).click()
            browser.find_element_by_xpath("//button[contains(text(),'创建账户')]").click()
            sleep(2)
            browser.find_element_by_xpath("//button[contains(text(),'登录')]").click()
            get_element(browser, ('id', "username")).send_keys(mobile)
            get_element(browser, ('id', "password")).send_keys(password)
            get_element(browser, ('id', "loginButton")).click()
            sleep(3)
        else:
            get_elements(browser, ('xpath', "//input[@placeholder='手机验证码']"))[0].send_keys(code)
            get_element(browser, ('id', "password")).send_keys(password)
            get_element(browser, ('id', 'repassword')).send_keys(password)
            sleep(1)
            get_element(browser, ('id', 'repassword')).click()
            get_element(browser, ('xpath', "//input[@class='agree-input']")).click()
            browser.find_element_by_xpath("//button[contains(text(),'创建账户')]").click()
            sleep(0.5)
            if is_element_present_3s(browser,
                                     ('xpath', "//span[@class='text-muted tel-tip' and contains(text(),'必须填写')]"),
                                     2):
                get_element(browser, ('id', 'username')).clear()
                get_element(browser, ('id', 'username')).send_keys(mobile)
                get_elements(browser, ('xpath', "//input[@placeholder='短信校验码']"))[0].clear()
                get_elements(browser, ('xpath', "//input[@placeholder='短信校验码']"))[0].send_keys(code)
                get_element(browser, ('id', "password")).clear()
                get_element(browser, ('id', "password")).send_keys(password)
                get_element(browser, ('id', 'repassword')).clear()
                get_element(browser, ('id', 'repassword')).send_keys(password)
                sleep(0.5)
                get_element(browser, ('id', 'repassword')).click()
                sleep(0.1)
                browser.find_element_by_xpath("//button[contains(text(),'创建账户')]").click()
                sleep(2)
            browser.find_element_by_xpath("//button[contains(text(),'登录')]").click()
            get_element(browser, ('id', "username")).send_keys(mobile)
            get_element(browser, ('id', "password")).send_keys(password)
            get_element(browser, ('id', "loginButton")).click()
        return mobile
    except Exception as e:
        print(e)
        print("工人注册失败")
        assert False
Exemple #12
0
 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  # 包含这个字段的公司,在列表里面