コード例 #1
0
    def text_input_noclear(self, method='id', path='', key=""):
        if path == '':
            Log.warn("call text_input() error : The path is null")
            raise ValueError

        else:
            if method == 'id':
                elem = self._driver.find_element_by_id(path)
                # elem.clear()
                elem.send_keys(key)

            if method == 'name':
                elem = self._driver.find_element_by_name(path)
                # elem.clear()
                elem.send_keys(key)

            if method == 'class':
                elem = self._driver.find_element_by_class_name(path)
                # elem.clear()
                elem.send_keys(key)

            if method == 'xpath':
                elem = self._driver.find_element_by_xpath(path)
                # elem.clear()
                elem.send_keys(key)

            if method == 'css':
                elem = self._driver.find_element_by_css(path)
                # elem.clear()
                elem.send_keys(key)
コード例 #2
0
    def enter(self, method='id', path=''):
        if path == '':
            Log.warn("call enter() error : The path is null")
            raise ValueError

        else:
            if method == 'id':
                elem = self._driver.find_element_by_id(path)
                elem.send_keys(Keys.ENTER)

            if method == 'name':
                elem = self._driver.find_element_by_name(path)
                elem.clear()
                elem.send_keys(Keys.ENTER)

            if method == 'class':
                elem = self._driver.find_element_by_class_name(path)
                elem.clear()
                elem.send_keys(Keys.ENTER)

            if method == 'xpath':
                elem = self._driver.find_element_by_xpath(path)
                elem.clear()
                elem.send_keys(Keys.ENTER)

            if method == 'css':
                elem = self._driver.find_element_by_css(path)
                elem.clear()
                elem.send_keys(Keys.ENTER)
コード例 #3
0
    def click(self, method='id', path=''):
        if path == '':
            Log.warn("call click() error : The path is null")
            raise ValueError

        else:
            if method == 'id':
                elem = self._driver.find_element_by_id(path)
                elem.click()

            if method == 'name':
                elem = self._driver.find_element_by_name(path)
                elem.click()

            if method == 'class':
                elem = self._driver.find_element_by_class_name(path)
                elem.click()

            if method == 'xpath':
                elem = self._driver.find_element_by_xpath(path)
                elem.click()

            if method == 'css':
                elem = self._driver.find_element_by_css(path)
                elem.click()

            if method == 'linktext':
                elem = self._driver.find_element_by_link_text(path)
                elem.click()
コード例 #4
0
    def get(cls, url='', headers='', cookies=''):
        if url == '':
            Log.warn("call get() error:url is null")
        else:
            sess = requests.Session()
            if headers == '':
                if cookies == '':
                    res = sess.get(url)
                else:
                    res = sess.get(url, cookies = cookies)
            else:
                if cookies == '':
                    res = sess.get(url, headers = headers)
                else:
                    res = sess.get(url, headers = headers, cookies = cookies)

        return res
コード例 #5
0
    def open_account(self, username, password, name, ID, cardnumber, mphone):

        try:
            Login(self._driver).login(username, password)
        except Exception:
            Log.exception('login failed leads open account failed')
            raise

        self._elem.click('linktext', u'立即开通')
        sleep(2)
        self._elem.text_input('id', 'name', name)
        sleep(1)
        self._elem.text_input('id', 'idnum', ID)
        sleep(1)
        # dropdown operation
        self._elem.click('id', "select2-bankCode-container")
        sleep(1)
        self._elem.text_input('class', 'select2-search__field', u'招商银行')
        sleep(1)
        self._elem.enter('class', 'select2-search__field')
        sleep(1)
        self._elem.text_input('id', 'bankAccount', cardnumber)
        sleep(1)
        self._elem.text_input('id', 'mphone', mphone)
        sleep(1)
        # send message
        self._elem.click('id',
                         "update_account_sendOldMobileVerificationCode_btn")
        sleep(3)
        # find sms code
        c = ConnectDb("SX_CREDIT_ONLINE_B", "postgres", "123456",
                      "10.7.106.245", "5432")
        c.Connect_to_postgreSQL()
        res = c.ExecuteSQL(
            "select send_content from credit_t_sms_message where mobile = '%s' ORDER BY created_date desc limit 1"
            % username)
        c.Disconnect_from_postgreSQL()
        patt = r'[0-9]{6}'
        rec = re.compile(patt)
        res = rec.findall(res[0][0])
        self._elem.text_input('id', 'verification_code', res[0])
        # commit
        self._elem.click('id', "open_account_submit")
