def test_group_chat_send_receive_messages_and_remove_user(self): device_1, device_2 = ConsoleView(self.driver_1), \ ConsoleView(self.driver_2) for device in device_1, device_2: user_flow.create_user(device) device_1.back_button.click() device_2.back_button.click() device_1_chat = device_1.get_chat_view() device_2_chat = device_2.get_chat_view() device_1_public_key = user_flow.get_public_key(device_1_chat) user_flow.add_contact(device_2_chat, device_1_public_key) device_1_user_name = device_2_chat.user_name_text.text for _ in range(3): device_2.back_button.click() chat_name = 'new_chat' message_1 = 'first SOMETHING' message_2 = 'second SOMETHING' message_3 = 'third SOMETHING' user_flow.create_group_chat(device_2_chat, device_1_user_name, chat_name) # send_and_receive_messages device_2_chat.chat_message_input.send_keys(message_1) device_2_chat.send_message_button.click() device_1.back_button.click() device_1_chat = device_1.get_chat_view() device_1_chat.find_full_text(message_1) group_chat_d1 = device_1_chat.element_by_text(chat_name, 'button') group_chat_d1.click() device_2_chat.chat_message_input.send_keys(message_2) device_2_chat.send_message_button.click() device_1_chat.find_full_text(message_2) # remove user device_2_chat.group_chat_options.click() device_2_chat.chat_settings.click() for _ in range(2): try: device_2_chat.user_options.click() except (NoSuchElementException, TimeoutException): pass device_2_chat.remove_button.click() device_2_chat.confirm() device_2.back_button.click() # verify removed user receives no messages device_2_chat.chat_message_input.send_keys(message_3) device_2_chat.send_message_button.click() device_1_chat.find_text_part("removed you from group chat") message_text = device_1_chat.element_by_text(message_3, 'text') if message_text.is_element_present(20): pytest.fail( 'Message is shown for the user which has been removed from the GroupChat', False)
def test_change_profile_name_and_status(self): new_status = '#newstatus' new_username = '******' console_view = ConsoleView(self.driver) user_flow.create_user(console_view) chats_view = console_view.get_chat_view() chats_view.back_button.click() profile_drawer = chats_view.profile_button.click() profile_view = profile_drawer.profile_icon.click() profile_view.user_status_box.click() profile_view.user_status_input.clear() profile_view.user_status_input.send_keys(new_status) profile_view.username_input.clear() profile_view.username_input.send_keys(new_username) profile_view.save_button.click() profile_view.back_button.click() chats_view.profile_button.click() sign_in_view = profile_drawer.switch_users_button.click() user = sign_in_view.element_by_text(new_username, 'button') user.click() sign_in_view.password_input.send_keys('qwerty1234') sign_in_view.sign_in_button.click() chats_view.find_full_text('Chats', 60) chats_view.profile_button.click() for text in new_status + ' ', new_username: chats_view.find_full_text(text, 5)
def test_send_transaction_from_daap(self): console = ConsoleView(self.driver) user_flow.recover_access(console, transaction_users['B_USER']['passphrase'], transaction_users['B_USER']['password'], transaction_users['B_USER']['username']) chats_view = console.get_chat_view() address = transaction_users['B_USER']['address'] initial_balance = api_requests.get_balance(address) contacts_view = chats_view.contacts_button.click() auction_house = contacts_view.auction_house_button.click() auction_house.toggle_navigation_button.click() auction_house.new_auction_button.click() auction_house.name_to_reserve_input.click() auction_name = time.strftime('%Y-%m-%d-%H-%M') auction_house.send_as_keyevent(auction_name) auction_house.register_name_button.click() send_transaction_view = chats_view.get_send_transaction_view() send_transaction_view.sign_transaction_button.wait_for_element(20) send_transaction_view.sign_transaction_button.click() send_transaction_view.enter_password_input.send_keys( transaction_users['B_USER']['password']) send_transaction_view.sign_transaction_button.click() send_transaction_view.got_it_button.click() auction_house.find_full_text( 'You are the proud owner of the name: ' + auction_name, 120) api_requests.verify_balance_is_updated(initial_balance, address)
def test_one_to_one_chat(self): device_1, device_2 = ConsoleView(self.driver_1), ConsoleView( self.driver_2) for device in device_1, device_2: user_flow.create_user(device) device_1.back_button.click() device_2.back_button.click() device_1_chat = device_1.get_chat_view() device_2_chat = device_2.get_chat_view() device_1_public_key = user_flow.get_public_key(device_1_chat) user_flow.add_contact(device_2_chat, device_1_public_key) message_1 = 'SOMETHING' message_2 = 'another SOMETHING' user_d1_name = device_2_chat.user_name_text.text device_2_chat.chat_message_input.send_keys(message_1) device_2_chat.send_message_button.click() device_1_chat.back_button.click() device_1_chat.find_full_text(message_1) one_to_one_chat_d1 = device_1_chat.element_by_text(message_1, 'button') one_to_one_chat_d1.click() one_to_one_chat_d2 = device_2_chat.element_by_text( user_d1_name, 'button') one_to_one_chat_d2.click() device_2_chat.chat_message_input.send_keys(message_2) device_2_chat.send_message_button.click() device_1_chat.find_full_text(message_2)
def test_one_to_one_chat_between(self, network): device_1, device_2 = ConsoleView(self.driver_1), ConsoleView( self.driver_2) for device in device_1, device_2: user_flow.create_user(device) device_1.back_button.click() device_1_chats = device_1.get_chat_view() device_1_profile_drawer = device_1_chats.profile_button.click() device_1_profile_view = device_1_profile_drawer.profile_icon.click() device_1_public_key = device_1_profile_view.public_key_text.text if network[0] != 'Ropsten with upstream RPC': login_d1 = device_1_profile_view.switch_network(network[0]) login_d1.first_account_button.click() login_d1.password_input.send_keys('qwerty1234') login_d1.sign_in_button.click() login_d1.find_full_text('Chats', 60) else: device_1_profile_view.back_button.click() device_2.back_button.click() device_2_chats = device_2.get_chat_view() if network[1] != 'Ropsten with upstream RPC': device_2_profile_drawer = device_2_chats.profile_button.click() device_2_profile_view = device_2_profile_drawer.profile_icon.click( ) device_2_sign_in = device_2_profile_view.switch_network(network[1]) device_2_sign_in.first_account_button.click() device_2_sign_in.password_input.send_keys('qwerty1234') device_2_sign_in.sign_in_button.click() device_2_sign_in.find_full_text('Chats', 60) user_flow.add_contact(device_2_chats, device_1_public_key) message_1 = network[0] message_2 = network[1] user_d1_name = device_2_chats.user_name_text.text device_2_chats.chat_message_input.send_keys(message_2) device_2_chats.send_message_button.click() errors = list() try: device_1_chats.find_full_text(message_2) except TimeoutException: errors.append("Message '%s' wasn't received by Device #1") one_to_one_chat_d1 = device_1_chats.element_by_text( message_2, 'button') one_to_one_chat_d1.click() one_to_one_chat_d2 = device_2_chats.element_by_text( user_d1_name, 'button') one_to_one_chat_d2.click() device_1_chats.chat_message_input.send_keys(message_1) device_1_chats.send_message_button.click() try: device_2_chats.find_full_text(message_1) except TimeoutException: errors.append("Message '%s' wasn't received by Device #2") if errors: msg = '' for error in errors: msg += (error + '\n') pytest.fail(msg, pytrace=False)
def test_send_transaction_from_wallet(self, test, recipient, sender): console_view = ConsoleView(self.driver) user_flow.recover_access( console_view, transaction_users_wallet[sender]['passphrase'], transaction_users_wallet[sender]['password'], transaction_users_wallet[sender]['username']) chats_view = console_view.get_chat_view() recipient_key = transaction_users_wallet[recipient]['public_key'] recipient_address = transaction_users_wallet[recipient]['address'] initial_balance_recipient = api_requests.get_balance(recipient_address) user_flow.add_contact(chats_view, recipient_key) for _ in range(3): try: chats_view.back_button.click() except (TimeoutException, NoSuchElementException): pass wallet_view = chats_view.wallet_button.click() wallet_view.send_button.click() send_transaction = wallet_view.get_send_transaction_view() send_transaction.amount_edit_box.click() amount = send_transaction.get_unique_amount() send_transaction.send_as_keyevent(amount) send_transaction.confirm() send_transaction.chose_recipient_button.click() send_transaction.deny_button.click() send_transaction.chose_from_contacts_button.click() user_contact = send_transaction.element_by_text( transaction_users_wallet[recipient]['username'], 'button') user_contact.click() if test == 'sign_later': send_transaction.sign_later_button.click() send_transaction.yes_button.click() send_transaction.ok_button_apk.click() transactions_view = wallet_view.transactions_button.click() transactions_view.unsigned_tab.click() transactions_view.sign_button.click() send_transaction.sign_transaction_button.click() send_transaction.enter_password_input.send_keys( transaction_users_wallet[sender]['password']) send_transaction.sign_transaction_button.click() send_transaction.got_it_button.click() api_requests.verify_balance_is_updated(initial_balance_recipient, recipient_address) if test == 'sign_later': transactions_view.history_tab.click() else: chats_view.wallet_button.click() transactions_view = wallet_view.transactions_button.click() transaction = transactions_view.transactions_table.find_transaction( amount=amount) details_view = transaction.click() transaction_hash = details_view.get_transaction_hash() api_requests.find_transaction_on_ropsten( address=transaction_users_wallet[sender]['address'], transaction_hash=transaction_hash)
def test_transaction_send_command(self, test, recipient): console_view = ConsoleView(self.driver) user_flow.create_user(console_view) console_view.back_button.click() chats_view = console_view.get_chat_view() recipient_address = transaction_users[recipient]['address'] recipient_key = transaction_users[recipient]['public_key'] transaction_amount = '0.001' sender_address = user_flow.get_address(chats_view) chats_view.back_button.click() api_requests.get_donate(sender_address) initial_balance_recipient = api_requests.get_balance(recipient_address) # next 2 lines are bypassing issue #2417 wallet_view = chats_view.wallet_button.click() wallet_view.chats_button.click() user_flow.add_contact(chats_view, recipient_key) if test == 'group_chat': for _ in range(3): chats_view.back_button.click() user_flow.create_group_chat( chats_view, transaction_users[recipient]['username'], 'trg_%s' % get_current_time()) else: chats_view.element_by_text( transaction_users[recipient]['username'], 'button').click() chats_view.send_command.click() if test == 'group_chat': chats_view.first_recipient_button.click() chats_view.send_as_keyevent(transaction_amount) else: chats_view.send_as_keyevent(transaction_amount) chats_view.send_message_button.click() send_transaction_view = chats_view.get_send_transaction_view() send_transaction_view.sign_transaction_button.wait_for_element(5) send_transaction_view.sign_transaction_button.click() if test == 'wrong_password': send_transaction_view.enter_password_input.send_keys('invalid') send_transaction_view.sign_transaction_button.click() send_transaction_view.find_full_text('Wrong password', 20) else: send_transaction_view.enter_password_input.send_keys('qwerty1234') send_transaction_view.sign_transaction_button.click() send_transaction_view.got_it_button.click() send_transaction_view.find_full_text(transaction_amount) try: chats_view.find_full_text('Sent', 10) except TimeoutException: chats_view.find_full_text('Delivered', 10) if test == 'group_chat': chats_view.find_full_text( 'to ' + transaction_users[recipient]['username'], 60) api_requests.verify_balance_is_updated(initial_balance_recipient, recipient_address)
def test_wallet_error_messages(self): console = ConsoleView(self.driver) user_flow.create_user(console) chats = console.get_chat_view() chats.back_button.click() wallet_view = chats.wallet_button.click() wallet_view.send_button.click() send_transaction = wallet_view.get_send_transaction_view() send_transaction.amount_edit_box.send_keys('asd') send_transaction.find_full_text('Amount is not a valid number') send_transaction.amount_edit_box.send_keys('0,1') send_transaction.find_full_text('Insufficient funds')
def test_network_switch(self, network): console = ConsoleView(self.driver) user_flow.create_user(console) console.back_button.click() chats = console.get_chat_view() profile_drawer = chats.profile_button.click() profile_view = profile_drawer.profile_icon.click() sign_in_view = profile_view.switch_network(network) sign_in_view.first_account_button.click() sign_in_view.password_input.send_keys('qwerty1234') sign_in_view.sign_in_button.click() sign_in_view.find_full_text('Chats', 20)
def test_recover_access(self): console_view = ConsoleView(self.driver) user_flow.create_user(console_view) chats_view = console_view.get_chat_view() chats_view.back_button.click() profile_drawer = chats_view.profile_button.click() sign_in_view = profile_drawer.switch_users_button.click() recover_access_view = sign_in_view.recover_access_button.click() recover_access_view.passphrase_input.send_keys(basic_user['passphrase']) recover_access_view.password_input.send_keys(basic_user['password']) recover_access_view.confirm_recover_access.click() recovered_user = sign_in_view.element_by_text(basic_user['username'], 'button') recovered_user.click() sign_in_view.password_input.send_keys(basic_user['password']) sign_in_view.sign_in_button.click() console_view.find_full_text('Chats', 60) if basic_user['password'] in str(console_view.logcat): pytest.fail('Password in logcat!!!', pytrace=False)
def test_sign_in(self, verification): verifications = {"valid": {"input": "qwerty1234", "outcome": "Chats"}, "invalid": {"input": "12345ewq", "outcome": "Wrong password"}} console_view = ConsoleView(self.driver) user_flow.create_user(console_view) chats_view = console_view.get_chat_view() chats_view.back_button.click() profile_drawer = chats_view.profile_button.click() sign_in_view = profile_drawer.switch_users_button.click() sign_in_view.first_account_button.click() sign_in_view.password_input.send_keys(verifications[verification]['input']) sign_in_view.sign_in_button.click() console_view.find_full_text(verifications[verification]["outcome"], 60) if verifications[verification]["input"] in str(console_view.logcat): pytest.fail('Password in logcat!!!', pytrace=False)
def test_eth_and_currency_balance(self): errors = list() console = ConsoleView(self.driver) user_flow.recover_access( console, passphrase=transaction_users_wallet['A_USER']['passphrase'], password=transaction_users_wallet['A_USER']['password'], username=transaction_users_wallet['A_USER']['username']) chats_view = console.get_chat_view() wallet = chats_view.wallet_button.click() address = transaction_users_wallet['A_USER']['address'] balance = api_requests.get_balance(address) / 1000000000000000000 eth_rate = api_requests.get_ethereum_price_in_usd() wallet_balance = wallet.get_eth_value() if wallet_balance != balance: errors.append('Balance %s is not equal to the expected %s' % (wallet_balance, balance)) wallet.verify_currency_balance(eth_rate, errors) assert not errors, 'errors occurred:\n{}'.format('\n'.join(errors))
def test_new_profile_name_and_status_on_discover(self): device_1, device_2 = ConsoleView(self.driver_1), ConsoleView( self.driver_2) for device in device_1, device_2: user_flow.create_user(device) device_1.back_button.click() device_2.back_button.click() device_1_chat, device_2_chat = device_1.get_chat_view( ), device_2.get_chat_view() device_2_public_key = user_flow.get_public_key(device_2_chat) user_flow.add_contact(device_1_chat, device_2_public_key) device_1_chat.chat_message_input.send_keys('test123') device_1_chat.send_message_button.click() device_1_chat.back_button.click() device_2_chat.back_button.click() new_chat_d2 = device_2_chat.element_by_text('test123', 'button') new_chat_d2.click() device_2_chat.add_to_contacts.click() for _ in range(2): device_1_chat.back_button.click() device_2_chat.back_button.click() device_1_profile_drawer = device_1_chat.profile_button.click() device_2_profile_drawer = device_2_chat.profile_button.click() device_1_profile, device_2_profile = \ device_1_profile_drawer.profile_icon.click(), device_2_profile_drawer.profile_icon.click() users_details = user_flow.get_new_username_and_status( device_1_profile, device_2_profile) device_1_profile.back_button.click() device_2_profile.back_button.click() device_1_discover = device_1_profile.discover_button.click() device_2_discover = device_2_profile.discover_button.click() for device in device_1_discover, device_2_discover: device.all_popular.click() for k in users_details: device.find_full_text(users_details[k]['name']) device.find_full_text(' ' + users_details[k]['status']) device.back_button.click() device.all_recent.click() for k in users_details: device.find_full_text(users_details[k]['name']) device.find_full_text(users_details[k]['status'] + ' ')
def test_request_transaction_from_wallet(self): console_view = ConsoleView(self.driver) user_flow.recover_access( console_view, transaction_users_wallet['A_USER']['passphrase'], transaction_users_wallet['A_USER']['password'], transaction_users_wallet['A_USER']['username']) chats_view = console_view.get_chat_view() recipient_key = transaction_users_wallet['B_USER']['public_key'] user_flow.add_contact(chats_view, recipient_key) for _ in range(3): try: chats_view.back_button.click() except (TimeoutException, NoSuchElementException): pass wallet_view = chats_view.wallet_button.click() wallet_view.request_button.click() send_transaction_view = wallet_view.get_send_transaction_view() send_transaction_view.amount_edit_box.scroll_to_element() send_transaction_view.amount_edit_box.send_keys('0.1') wallet_view.send_request_button.click() user_contact = chats_view.element_by_text( transaction_users_wallet['B_USER']['username'], 'button') user_contact.click() chats_view.find_text_part('Requesting 0.1 ETH')
def test_send_funds_via_request(self, test, recipient, sender): device_1, device_2 = ConsoleView(self.driver_1), ConsoleView( self.driver_2) user_flow.recover_access(device_1, passphrase=recipient['passphrase'], password=recipient['password'], username=recipient['username']) user_flow.recover_access(device_2, passphrase=sender['passphrase'], password=sender['password'], username=sender['username']) device_2_chat = device_2.get_chat_view() device_1_chat = device_1.get_chat_view() if test == 'group_chat': user_flow.add_contact(device_1_chat, sender['public_key']) for _ in range(2): device_1_chat.back_button.click() group_chat_name = 'gtr_%s' % get_current_time() user_flow.create_group_chat(device_1_chat, sender['username'], group_chat_name) group_chat_d2 = device_2_chat.element_by_text( group_chat_name, 'button') group_chat_d2.click() else: device_1_chat.element_by_text_part(sender['username'][:25], 'button').click() device_1_chat.request_command.click() amount = device_1_chat.get_unique_amount() if test == 'group_chat': device_1_chat.first_recipient_button.click() device_1_chat.send_as_keyevent(amount) else: device_1_chat.chat_message_input.set_value(amount) device_1_chat.send_message_button.click() initial_balance_recipient = api_requests.get_balance( recipient['address']) if test == 'group_chat': device_1_chat.find_full_text('from ' + sender['username'], 20) device_2_chat.find_full_text('from ' + sender['username'], 20) device_2_chat.element_by_text_part(recipient['username'][:25], 'button').click() device_2_chat.element_by_text_part('Requesting %s ETH' % amount, 'button').click() device_2_chat.send_message_button.click() device_2_send_transaction = device_2_chat.get_send_transaction_view() device_2_send_transaction.sign_transaction_button.click() device_2_send_transaction.enter_password_input.send_keys( sender['password']) device_2_send_transaction.sign_transaction_button.click() device_2_send_transaction.got_it_button.click() api_requests.verify_balance_is_updated(initial_balance_recipient, recipient['address']) device_2_chat.back_button.click() device_2_wallet = device_2_chat.wallet_button.click() transactions_view = device_2_wallet.transactions_button.click() transaction_element = transactions_view.transactions_table.find_transaction( amount=amount) transaction_details_view = transaction_element.click() transaction_hash = transaction_details_view.get_transaction_hash() api_requests.find_transaction_on_ropsten( address=sender['address'], transaction_hash=transaction_hash)