def set_address(self, address, dest_page='dest'):
        self.address1.clear()
        self.address1.send_keys(address[0])
        self.address2.clear()
        self.address2.send_keys(address[1])
        self.city.clear()
        self.city.send_keys(address[2])
        if main.is_android(
        ):  # hide keyboard (probably covering state element)
            self.try_hide_keyboard()
        self.select_state(address[3])

        self.postal.clear()
        self.postal.send_keys(address[4])
        self.click_continue()
        # Redirect page could be destination picker (normal) or...
        # send page (US recipient sending to MX bank account or cashout)
        if dest_page == 'send':
            WDW(self.driver, 10).until(
                EC.presence_of_element_located((By.ID, 'sourceAmountInput')))
        elif dest_page == 'recipient_view':
            WDW(self.driver, 10).until(
                EC.presence_of_element_located(
                    (By.CLASS_NAME, 'recipient_remove')))
        else:  # destination page (default)
            WDW(self.driver, 10).until(
                EC.presence_of_element_located((By.ID, 'radio_cashout')))
Example #2
0
    def select_location(self, location, option=0):
        self.type_location(location)
        if main.is_android():
            self.try_hide_keyboard()

        unsetOption = True
        count = 0
        while count < 5:
            try:
                if self.options is not None:
                    self.options[option].click()
                    try:
                        WDW(self.driver, 5).until(
                            EC.element_to_be_clickable(
                                (By.CLASS_NAME, 'sm-continue-button')))
                        self.click_continue()
                        return True
                    except TimeoutException:
                        # no continue button (i.e. adding non-us business)
                        pass
                return False
            except StaleElementReferenceException:
                # Page might have reloaded
                print('Failed to click location option.')
            count += 1

        return False
	def click_details(self):
		if main.is_android(): # may need to close keyboard
			self.try_hide_keyboard()
		self.scroll_to_top()
		self.details_button.click()
		self.load_details()
		time.sleep(1)
Example #4
0
 def set_account_type(self, acct_type):
     if main.is_android():
         self.try_hide_keyboard()
     if acct_type.lower() == 'checking':
         self.move_to_el(self.checking)
     if acct_type.lower() == 'savings':
         self.move_to_el(self.savings)
     time.sleep(.2)
Example #5
0
 def try_hide_keyboard(self):
     """If open, close android keyboard"""
     if main.is_android():
         try:
             self.driver.hide_keyboard()
             time.sleep(.6)
         except WebDriverException:
             pass
Example #6
0
 def dismiss_keyboard(self):
     """If open, close android keyboard"""
     if main.is_android():
         try:
             self.driver.hide_keyboard()
             time.sleep(2)  # Wait for keyboard to dismiss
         except WebDriverException:
             pass
Example #7
0
	def close(self, action='click'):
		if self.is_drawer_visible():
			if not main.is_desktop():
				# ios: Base coordinates off window.innerWidth/innerHeight
				# y position needs to be lower than browser header
				web_width = self.driver.execute_script('return window.innerWidth')
				click_x = web_width - 10
				click_y = 100
				duration = 100 # milliseconds

				# Android: TA only works in NATIVE view
				if main.is_android():
					# go to native context
					main.native_context(self.driver)

					# use native dimensions (different from webview dimensions)
					native_dimensions = self.driver.get_window_size()
					native_width = native_dimensions['width']

					click_x = native_width - 10
					# needs bigger value than WEBVIEW (to avoid clicking URL)
					click_y = 300

				if action == 'click': # Either option should work
					# position = [(click_x, click_y)]
					# self.driver.tap(position, duration)
					TA(self.driver).tap(x=click_x, y=click_y).perform()
					# 2nd click opens /account-detail on iOS native
					# TA(self.driver).tap(x=click_x, y=click_y).perform()
				elif action == 'swipe':
					# Either option should work
					# second set of coordinates are RELATIVE to click position

					# self.driver.swipe(click_x, click_y, -300, 0, duration)
					TA(self.driver).press(x=click_x, y=click_y).wait(
						duration).move_to(x=-200, y=0).release().perform()

				# back to webview context
				if main.is_android():
					main.webview_context(self.driver)

				# wait until drawer disappears
				WDW(self.driver, 10).until(lambda x: not self.is_profile_loaded())
			else: # Press escape
				self.toggle_button.click()
 def click_continue(self):
     if main.is_android():
         self.try_hide_keyboard()
     self.continue_button.click()
 def set_last_name(self, name):
     if main.is_android():
         self.try_hide_keyboard()
     self.last_name.click()
     self.last_name.clear()
     self.last_name.send_keys(name)
