def mess_limit(self, login, password): th = "".join([random.choice(string.letters) for i in xrange(90)]) tx = "".join([random.choice(string.letters) for i in xrange(2010)]) self.driver.implicitly_wait(30) sleep(10) autologin(self, login, password) menu = self.driver.find_element_by_xpath('//*[@class="OtpCommonMobileBundle-OtpCommonStyle-headerButtonMenu"]') tap(self, menu) self.driver.switch_to.context('NATIVE_APP') transfer = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("Messages|MESSAGES")') transfer.click() new = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("New message|NEW MESSAGE")') new.click() self.driver.switch_to.context('WEBVIEW') send = self.driver.find_element_by_xpath('//*[@class="OtpMessageMobileBundle-OtpMessageStyle-sendMessage"]') theme = self.driver.find_element_by_xpath('//*[@class="gwt-TextBox InputAppearance-InputCss-mgwt-InputBox-box"]') text = self.driver.find_element_by_xpath('//*[@class="gwt-TextArea InputAppearance-InputCss-mgwt-InputBox-box"]') w = theme.get_attribute('maxlength') self.assertEqual(w, '84') theme.send_keys(th) text.send_keys(tx) self.assertEqual(len(self.driver.find_element_by_xpath('//*[@class="gwt-TextBox InputAppearance-InputCss-mgwt-InputBox-box"]').get_attribute('value')), 84) tap(self, send) self.driver.switch_to.context('NATIVE_APP') err = self.driver.find_element_by_id('ua.com.cs.ifobs.mobile.android.otp:id/dialogText').get_attribute('text') self.assertTrue(err == 'The message length exceeds 2000 characters.')
def acc_rule_13(self, login, password): self.driver.implicitly_wait(30) sleep(10) autologin(self, login, password) self.assertTrue( self.driver.find_elements_by_xpath( '//*[@class="OtpDashboardMobileBundle-OtpDashboardStyle-logo"]')) table = self.driver.find_elements_by_xpath( '//*[@class="OtpDashboardMobileBundle-OtpDashboardStyle-indicatorTitleWidgetContainer"]' ) for i in table: if i.find_element_by_xpath( './/*[@class="OtpDashboardMobileBundle-OtpDashboardStyle-nameTitleWidget"]' ).get_attribute('textContent') == 'Accounts': count = i.find_element_by_xpath( './/*[@class="OtpDashboardMobileBundle-OtpDashboardStyle-countTitleWidget"]' ).get_attribute('textContent').strip(')').lstrip('(') print count acc_rule13(login) refresh = self.driver.find_element_by_xpath( '//*[@class="OtpCommonMobileBundle-OtpCommonStyle-headerButtonRefresh"]' ) tap(self, refresh) sleep(7) table2 = self.driver.find_elements_by_xpath( '//*[@class="OtpDashboardMobileBundle-OtpDashboardStyle-indicatorTitleWidgetContainer"]' ) for i in table2: if i.find_element_by_xpath( './/*[@class="OtpDashboardMobileBundle-OtpDashboardStyle-nameTitleWidget"]' ).get_attribute('textContent') == 'Accounts': count2 = i.find_element_by_xpath( './/*[@class="OtpDashboardMobileBundle-OtpDashboardStyle-countTitleWidget"]' ).get_attribute('textContent').strip(')').lstrip('(') self.assertNotEqual(count, count2)
def login_change(self, login, password, new_log, conf_log, type): self.driver.implicitly_wait(30) sleep(10) autologin(self, login, password) menu = self.driver.find_element_by_xpath('//*[@class="OtpCommonMobileBundle-OtpCommonStyle-headerButtonMenu"]') tap(self, menu) self.driver.switch_to.context('NATIVE_APP') try: arrow = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/bottomIndicator")') arrow.click() except: pass sett = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("Settings|SETTINGS")') sett.click() psw_ch = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("Change login|CHANGE THE LOGIN")') psw_ch.click() new_psw = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/new_login")') conf = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/new_login_confirm")') if type == 'busy': new_psw.send_keys(new_log) conf.send_keys(conf_log) self.driver.hide_keyboard() save_btn = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/dialogOk")') save_btn.click() err = self.driver.find_element_by_id('ua.com.cs.ifobs.mobile.android.otp:id/dialogText').get_attribute('text') self.assertTrue(err == "The user with such login has already registered in the system") elif type == 'same': new_psw.send_keys(new_log) conf.send_keys(conf_log) self.driver.hide_keyboard() save_btn = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/dialogOk")') save_btn.click() err = self.driver.find_element_by_id('ua.com.cs.ifobs.mobile.android.otp:id/dialogTitle').get_attribute('text') self.assertTrue(err == "Change the login") elif type == 'validation': new_psw.send_keys('Some new + . login') self.assertTrue(self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/new_login")').get_attribute('text')== 'Somenewlogin') new_psw.clear() new_psw.send_keys('to') conf.send_keys('to') self.driver.hide_keyboard() save_btn = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/dialogOk")') save_btn.click() err = self.driver.find_element_by_id('ua.com.cs.ifobs.mobile.android.otp:id/dialogTitle').get_attribute('text') self.assertTrue(err == "Change the login")
def change_password(self, login, password, new_pass, conf_pass, type): self.driver.implicitly_wait(30) sleep(10) autologin(self, login, password) menu = self.driver.find_element_by_xpath('//*[@class="OtpCommonMobileBundle-OtpCommonStyle-headerButtonMenu"]') tap(self, menu) self.driver.switch_to.context('NATIVE_APP') try: arrow = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/bottomIndicator")') arrow.click() except: pass sett = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("Settings|SETTINGS")') sett.click() psw_ch = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("Change password|CHANGE PASSWORD")') psw_ch.click() new_psw = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/new_password")') conf = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/repeat_password")') new_psw.send_keys(new_pass) conf.send_keys(conf_pass) self.driver.hide_keyboard() if type == 'positive': save_btn = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/savePasswordButton")') save_btn.click() err = self.driver.find_element_by_id('ua.com.cs.ifobs.mobile.android.otp:id/dialogText').get_attribute('text') self.assertTrue(err == 'The password has been changed') elif type == 'empty': save_btn = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/savePasswordButton")') save_btn.click() err = self.driver.find_element_by_android_uiautomator( 'className("android.widget.TextView").text("CHANGE PASSWORD")') self.assertTrue(err) elif type == 'latin': print self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/new_password")').get_attribute('text') elif type == 'space': err = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/new_password")').get_attribute('text') self.assertTrue(len(err) == 3) elif type == 'same': save_btn = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/savePasswordButton")') save_btn.click() err = self.driver.find_element_by_id('ua.com.cs.ifobs.mobile.android.otp:id/dialogText').get_attribute('text') self.assertTrue(err == "The values of the 'New password' and 'Current password' fields should differ.")
def invalid_psw(self, login, password): self.driver.implicitly_wait(30) sleep(10) password += '4' autologin(self, login, password) self.driver.switch_to.context('NATIVE_APP') err = self.driver.find_element_by_id( "ua.com.cs.ifobs.mobile.android.otp:id/dialogText").get_attribute( 'text') self.assertEqual( err, 'It is impossible to login. Check if the login and password are correct.' )
def rule_17and18(self, login, password): self.driver.implicitly_wait(30) sleep(10) autologin(self, login, password) menu = self.driver.find_element_by_xpath( '//*[@class="OtpCommonMobileBundle-OtpCommonStyle-headerButtonMenu"]') tap(self, menu) self.driver.switch_to.context('NATIVE_APP') try: self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("Transfers|TRANSFERS")' ) raise NameError('Payments present') except NoSuchElementException: return True
def rule_46(self, login, password): self.driver.implicitly_wait(30) sleep(10) autologin(self, login, password) menu = self.driver.find_element_by_xpath( '//*[@class="OtpDashboardMobileBundle-OtpDashboardStyle-indicatorTitleWidgetContainer"]' ) tap(self, menu) self.driver.switch_to.context('NATIVE_APP') try: self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("Cards|CARDS")' ) raise NameError('Cards present') except NoSuchElementException: return True
def accounts_mask(self, login, password): self.driver.implicitly_wait(30) sleep(10) autologin(self, login, password) self.assertTrue( self.driver.find_elements_by_xpath( '//*[@class="OtpDashboardMobileBundle-OtpDashboardStyle-logo"]')) menu = self.driver.find_element_by_xpath( '//*[@class="OtpCommonMobileBundle-OtpCommonStyle-headerButtonMenu"]') tap(self, menu) self.driver.switch_to.context('NATIVE_APP') transfer = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("Transfers|TRANSFERS")' ) transfer.click() new = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("New transfers|NEW TRANSFERS")' ) new.click() self.driver.switch_to.context('WEBVIEW') spisok = self.driver.find_elements_by_xpath( '//*[@class="OtpPaymentMobileBundle-OtpPaymentStyle-paymentMenuItemLabel"]' ) for i in spisok: if i.get_attribute('textContent') == 'Between own accounts': tap(self, i) self.driver.switch_to.context('NATIVE_APP') own = self.driver.find_element_by_android_uiautomator( 'resourceId("android:id/text1").text("New")') own.click() self.driver.switch_to.context('WEBVIEW') self.driver.hide_keyboard() spisok = self.driver.find_elements_by_xpath( '//*[@class="OtpCommonMobileBundle-OtpCommonStyle-groupItemSingleFieldValue"]' ) for i in spisok: w = i.get_attribute('textContent') print w if re.findall(r'2625\d+', w): if w == re.findall(r'2625\d+', w)[0]: raise NameError('we got 2625 acc')
def rule_18(self, login, password): self.driver.implicitly_wait(30) sleep(10) autologin(self, login, password) menu = self.driver.find_element_by_xpath( '//*[@class="OtpCommonMobileBundle-OtpCommonStyle-headerButtonMenu"]') tap(self, menu) self.driver.switch_to.context('NATIVE_APP') transfer = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("Transfers|TRANSFERS")' ) transfer.click() new = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("New transfers|NEW TRANSFERS")' ) new.click() self.driver.switch_to.context('WEBVIEW') spisok = self.driver.find_elements_by_xpath( '//*[@class="OtpPaymentMobileBundle-OtpPaymentStyle-paymentMenuItemLabel"]' ) for i in spisok: if i.get_attribute('textContent') == 'Between own accounts': tap(self, i) self.driver.switch_to.context('NATIVE_APP') own = self.driver.find_element_by_android_uiautomator( 'resourceId("android:id/text1").text("New")') own.click() self.driver.switch_to.context('WEBVIEW') self.driver.hide_keyboard() spisok = self.driver.find_elements_by_xpath( '//*[@class="OtpPaymentMobileBundle-OtpPaymentStyle-itemAmountContainer"]' ) for i in spisok: print i.find_element_by_xpath( './/*[@class="OtpCommonMobileBundle-OtpCommonStyle-amountWidgetCurrency"]' ).get_attribute('textContent') self.assertTrue( i.find_element_by_xpath( './/*[@class="OtpCommonMobileBundle-OtpCommonStyle-amountWidgetCurrency"]' ).get_attribute('textContent') == "UAH")
def new_mess(self, login, password): th = "".join([random.choice(string.letters) for i in xrange(5)]) self.driver.implicitly_wait(30) sleep(10) autologin(self, login, password) menu = self.driver.find_element_by_xpath('//*[@class="OtpCommonMobileBundle-OtpCommonStyle-headerButtonMenu"]') tap(self, menu) self.driver.switch_to.context('NATIVE_APP') transfer = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("Messages|MESSAGES")') transfer.click() new = self.driver.find_element_by_android_uiautomator( 'resourceId("ua.com.cs.ifobs.mobile.android.otp:id/menuItemName").textMatches("New message|NEW MESSAGE")') new.click() self.driver.switch_to.context('WEBVIEW') send = self.driver.find_element_by_xpath('//*[@class="OtpMessageMobileBundle-OtpMessageStyle-sendMessage"]') theme = self.driver.find_element_by_xpath('//*[@class="gwt-TextBox InputAppearance-InputCss-mgwt-InputBox-box"]') text = self.driver.find_element_by_xpath('//*[@class="gwt-TextArea InputAppearance-InputCss-mgwt-InputBox-box"]') tap(self, send) sleep(1) self.driver.switch_to.context('NATIVE_APP') err = self.driver.find_element_by_id('ua.com.cs.ifobs.mobile.android.otp:id/dialogText').get_attribute('text') self.assertTrue(err == 'The message subject/body is missing') self.driver.find_element_by_id('ua.com.cs.ifobs.mobile.android.otp:id/dialogOk').click() self.driver.switch_to.context('WEBVIEW') theme.send_keys(th) tap(self, send) sleep(1) self.driver.switch_to.context('NATIVE_APP') err = self.driver.find_element_by_id('ua.com.cs.ifobs.mobile.android.otp:id/dialogText').get_attribute('text') self.assertTrue(err == 'The message subject/body is missing') self.driver.find_element_by_id('ua.com.cs.ifobs.mobile.android.otp:id/dialogOk').click() self.driver.switch_to.context('WEBVIEW') text.send_keys(th) tap(self, send) self.driver.switch_to.context('NATIVE_APP') err = self.driver.find_element_by_id('ua.com.cs.ifobs.mobile.android.otp:id/dialogText').get_attribute('text') self.assertTrue(err == 'The message has been sent')
def cards_active(self, login, password): self.driver.implicitly_wait(30) sleep(10) cards_req() autologin(self, login, password) self.assertTrue( self.driver.find_elements_by_xpath( '//*[@class="OtpDashboardMobileBundle-OtpDashboardStyle-logo"]')) card_block = self.driver.find_element_by_xpath( '//*[@id="MAIN"]/div[2]/div/div[1]/div[1]/div[2]') spisok = card_block.find_elements_by_xpath( './/*[@class="OtpDashboardMobileBundle-OtpDashboardStyle-itemAdditionalLabelInfoWidget"]' ) cards_ui = [] for i in spisok: self.assertTrue( re.findall(r'\d{6}\*{6}\d{4}', i.get_attribute('textContent'))) cards_ui.append(i.get_attribute('textContent')) acc = [] unacc = [] path_enc = '%s/sql/xmls/enc_data.xml' % os.getcwd() tree = ET.parse(path_enc) root = tree.getroot() for i in root.iter('AccountDetails'): if i.find('Type').text == 'CARD': if i.find('Card').find('State').text == 'ACTIVE': acc.append(i.find('Card').find('CardNo').text) else: unacc.append(i.find('Card').find('CardNo').text) for i in cards_ui: if i in acc: pass else: raise NameError('UnActive in active')