コード例 #6
0
    def login(self, username, password):

        elem = Element(self._driver)
        elem.text_input('id', 'username', username)
        #sleep(1)
        elem.text_input('id', 'password', password)
        #sleep(2)
        elem.click('id', 'login_btn')
        sleep(3)
        if username == '':

            Log.info("username is null")
            try:
                assert u"请输入手机号" == elem.get_elem_text('id', 'username-error')
                flag = True

            except AssertionError:
                Log.exception('login' + '-%s-%s' % (username, password))
                raise

        elif password == '':
            Log.info("password is null")

            try:
                assert u"请输入密码" == elem.get_elem_text('id', 'password-error')
                flag = True
            except AssertionError:
                Log.exception('login' + '-%s-%s' % (username, password))
                raise

        else:
            try:
                assert elem.get_current_url(
                ) == 'http://10.7.106.235:8000/account'
                flag = True
            except AssertionError:
                Log.exception('login' + '-%s-%s' % (username, password))
                raise

        return flag
コード例 #7
0
    def get_elem_shuxingzhi(self, method = 'id', path = '', shuxing = ''):

        if path == '' or shuxing == '':
            Log.warn("call get_elem_shuxingzhi() error : The path is null")
            raise ValueError

        else:
            if method == 'id':
                elem = self._driver.find_element_by_id(path)
                return elem.get_attribute(shuxing)

            if method == 'name':
                elem = self._driver.find_element_by_name(path)
                return elem.get_attribute(shuxing)

            if method == 'class':
                elem = self._driver.find_element_by_class_name(path)
                return elem.get_attribute(shuxing)

            if method == 'xpath':
                elem = self._driver.find_element_by_xpath(path)
                return elem.get_attribute(shuxing)