Example #10
0
    def test_single_election(self):
        """ test_profile.py:TestElection.test_single_election """
        # process all pending elections for Multiverse
        # Lili needs to be employee of 'Multiverse' w/ emp ID 13313113
        business = 'Multiverse'
        lobby_page = self.nicol.lobby_page
        pe_page = self.nicol.pending_elections_page
        self.assertTrue(self.nicol.login(self.driver), messages.login)
        self.assertTrue(lobby_page.on())
        # Can't close menu on Android. Checking for business leaves menu open
        if not main.is_android():
            if lobby_page.menu.get_current_business() != business:
                lobby_page.menu.select_business(business)
                self.assertTrue(lobby_page.on())
        lobby_page.click_link('card', 1)
        self.assertTrue(pe_page.on())
        if pe_page.num_pending_elections() > 0:
            pe_page.mark_all_as_processed()
        pe_page.menu.sign_out()

        # lili: request new Multiverse election
        eHome = self.lili.eHome_page
        election_page = self.lili.pay_election_page
        history_page = self.lili.election_history_page
        self.assertTrue(self.lili.login(self.driver), messages.login)

        self.assertTrue(eHome.on())
        eHome.setTab('election')
        elections = eHome.get_elections()
        initial_election = elections[business]
        print(initial_election)
        # Lili should have single election field (no total)
        self.assertEqual(None, elections['total'])

        increase = self.lili.generate_amount()
        new_election = str(Decimal(initial_election) + Decimal(increase))
        print(new_election)

        eHome.set_election(business, new_election)
        new_elections = eHome.get_elections()
        self.assertEqual(new_election, new_elections[business])
        self.assertEqual(None, new_elections['total'])
        eHome.click_save_elections()
        self.assertTrue(eHome.on('election'))
        self.assertTrue(eHome.has_election_prompt())
        self.assertFalse(eHome.has_save_election_button())
        # eHome.clear_election_prompt()
        # self.assertFalse(eHome.has_election_prompt())
        # self.assertTrue(eHome.has_save_election_button())

        # assert change is reflected in lili's election history
        eHome.view_election_history()
        self.assertTrue(history_page.on())
        election = history_page.get_election()
        self.assertTrue(election['name'] == business)
        self.assertTrue(election['amount'] == new_election)
        history_page.header.click_back()

        # election should be pending
        self.assertTrue(eHome.on('election'))
        pending_elections = eHome.get_elections()
        self.assertTrue(pending_elections[business + " pending"])
        eHome.menu.sign_out()

        # assert change is NOT reflected in Multiverse employee table
        emp_page = self.nicol.employee_page
        view_page = self.nicol.employee_view_page
        self.assertTrue(self.nicol.login(self.driver), messages.login)
        self.assertTrue(lobby_page.on())
        lobby_page.menu.click_option('employees')

        self.assertTrue(emp_page.on())
        lili = emp_page.get_employee('id', '13313113')
        # should still be initial election
        # can fail if multiple elections have been requested w/out being processed.
        self.assertEqual(lili['election'], initial_election + " USD")
        self.assertNotEqual(lili['election'], new_election + " USD")

        self.assertTrue(emp_page.click_employee('id', '13313113'))
        self.assertTrue(view_page.on())
        self.assertEqual(view_page.election.text, initial_election + " USD")
        self.assertNotEqual(view_page.election.text, new_election + " USD")
        view_page.header.click_back()
        self.assertTrue(emp_page.on())

        # process pending election and recheck employee table
        emp_page.menu.click_option('pending elections')
        self.assertTrue(pe_page.on())
        pe_page.mark_all_as_processed()
        pe_page.menu.click_option('employees')
        self.assertTrue(emp_page.on())

        lili = emp_page.get_employee('id', '13313113')

        # Doesn't always refresh quickly.
        # Force refresh if they're not equal right away
        if new_election + ' USD' == lili['election']:
            self.assertEqual('Active', lili['status'])
            self.assertEqual(new_election + ' USD', lili['election'])
        else:
            # Refresh and check again
            self.driver.refresh()
            self.assertTrue(emp_page.on())
            lili = emp_page.get_employee('id', '13313113')
            self.assertEqual('Active', lili['status'])
            self.assertEqual(new_election + ' USD', lili['election'])
        emp_page.menu.sign_out()

        # lili's election should not be pending
        self.assertTrue(self.lili.login(self.driver), messages.login)
        # not sure why this is different on native. I'm assuming app remembers which tab you were on
        if not main.is_web():
            self.assertTrue(eHome.on('election'))
        else:
            self.assertTrue(eHome.on())
            eHome.setTab('election')
        elections = eHome.get_elections()
        self.assertFalse(elections[business + ' pending'])
	def set_password(self,pw):
		if main.is_android():
			self.try_hide_keyboard()
		self.password_input.click()
		self.password_input.send_keys(pw)
Example #12
0
 def click_confirm_remove(self):
     if main.is_android():
         self.try_hide_keyboard()
         time.sleep(.4)
     self.move_to_el(self.confirm_remove_button)
     time.sleep(2)