From f7bb0d36481578aeec6bc06583305066b0d91eef Mon Sep 17 00:00:00 2001 From: yevh-berdnyk Date: Wed, 24 Jul 2019 02:10:55 +0300 Subject: [PATCH] Fixed false failed tests Signed-off-by: Serhy --- .../atomic/account_management/test_profile.py | 14 +++++++------- test/appium/tests/atomic/chats/test_commands.py | 2 +- test/appium/views/base_element.py | 3 +++ test/appium/views/home_view.py | 2 +- test/appium/views/send_transaction_view.py | 2 +- test/appium/views/sign_in_view.py | 11 +++++++++++ 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/test/appium/tests/atomic/account_management/test_profile.py b/test/appium/tests/atomic/account_management/test_profile.py index 59f8c5a45e..4778569693 100644 --- a/test/appium/tests/atomic/account_management/test_profile.py +++ b/test/appium/tests/atomic/account_management/test_profile.py @@ -2,8 +2,8 @@ import pytest from tests import marks, bootnode_address, mailserver_address, camera_access_error_text, \ photos_access_error_text -from tests.users import transaction_senders, basic_user from tests.base_test_case import SingleDeviceTestCase, MultipleDeviceTestCase +from tests.users import transaction_senders, basic_user from views.sign_in_view import SignInView @@ -92,8 +92,9 @@ class TestProfileSingleDevice(SingleDeviceTestCase): wallet.accounts_status_account.click() wallet.receive_transaction_button.click_until_presence_of_element(wallet.send_transaction_request) address = wallet.address_text.text - wallet.address_text.long_press_element() - wallet.copy_text() + share_view = home.get_send_transaction_view() + share_view.share_button.click() + share_view.element_by_text('Copy to clipboard').click() wallet.get_back_to_home_view() wallet.home_button.click() home.get_chat_with_user(transaction_senders['M']['username']).click() @@ -268,11 +269,10 @@ class TestProfileSingleDevice(SingleDeviceTestCase): self.errors.append('{} Sign in view!'.format(no_link_open_error_msg)) base_web_view.click_system_back_button() - signin_view = SignInView(self.driver) home_view = signin_view.create_user() profile = home_view.profile_button.click() about_view = profile.about_button.click() - base_web_view = about_view.privacy_policy_button.click() + about_view.privacy_policy_button.click() if not base_web_view.policy_summary.is_element_displayed(): self.errors.append('{} Profile about view!'.format(no_link_open_error_msg)) @@ -280,7 +280,7 @@ class TestProfileSingleDevice(SingleDeviceTestCase): base_web_view.click_system_back_button() if about_view.privacy_policy_button.is_element_displayed(): base_web_view.click_system_back_button() - signin_view = profile.logout() + profile.logout() if signin_view.ok_button.is_element_displayed(): signin_view.ok_button.click() signin_view.other_multiaccounts_button.click() @@ -288,7 +288,7 @@ class TestProfileSingleDevice(SingleDeviceTestCase): if not signin_view.privacy_policy_link.is_element_displayed(): self.driver.fail('{} Sign in view!'.format(no_link_found_error_msg)) - base_web_view = signin_view.privacy_policy_link.click() + signin_view.privacy_policy_link.click() if not base_web_view.policy_summary.is_element_displayed(): self.errors.append('{} Sign in view!'.format(no_link_open_error_msg)) diff --git a/test/appium/tests/atomic/chats/test_commands.py b/test/appium/tests/atomic/chats/test_commands.py index bc364bac82..d26dd9fadd 100644 --- a/test/appium/tests/atomic/chats/test_commands.py +++ b/test/appium/tests/atomic/chats/test_commands.py @@ -466,7 +466,7 @@ class TestCommandsSingleDevices(SingleDeviceTestCase): self.errors.append( "'Insufficient funds' error is now shown when sending %s ETHro from chat with balance %s" % ( round(eth_value + 1), eth_value)) - send_transaction.cancel_button.click() + send_transaction.cancel_button.click_until_presence_of_element(chat_view.commands_button) chat_view.commands_button.click() chat_view.send_command.click() chat_view.asset_by_name('STT').scroll_to_element() diff --git a/test/appium/views/base_element.py b/test/appium/views/base_element.py index 9f2e1c57ac..16eaa13c2c 100644 --- a/test/appium/views/base_element.py +++ b/test/appium/views/base_element.py @@ -120,6 +120,9 @@ class BaseElement(object): self.driver.swipe(500, 1000, 500, 500) else: self.driver.swipe(500, 500, 500, 1000) + else: + raise NoSuchElementException( + "Device %s: '%s' is not found on the screen" % (self.driver.number, self.name)) from None def is_element_present(self, sec=5): try: diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index d1ec2caac3..3befdfeffd 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -195,7 +195,7 @@ class HomeView(BaseView): return ChatView(self.driver) def join_public_chat(self, chat_name: str): - self.plus_button.click_until_presence_of_element(self.join_public_chat_button) + self.plus_button.click_until_presence_of_element(self.join_public_chat_button, attempts=5) self.join_public_chat_button.wait_for_visibility_of_element(5) contacts_view = self.join_public_chat_button.click() contacts_view.chat_name_editbox.click() diff --git a/test/appium/views/send_transaction_view.py b/test/appium/views/send_transaction_view.py index db8a10810b..071997a31d 100644 --- a/test/appium/views/send_transaction_view.py +++ b/test/appium/views/send_transaction_view.py @@ -231,7 +231,7 @@ class SendTransactionView(BaseView): wallet_view.ok_got_it_button.click() def sign_transaction(self, sender_password: str = common_password): - self.sign_with_password.click() + self.sign_with_password.click_until_presence_of_element(self.enter_password_input) self.enter_password_input.send_keys(sender_password) self.sign_button.click_until_presence_of_element(self.ok_button) self.ok_button.click() diff --git a/test/appium/views/sign_in_view.py b/test/appium/views/sign_in_view.py index a3409ce0ea..a29c24e297 100644 --- a/test/appium/views/sign_in_view.py +++ b/test/appium/views/sign_in_view.py @@ -1,3 +1,4 @@ +from appium.webdriver.common.touch_action import TouchAction from selenium.common.exceptions import NoSuchElementException from tests import common_password @@ -134,6 +135,16 @@ class PrivacyPolicyLink(BaseButton): super(PrivacyPolicyLink, self).__init__(driver) self.locator = self.Locator.text_part_selector('privacy policy') + def click(self): + element = self.find_element() + location = element.location + size = element.size + x = int(location['x'] + size['width'] * 0.8) + y = int(location['y'] + size['height'] / 2) + TouchAction(self.driver).tap(None, x, y).perform() + self.driver.info('Tap on %s' % self.name) + return self.navigate() + def navigate(self): from views.web_views.base_web_view import BaseWebView return BaseWebView(self.driver)