diff --git a/ci/Jenkinsfile.e2e-nightly b/ci/Jenkinsfile.e2e-nightly index c1050747fa..6f7a8740c4 100644 --- a/ci/Jenkinsfile.e2e-nightly +++ b/ci/Jenkinsfile.e2e-nightly @@ -5,8 +5,8 @@ pipeline { agent { label 'linux' } triggers { - // Nightly at 2am - cron 'H 2 * * *' + // Nightly at 0am + cron 'H 0 * * *' } parameters { diff --git a/test/appium/tests/__init__.py b/test/appium/tests/__init__.py index 7411c46c0d..3be6f50692 100644 --- a/test/appium/tests/__init__.py +++ b/test/appium/tests/__init__.py @@ -28,6 +28,14 @@ async def start_threads(test_name: str, quantity: int, func: type, returns: dict except MaxRetryError: print("MaxRetryError when creating a driver for %s" % test_name) time.sleep(10) + # for k in returns: + # for _ in range(30): + # try: + # k.session_id + # break + # except AttributeError: + # print("AttributeError when creating a driver for %s" % test_name) + # time.sleep(3) return returns diff --git a/test/appium/tests/activity_center/test_activity_center.py b/test/appium/tests/activity_center/test_activity_center.py index 30f53082d9..68a0973631 100644 --- a/test/appium/tests/activity_center/test_activity_center.py +++ b/test/appium/tests/activity_center/test_activity_center.py @@ -85,8 +85,9 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC self.home_2.navigate_back_to_home_view() self.home_2.open_activity_center_button.click() self.home_2.activity_unread_filter_button.click() - if not self.home_2.element_by_text_part( - self.home_2.get_translation_by_key("contact-request-outgoing")).is_element_displayed(30): + element = self.home_2.get_activity_center_element_by_text('connect') + if element.title.text != 'Contact request' or element.context_tag_text != self.username_1 \ + or not element.pending_status_tag.is_element_displayed(): self.errors.append( "Pending contact request is not shown on unread notification element on Activity center!") self.home_2.close_activity_centre.click() diff --git a/test/appium/tests/base_test_case.py b/test/appium/tests/base_test_case.py index bd650cbf70..5d55126251 100644 --- a/test/appium/tests/base_test_case.py +++ b/test/appium/tests/base_test_case.py @@ -19,7 +19,7 @@ from urllib3.exceptions import MaxRetryError, ProtocolError from support.api.network_api import NetworkApi from tests import test_suite_data, start_threads, appium_container, pytest_config_global, transl -from tests.conftest import sauce_username, sauce_access_key, apibase, github_report +from tests.conftest import sauce_username, sauce_access_key, apibase, github_report, run_name executor_sauce_lab = 'https://%s:%s@ondemand.%s:443/wd/hub' % (sauce_username, sauce_access_key, apibase) @@ -84,7 +84,7 @@ def get_capabilities_sauce_lab(): caps['sauce:options']['appiumVersion'] = '2.0.0' caps['sauce:options']['username'] = sauce_username caps['sauce:options']['accessKey'] = sauce_access_key - caps['sauce:options']['build'] = pytest_config_global['build'] + caps['sauce:options']['build'] = run_name caps['sauce:options']['name'] = test_suite_data.current_test.name caps['sauce:options']['maxDuration'] = 3600 caps['sauce:options']['idleTimeout'] = 1000 @@ -124,8 +124,7 @@ class AbstractTestCase: def print_sauce_lab_info(self, driver): sys.stdout = sys.stderr - print("SauceOnDemandSessionID=%s job-name=%s" % (driver.session_id, - pytest_config_global['build'])) + print("SauceOnDemandSessionID=%s job-name=%s" % (driver.session_id, run_name)) def get_translation_by_key(self, key): return transl[key] @@ -312,14 +311,20 @@ def create_shared_drivers(quantity): drivers, command_executor=executor_sauce_lab, options=get_capabilities_sauce_lab())) + if len(drivers) < quantity: + test_suite_data.current_test.testruns[-1].error = "Not all %s drivers are created" % quantity + for i in range(quantity): test_suite_data.current_test.testruns[-1].jobs[drivers[i].session_id] = i + 1 drivers[i].implicitly_wait(implicit_wait) - if len(drivers) < quantity: - test_suite_data.current_test.testruns[-1].error = "Not all %s drivers are created" % quantity return drivers, loop except (MaxRetryError, AttributeError) as e: test_suite_data.current_test.testruns[-1].error = str(e) + for _, driver in drivers.items(): + try: + driver.quit() + except (WebDriverException, AttributeError): + pass raise e diff --git a/test/appium/tests/conftest.py b/test/appium/tests/conftest.py index a7ccca1788..69d937718b 100644 --- a/test/appium/tests/conftest.py +++ b/test/appium/tests/conftest.py @@ -148,6 +148,7 @@ testrail_report = None github_report = None apibase = None sauce = None +run_name = None def is_master(config): @@ -218,6 +219,21 @@ def _download_apk(url): return apk_path +def get_run_name(config, new_one=False): + pr_number = config.getoption('pr_number') + if config.getoption('testrail_report'): + if pr_number: + if new_one: + run_number = len(testrail_report.get_runs(pr_number)) + 1 + else: + run_number = len(testrail_report.get_runs(pr_number)) + return 'PR-%s run #%s (%s)' % (pr_number, run_number, test_suite_data.apk_name.split('-')[4]) + else: + return test_suite_data.apk_name + else: + return config.getoption('build') + + def pytest_configure(config): global option option = config.option @@ -248,18 +264,17 @@ def pytest_configure(config): test_suite_data.apk_name = ([i for i in [i for i in config.getoption('apk').split('/') if '.apk' in i]])[0] + global run_name + if is_master(config): + run_name = get_run_name(config, new_one=True) + testrail_report.add_run(run_name) + else: + run_name = get_run_name(config, new_one=False) + if not is_master(config): return pr_number = config.getoption('pr_number') - if config.getoption('testrail_report'): - if pr_number: - run_number = len(testrail_report.get_runs(pr_number)) + 1 - run_name = 'PR-%s run #%s' % (pr_number, run_number) - else: - run_name = test_suite_data.apk_name - testrail_report.add_run(run_name) - if pr_number: from github import Github repo = Github(github_token).get_user('status-im').get_repo('status-mobile') diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index c7c57b6939..f36c777bb8 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -1229,13 +1229,8 @@ class ChatView(BaseView): self.show_images_button.click() self.allow_button.click_if_shown() self.allow_all_button.click_if_shown() - confirm_button = self.images_confirm_selection_button - for i in indexes: - # ToDo: should be changed to just 1 click when https://github.com/status-im/status-mobile/issues/18872 when is fixed - self.get_image_by_index(i).click() - if not confirm_button.is_element_displayed(sec=3): - self.get_image_by_index(i).click() - confirm_button.click() + [self.get_image_by_index(i).click() for i in indexes] + self.images_confirm_selection_button.click() self.chat_message_input.send_keys(description) self.send_message_button.click() diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index b039931d4d..6cde0f88e7 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -130,7 +130,7 @@ class ActivityCenterElement(SilentButton): @property def title(self): - return Button(self.driver, xpath=self.locator + '//*[@content-desc="activity-title"]') + return Text(self.driver, xpath=self.locator + '//*[@content-desc="activity-title"]') @property def unread_indicator(self): @@ -140,6 +140,14 @@ class ActivityCenterElement(SilentButton): def message_body(self): return Button(self.driver, xpath=self.locator + '//*[@content-desc="activity-message-body"]') + @property + def context_tag_text(self): + return Text(self.driver, xpath=self.locator + '//*[@content-desc="context-tag"]/android.widget.TextView').text + + @property + def pending_status_tag(self): + return Text(self.driver, xpath=self.locator + '//*[@content-desc="status-tag-pending"]') + def handle_cr(self, element_accessibility: str): Button( self.driver, @@ -338,6 +346,9 @@ class HomeView(BaseView): except TimeoutException: break + def get_activity_center_element_by_text(self, text_part): + return ActivityCenterElement(self.driver, text_part) + def get_chat(self, username, community=False, community_channel=False, wait_time=10): if community: self.driver.info("Looking for community: '%s'" % username) @@ -346,7 +357,7 @@ class HomeView(BaseView): chat_element = ChatElement(self.driver, username[:25], community=community, community_channel=community_channel) if not chat_element.is_element_displayed(wait_time) and community is False and community_channel is False: if self.notifications_unread_badge.is_element_displayed(30): - chat_in_ac = ActivityCenterElement(self.driver, username[:25]) + chat_in_ac = self.get_activity_center_element_by_text(username[:25]) self.open_activity_center_button.click_until_presence_of_element(chat_in_ac) chat_in_ac.wait_for_element(20) chat_in_ac.click() @@ -364,7 +375,7 @@ class HomeView(BaseView): def get_element_from_activity_center_view(self, message_body): self.driver.info("Looking for activity center element: '%s'" % message_body) - chat_element = ActivityCenterElement(self.driver, message_body) + chat_element = self.get_activity_center_element_by_text(message_body) return chat_element def handle_contact_request(self, username: str, action='accept'): @@ -375,7 +386,7 @@ class HomeView(BaseView): except TimeoutException: pass self.open_activity_center_button.click_until_presence_of_element(self.close_activity_centre) - chat_element = ActivityCenterElement(self.driver, username[:25]) + chat_element = self.get_activity_center_element_by_text(username[:25]) try: if action == 'accept': self.driver.info("Accepting incoming CR for %s" % username)