コード例 #8
0
    def loan(self,
             loan_type,
             repay_method,
             loan_term,
             loan_amount,
             loan_purpose,
             invitation_code=''):

        #step 1
        # 取消审核中的借款
        self._elem.click('linktext', u'我的借款')
        sleep(2)
        try:
            if self._elem.get_elem_text(
                    'xpath',
                    ".//*[@id='base_info_body']/div/div[2]/div/table[1]/tbody/tr[3]/td[6]"
            ) == u'审核中':
                self._elem.click(
                    'xpath',
                    ".//*[@id='base_info_body']/div/div[2]/div/table[1]/tbody/tr[3]/td[7]/a/font"
                )
                sleep(3)
                self._elem.click('xpath', "//a[@id='qx_loanApplybut']")
                sleep(1)
            elif self._elem.get_elem_text(
                    'xpath',
                    ".//*[@id='base_info_body']/div/div[2]/div/table[1]/tbody/tr[3]/td[6]"
            ) == u'申请':
                self._elem.click(
                    'xpath',
                    ".//*[@id='base_info_body']/div/div[2]/div/table[1]/tbody/tr[3]/td[7]/a[2]/font"
                )
                sleep(3)
                self._elem.click('xpath', "//a[@id='qx_loanApplybut']")
                sleep(1)

        except:

            Log.info(u'没有未结束的借款')

        finally:
            self._elem.click('linktext', u'我要借款')
            sleep(2)
            self._elem.click('xpath', 'html/body/div[1]/div[1]/div[1]/div/a')
            sleep(3)

            dict1 = {
                u'善薪贷': '51a7fa647e18641fe053326410ac9559',
                u'善美贷': '51a7fa647e36641fe053326410ac9559',
                u'善楼贷': '51a7fa647e1d641fe053326410ac9559',
                u'善时贷': '51a7fa647e31641fe053326410ac9559',
                u'保单贷': '51a7fa647e2c641fe053326410ac9559',
                u'学历贷': '51a7fa647e27641fe053326410ac9559',
                u'精英贷': '51a7fa647e22641fe053326410ac9559',
                u'培训贷': '2c91808a5c901d6f015cab18708e087a'
            }

            for key, value in dict1.items():
                if key == loan_type:
                    self._elem.dropdown_choose('value', value, 'id',
                                               'loan_product')

            self._elem.dropdown_choose('value', repay_method, 'id',
                                       'loan_repayment_method')

            sleep(1)

            self._elem.dropdown_choose('value', loan_term, 'id', 'loan_term')

            self._elem.text_input('id', 'loan_amount', loan_amount)

            self._elem.dropdown_choose('value', loan_purpose, 'id',
                                       'loan_purpose')

            self._elem.text_input('id', 'invitation_code', invitation_code)

            # self._elem.dropdown_choose('value', "001001001001005", 'id', 'loan_city')
            #
            # sleep(1)

            self._elem.click('id', "select2-loan_city-container")

            self._elem.text_input('class', 'select2-search__field', u'上海市')

            self._elem.enter('class', 'select2-search__field')

            self._elem.dropdown_choose('value',
                                       "5193c7186b38600de053326410acda90",
                                       'id', 'loan_sales_department')

            sleep(1)

            self._elem.text_input('xpath', ".//*[@id='loanDesc']", u'善薪贷')

            self._elem.click('xpath', ".//*[@id='loan_apply_btn']")

            sleep(3)

            #step 2
            # 身份证明
            self._elem.click('id', 'idcard_upload_btn')
            sleep(2)
            # upload three id pictures
            self._elem.click(
                'xpath',
                "//div[@id='batchContainer']/button[@class='addFile add-file']"
            )
            sleep(2)
            os.system(
                r"E:\pythonworkspace\functional_automation\autoit\loan_id_pic_upload.exe"
            )
            sleep(1)
            self._elem.click(
                'xpath',
                "//div[@id='batchContainer']/button[@class='addFile add-file']"
            )
            sleep(2)
            os.system(
                r"E:\pythonworkspace\functional_automation\autoit\loan_id_pic_upload2.exe"
            )
            sleep(1)
            self._elem.click(
                'xpath',
                "//div[@id='batchContainer']/button[@class='addFile add-file']"
            )
            sleep(2)
            os.system(
                r"E:\pythonworkspace\functional_automation\autoit\loan_id_pic_upload3.exe"
            )
            sleep(1)

            self._elem.click(
                'xpath',
                "//div[@id='batchContainer']/button[@class='batchUpload batch-upload']"
            )
            sleep(2)
            self._elem.click('xpath',
                             "//img[@src='/images/shade-closebtn.png']")
            sleep(1)

            # 房产证明
            self._elem.click('id', 'house_upload_btn')
            sleep(2)
            self._elem.click(
                'xpath',
                "//div[@id='batchContainer']/button[@class='addFile add-file']"
            )
            sleep(2)
            os.system(
                r"E:\pythonworkspace\functional_automation\autoit\loan_house_pic_upload.exe"
            )
            sleep(1)
            self._elem.click(
                'xpath',
                "//div[@id='batchContainer']/button[@class='batchUpload batch-upload']"
            )
            sleep(2)
            self._elem.click('xpath',
                             "//img[@src='/images/shade-closebtn.png']")
            sleep(1)

            # 居住证明
            self._elem.click('id', 'live_upload_btn')
            sleep(2)
            self._elem.click(
                'xpath',
                "//div[@id='batchContainer']/button[@class='addFile add-file']"
            )
            sleep(2)
            os.system(
                r"E:\pythonworkspace\functional_automation\autoit\loan_live_pic_upload.exe"
            )
            sleep(1)
            self._elem.click(
                'xpath',
                "//div[@id='batchContainer']/button[@class='batchUpload batch-upload']"
            )
            sleep(2)
            self._elem.click('xpath',
                             "//img[@src='/images/shade-closebtn.png']")
            sleep(1)

            # 我已阅读
            self._elem.click('id', 'loan_authorization_ipt')

            # 提交
            self._elem.click('id', 'loan_commit_btn')
            sleep(1)
            self._elem.click('id', 'confirm_commit_loan')
            sleep(1)

            # 断言提交成功页面
            assert self._elem.get_elem_text(
                'xpath', "//h2[@style='color:#21aa71;']") == u'借款申请成功,请等待处理'
コード例 #9
0
 def test003_login(self):
     if Login(self.driver).login('18252023049', ''):
         Log.info("test003_login pass")
コード例 #10
0
 def test002_login(self):
     if Login(self.driver).login('', '123456'):
         Log.info("test002_login pass")
コード例 #11
0
 def test001_login(self):
     if Login(self.driver).login('18252023049', 'cjs123456'):
         Log.info("test001_login pass")
コード例 #12
0
    def base_info_edit(self):

        self._elem.click('linktext', u'我的借款')
        sleep(2)
        try:
            if self._elem.get_elem_text(
                    'xpath',
                    ".//*[@id='base_info_body']/div/div[2]/div/table[1]/tbody/tr[3]/td[6]"
            ) == u'审核中':
                self._elem.click(
                    'xpath',
                    ".//*[@id='base_info_body']/div/div[2]/div/table[1]/tbody/tr[3]/td[7]/a/font"
                )
                sleep(3)
                self._elem.click('xpath', "//a[@id='qx_loanApplybut']")
                sleep(1)
            elif self._elem.get_elem_text(
                    'xpath',
                    ".//*[@id='base_info_body']/div/div[2]/div/table[1]/tbody/tr[3]/td[6]"
            ) == u'申请':
                self._elem.click(
                    'xpath',
                    ".//*[@id='base_info_body']/div/div[2]/div/table[1]/tbody/tr[3]/td[7]/a[2]/font"
                )
                sleep(3)
                self._elem.click('xpath', "//a[@id='qx_loanApplybut']")
                sleep(1)

        except:

            Log.info(u'没有未结束的借款')

        finally:

            self._elem.click('linktext', u'基本信息')
            sleep(2)
            assert self._elem.get_current_url(
            ) == "http://10.7.106.235:8000/account/baseInfo"

            self._elem.click('xpath', "//button[@class='account-edit-btn ']")
            sleep(2)
            self._elem.dropdown_choose('value', u'本科', 'id', 'education')
            # sleep(1)
            self._elem.dropdown_choose('value', u'未婚', 'id', 'marriage')
            # sleep(1)
            self._elem.dropdown_choose('value', '110', 'id', 'live_province')
            # sleep(1)
            self._elem.dropdown_choose('value', '110100000000', 'id',
                                       'live_city')
            # sleep(1)
            self._elem.dropdown_choose('value', '110101000000', 'id',
                                       'live_county')
            # sleep(1)
            self._elem.text_input('name', 'liveDetailAddress', u'朝阳门南大街')
            # sleep(1)
            self._elem.text_input('name', 'workCompany', u'上海市腾讯大厦')
            # sleep(1)
            self._elem.text_input('name', 'cTel', '021-8857623')
            # sleep(1)
            self._elem.dropdown_choose('value', '310', 'id',
                                       'company_province')
            # sleep(1)
            self._elem.dropdown_choose('value', '310100000000', 'id',
                                       'company_city')
            # sleep(1)
            self._elem.dropdown_choose('value', '310104000000', 'id',
                                       'company_county')
            # sleep(1)
            self._elem.text_input('name', 'companyDetailAddress', u'虹梅路1801号')
            # sleep(1)
            self._elem.text_input('name', 'workYears', '10')
            # sleep(1)
            self._elem.dropdown_choose('value', u'网银', 'id', 'pay_type')
            # sleep(1)
            self._elem.click('id', 'person_save_btn')
            sleep(2)
            # print self._elem.get_elem_text('xpath', ".//*[@id='edit_form']/div[4]/div[5]/div[2]/em")
            assert self._elem.get_elem_text(
                'xpath',
                ".//*[@id='edit_form']/div[4]/div[5]/div[2]/em") == '10'