From cc29436741d4ff29133bdf2c7bb3a9dc4eb2a853 Mon Sep 17 00:00:00 2001 From: ericbsd Date: Thu, 25 Apr 2024 08:46:54 -0300 Subject: [PATCH 01/15] Fixed starting SMB service in smb share test --- tests/bdd/core/test_NAS_T1007.py | 15 ++---------- tests/bdd/core/test_NAS_T1010.py | 15 ++---------- tests/bdd/core/test_NAS_T1013.py | 11 +-------- tests/bdd/core/test_NAS_T1016.py | 11 +-------- tests/bdd/core/test_NAS_T1018.py | 11 +-------- tests/bdd/core/test_NAS_T1041.py | 16 +------------ tests/bdd/reusableSeleniumCode.py | 38 ++++++++++++++++++++++++++++++- 7 files changed, 45 insertions(+), 72 deletions(-) diff --git a/tests/bdd/core/test_NAS_T1007.py b/tests/bdd/core/test_NAS_T1007.py index 4f71f6d8d21..cdd356916ca 100644 --- a/tests/bdd/core/test_NAS_T1007.py +++ b/tests/bdd/core/test_NAS_T1007.py @@ -127,24 +127,13 @@ def the_service_page_should_open(driver): def if_the_smb_service_is_not_started_start_the_service(driver): """if the SMB service is not started, start the service.""" assert wait_on_element(driver, 7, '//services') - assert wait_on_element(driver, 7, '//button[@ix-auto="button__S3_Actions"]') - # Scroll to SMB service - element = driver.find_element_by_xpath('//button[@ix-auto="button__S3_Actions"]') - driver.execute_script("arguments[0].scrollIntoView();", element) - time.sleep(1) - driver.find_element_by_xpath('//div[@ix-auto="value__SMB"]') - value_exist = attribute_value_exist(driver, '//mat-slide-toggle[@ix-auto="slider__SMB_Running"]', 'class', 'mat-checked') - if not value_exist: - driver.find_element_by_xpath('//div[@ix-auto="overlay__SMB_Running"]').click() - time.sleep(2) + rsc.set_service_toggle(driver, 'SMB') @then('click on the SMB Start Automatically checkbox') def click_on_the_smb_start_automatically_checkbox(driver): """click on the SMB Start Automatically checkbox.""" - value_exist = attribute_value_exist(driver, '//mat-checkbox[@ix-auto="checkbox__SMB_Start Automatically"]', 'class', 'mat-checkbox-checked') - if not value_exist: - driver.find_element_by_xpath('//mat-checkbox[@ix-auto="checkbox__SMB_Start Automatically"]').click() + rsc.set_service_checkbox(driver, 'SMB') @then(parsers.parse('send a file to the share with ip/"{smbname}" and "{user}"%"{password}"')) diff --git a/tests/bdd/core/test_NAS_T1010.py b/tests/bdd/core/test_NAS_T1010.py index 054c4156f7c..37cd99b73bf 100644 --- a/tests/bdd/core/test_NAS_T1010.py +++ b/tests/bdd/core/test_NAS_T1010.py @@ -128,24 +128,13 @@ def the_service_page_should_open(driver): def if_the_smb_service_is_not_started_start_the_service(driver): """if the SMB service is not started, start the service.""" assert wait_on_element(driver, 7, '//services') - assert wait_on_element(driver, 7, '//button[@ix-auto="button__S3_Actions"]') - # Scroll to SMB service - element = driver.find_element_by_xpath('//button[@ix-auto="button__S3_Actions"]') - driver.execute_script("arguments[0].scrollIntoView();", element) - time.sleep(1) - driver.find_element_by_xpath('//div[@ix-auto="value__SMB"]') - value_exist = attribute_value_exist(driver, '//mat-slide-toggle[@ix-auto="slider__SMB_Running"]', 'class', 'mat-checked') - if not value_exist: - driver.find_element_by_xpath('//div[@ix-auto="overlay__SMB_Running"]').click() - time.sleep(2) + rsc.set_service_toggle(driver, 'SMB') @then('click on the SMB Start Automatically checkbox') def click_on_the_smb_start_automatically_checkbox(driver): """click on the SMB Start Automatically checkbox.""" - value_exist = attribute_value_exist(driver, '//mat-checkbox[@ix-auto="checkbox__SMB_Start Automatically"]', 'class', 'mat-checkbox-checked') - if not value_exist: - driver.find_element_by_xpath('//mat-checkbox[@ix-auto="checkbox__SMB_Start Automatically"]').click() + rsc.set_service_checkbox(driver, 'SMB') @then(parsers.parse('send a file to the share with ip/"{smbname}" and "{ad_user}"%"{ad_password}"')) diff --git a/tests/bdd/core/test_NAS_T1013.py b/tests/bdd/core/test_NAS_T1013.py index 402eb3e1ace..d53ee88538f 100644 --- a/tests/bdd/core/test_NAS_T1013.py +++ b/tests/bdd/core/test_NAS_T1013.py @@ -131,16 +131,7 @@ def the_service_page_should_open(driver): @then('if the SMB service is not started, start the service') def if_the_smb_service_is_not_started_start_the_service(driver): """if the SMB service is not started, start the service.""" - assert wait_on_element(driver, 7, '//button[@ix-auto="button__S3_Actions"]') - # Scroll to SMB service - element = driver.find_element_by_xpath('//button[@ix-auto="button__S3_Actions"]') - driver.execute_script("arguments[0].scrollIntoView();", element) - time.sleep(1) - driver.find_element_by_xpath('//div[@ix-auto="value__SMB"]') - value_exist = attribute_value_exist(driver, '//mat-slide-toggle[@ix-auto="slider__SMB_Running"]', 'class', 'mat-checked') - if not value_exist: - driver.find_element_by_xpath('//div[@ix-auto="overlay__SMB_Running"]').click() - time.sleep(5) + rsc.set_service_toggle(driver, 'SMB') @then(parsers.parse('send a file to the share with ip/{smbname} and {ldap_user}%{ldap_password}')) diff --git a/tests/bdd/core/test_NAS_T1016.py b/tests/bdd/core/test_NAS_T1016.py index 569f7e7a3ce..f15f99bea37 100644 --- a/tests/bdd/core/test_NAS_T1016.py +++ b/tests/bdd/core/test_NAS_T1016.py @@ -132,16 +132,7 @@ def the_service_page_should_open(driver): def if_the_smb_service_is_not_started_start_the_service(driver): """if the SMB service is not started, start the service.""" assert wait_on_element(driver, 7, '//services') - assert wait_on_element(driver, 7, '//button[@ix-auto="button__S3_Actions"]') - # Scroll to SMB service - element = driver.find_element_by_xpath('//button[@ix-auto="button__S3_Actions"]') - driver.execute_script("arguments[0].scrollIntoView();", element) - time.sleep(1) - driver.find_element_by_xpath('//div[@ix-auto="value__SMB"]') - value_exist = attribute_value_exist(driver, '//mat-slide-toggle[@ix-auto="slider__SMB_Running"]', 'class', 'mat-checked') - if not value_exist: - driver.find_element_by_xpath('//div[@ix-auto="overlay__SMB_Running"]').click() - time.sleep(2) + rsc.set_service_toggle(driver, 'SMB') @then(parsers.parse('send a file to the share with NAS IP/{smb_name} and {user}%{password}')) diff --git a/tests/bdd/core/test_NAS_T1018.py b/tests/bdd/core/test_NAS_T1018.py index 11b0fe49b99..834e7c7215d 100644 --- a/tests/bdd/core/test_NAS_T1018.py +++ b/tests/bdd/core/test_NAS_T1018.py @@ -132,16 +132,7 @@ def the_service_page_should_open(driver): def if_the_smb_service_is_not_started_start_the_service(driver): """if the SMB service is not started, start the service.""" assert wait_on_element(driver, 7, '//services') - assert wait_on_element(driver, 7, '//button[@ix-auto="button__S3_Actions"]') - # Scroll to SMB service - element = driver.find_element_by_xpath('//button[@ix-auto="button__S3_Actions"]') - driver.execute_script("arguments[0].scrollIntoView();", element) - time.sleep(1) - driver.find_element_by_xpath('//div[@ix-auto="value__SMB"]') - value_exist = attribute_value_exist(driver, '//mat-slide-toggle[@ix-auto="slider__SMB_Running"]', 'class', 'mat-checked') - if not value_exist: - driver.find_element_by_xpath('//div[@ix-auto="overlay__SMB_Running"]').click() - time.sleep(2) + rsc.set_service_toggle(driver, 'SMB') @then(parsers.parse('send a file to the share with NAS IP/{smb_name} and {user}%{password}')) diff --git a/tests/bdd/core/test_NAS_T1041.py b/tests/bdd/core/test_NAS_T1041.py index 938727c82c8..c76d45d3603 100644 --- a/tests/bdd/core/test_NAS_T1041.py +++ b/tests/bdd/core/test_NAS_T1041.py @@ -256,21 +256,7 @@ def click_on_service_on_the_side_menu_the_service_page_should_open(driver): @then('if the SMB service is not started, start the service') def if_the_smb_service_is_not_started_start_the_service(driver): """if the SMB service is not started, start the service.""" - if is_element_present(driver, '//li[@aria-label="page 4"]'): - assert wait_on_element(driver, 7, '//li[@aria-label="page 3"]', 'clickable') - driver.find_element_by_xpath('//li[@aria-label="page 3"]').click() - else: - # Scroll to SMB service - assert wait_on_element(driver, 7, '//div[@ix-auto="overlay__S3_Running"]') - element = driver.find_element_by_xpath('//button[@ix-auto="button__S3_Actions"]') - driver.execute_script("arguments[0].scrollIntoView();", element) - time.sleep(0.5) - assert wait_on_element(driver, 7, '//div[@ix-auto="overlay__SMB_Running"]', 'clickable') - value_exist = attribute_value_exist(driver, '//mat-slide-toggle[@ix-auto="slider__SMB_Running"]', 'class', 'mat-checked') - if not value_exist: - driver.find_element_by_xpath('//div[@ix-auto="overlay__SMB_Running"]').click() - # This sleep is to make sure the system ready for smbclient - time.sleep(2) + rsc.set_service_toggle(driver, 'SMB') @then(parsers.parse('send a file to the share with ip/"{smbname}" and "{user}"%password')) diff --git a/tests/bdd/reusableSeleniumCode.py b/tests/bdd/reusableSeleniumCode.py index 245315bd188..e3409e38020 100644 --- a/tests/bdd/reusableSeleniumCode.py +++ b/tests/bdd/reusableSeleniumCode.py @@ -2,7 +2,8 @@ import xpaths import time from function import ( - wait_on_element + wait_on_element, + attribute_value_exist ) @@ -35,3 +36,38 @@ def click_on_element(driver: classmethod, xpath: str): def click_If_Element_Exist(driver: classmethod, xpath: str): if wait_on_element(driver, 5, xpath, 'clickable'): driver.find_element_by_xpath(xpath).click() + + +def set_service_checkbox(driver: classmethod, service_name: str): + """ + This function will toggle the service on. + + :param driver: Webdriver Instance + :param service_name: Name of the service ex. 'SMB' + + Example: + set_service_checkbox(driver, 'SMB') + """ + assert wait_on_element(driver, 7, f'//div[@ix-auto="overlay__{service_name}_Running"]', 'clickable') + value_exist = attribute_value_exist(driver, f'//mat-checkbox[@ix-auto="checkbox__{service_name}_Running"]', 'class', + 'mat-checkbox-checked') + if not value_exist: + driver.find_element_by_xpath(f'//div[@ix-auto="overlay__{service_name}_Running"]').click() + + +def set_service_toggle(driver: classmethod, service_name: str): + """ + This function will toggle the service on. + + :param driver: Webdriver Instance + :param service_name: Name of the service ex. 'SMB' + + Example: + set_service_toggle(driver, 'SMB') + """ + assert wait_on_element(driver, 7, f'//div[@ix-auto="overlay__{service_name}_Running"]', 'clickable') + value_exist = attribute_value_exist(driver, f'//mat-slide-toggle[@ix-auto="slider__{service_name}_Running"]', 'class', + 'mat-checked') + if not value_exist: + driver.find_element_by_xpath(f'//div[@ix-auto="overlay__{service_name}_Running"]').click() + time.sleep(2) From d873285b722c18ed5c19eeccda1bc88d8a7b44ae Mon Sep 17 00:00:00 2001 From: ericbsd Date: Thu, 25 Apr 2024 16:18:56 -0300 Subject: [PATCH 02/15] Fix error AWS S# error message --- tests/bdd/core/test_NAS_T1118.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bdd/core/test_NAS_T1118.py b/tests/bdd/core/test_NAS_T1118.py index 6405187bdf3..ec51fe46e5d 100644 --- a/tests/bdd/core/test_NAS_T1118.py +++ b/tests/bdd/core/test_NAS_T1118.py @@ -157,6 +157,6 @@ def click_verify_credential_to_verify_the_access_key_is_invalid(driver): driver.find_element_by_xpath('//button[@ix-auto="button__VERIFY CREDENTIAL"]').click() assert wait_on_element_disappear(driver, 20, '//h1[contains(.,"Please wait")]') assert wait_on_element(driver, 10, '//h1[normalize-space(text())="Error"]') - assert wait_on_element(driver, 10, '//span[contains(.,"SignatureDoesNotMatch:")]') + assert wait_on_element(driver, 10, '//span[contains(.,"SignatureDoesNotMatch:") or contains(text(),"NOTICE:")]') assert wait_on_element(driver, 5, '//button[@ix-auto="button__CLOSE"]', 'clickable') driver.find_element_by_xpath('//button[@ix-auto="button__CLOSE"]').click() From 03d6a4add2049e42d1b5dc848f012c09874782c3 Mon Sep 17 00:00:00 2001 From: ericbsd Date: Fri, 26 Apr 2024 12:00:30 -0300 Subject: [PATCH 03/15] Fix set_service_checkbox --- tests/bdd/reusableSeleniumCode.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/bdd/reusableSeleniumCode.py b/tests/bdd/reusableSeleniumCode.py index e3409e38020..62c2d4adf0c 100644 --- a/tests/bdd/reusableSeleniumCode.py +++ b/tests/bdd/reusableSeleniumCode.py @@ -48,11 +48,11 @@ def set_service_checkbox(driver: classmethod, service_name: str): Example: set_service_checkbox(driver, 'SMB') """ - assert wait_on_element(driver, 7, f'//div[@ix-auto="overlay__{service_name}_Running"]', 'clickable') - value_exist = attribute_value_exist(driver, f'//mat-checkbox[@ix-auto="checkbox__{service_name}_Running"]', 'class', + assert wait_on_element(driver, 7, f'//*[@ix-auto="checkbox__{service_name}_Start Automatically"]', 'clickable') + value_exist = attribute_value_exist(driver, f'//*[@ix-auto="checkbox__{service_name}_Start Automatically"]', 'class', 'mat-checkbox-checked') if not value_exist: - driver.find_element_by_xpath(f'//div[@ix-auto="overlay__{service_name}_Running"]').click() + driver.find_element_by_xpath(f'//*[@ix-auto="checkbox__{service_name}_Start Automatically"]').click() def set_service_toggle(driver: classmethod, service_name: str): @@ -65,9 +65,9 @@ def set_service_toggle(driver: classmethod, service_name: str): Example: set_service_toggle(driver, 'SMB') """ - assert wait_on_element(driver, 7, f'//div[@ix-auto="overlay__{service_name}_Running"]', 'clickable') - value_exist = attribute_value_exist(driver, f'//mat-slide-toggle[@ix-auto="slider__{service_name}_Running"]', 'class', + assert wait_on_element(driver, 7, f'//*[@ix-auto="overlay__{service_name}_Running"]', 'clickable') + value_exist = attribute_value_exist(driver, f'//*[@ix-auto="slider__{service_name}_Running"]', 'class', 'mat-checked') if not value_exist: - driver.find_element_by_xpath(f'//div[@ix-auto="overlay__{service_name}_Running"]').click() + driver.find_element_by_xpath(f'//*[@ix-auto="overlay__{service_name}_Running"]').click() time.sleep(2) From 743369044af765de03c6872e6cf351f98865a2a0 Mon Sep 17 00:00:00 2001 From: ericbsd Date: Fri, 26 Apr 2024 12:38:22 -0300 Subject: [PATCH 04/15] Fixed aws folder header xpath --- tests/bdd/core/test_NAS_T1121.py | 58 ++++++++++++++++---------------- tests/bdd/xpaths.py | 9 +++++ 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/tests/bdd/core/test_NAS_T1121.py b/tests/bdd/core/test_NAS_T1121.py index 83313819249..67d57ab267f 100644 --- a/tests/bdd/core/test_NAS_T1121.py +++ b/tests/bdd/core/test_NAS_T1121.py @@ -194,14 +194,14 @@ def click_on_the_bucket_being_used_and_then_upload_a_file(driver): assert wait_on_element(driver, 10, '//div[contains(.,"Amazon S3")]') assert wait_on_element(driver, 5, f'//a[text()="{my_bucket}"]', 'clickable') driver.find_element_by_xpath(f'//a[text()="{my_bucket}"]').click() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, xpaths.aws.upload_Button, 'clickable') rsc.click_If_Element_Exist(driver, xpaths.button.close_Popover) s3_client = boto3.client('s3') s3_client.upload_file('cloud_test.txt', my_bucket, 'cloud_test.txt') driver.refresh() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, '//span[text()="cloud_test.txt"]', 'clickable') time.sleep(0.5) @@ -240,7 +240,7 @@ def verify_the_file_is_copied_from_the_s3_bucket_into_the_dataset(driver, nas_ip def on_the_bucket_tab_create_a_folder_and_upload_a_file_in_it(driver): """on the bucket tab, create a folder, and upload a file in it.""" driver.switch_to.window(driver.window_handles[1]) - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, xpaths.aws.create_Folder_Button, 'clickable') driver.find_element_by_xpath(xpaths.aws.create_Folder_Button).click() assert wait_on_element(driver, 10, '//div[contains(.,"Create folder")]') @@ -249,13 +249,13 @@ def on_the_bucket_tab_create_a_folder_and_upload_a_file_in_it(driver): assert wait_on_element(driver, 5, xpaths.aws.create_The_Folder_Button, 'clickable') rsc.scroll_To(driver, xpaths.aws.create_The_Folder_Button) driver.find_element_by_xpath(xpaths.aws.create_The_Folder_Button).click() - assert wait_on_element(driver, 10, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 10, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, '//span[text()="my_folder/"]', 'clickable') s3_client = boto3.client('s3') s3_client.upload_file('cloud_test.txt', my_bucket, 'my_folder/cloud_test.txt') assert wait_on_element(driver, 5, '//span[text()="my_folder/"]', 'clickable') driver.find_element_by_xpath('//span[text()="my_folder/"]').click() - assert wait_on_element(driver, 5, '//h1[text()="my_folder/"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header("my_folder/")) assert wait_on_element(driver, 5, '//span[text()="cloud_test.txt"]', 'clickable') @@ -344,10 +344,10 @@ def under_transfer_mode_select_move_click_save(driver): def on_the_bucket_add_a_file_in_the_folder(driver): """on the bucket add a file in the folder.""" driver.switch_to.window(driver.window_handles[1]) - assert wait_on_element(driver, 5, '//h1[text()="my_folder/"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header("my_folder/")) assert wait_on_element(driver, 5, f'//span[text()="{my_bucket}"]') driver.find_element_by_xpath(f'//span[text()="{my_bucket}"]').click() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) s3_client = boto3.client('s3') s3_client.upload_file('cloud_test.txt', my_bucket, 'cloud_test.txt') driver.refresh() @@ -356,7 +356,7 @@ def on_the_bucket_add_a_file_in_the_folder(driver): s3_client.upload_file('cloud_test.txt', my_bucket, 'my_folder/cloud_test.txt') assert wait_on_element(driver, 5, '//span[text()="my_folder/"]', 'clickable') driver.find_element_by_xpath('//span[text()="my_folder/"]').click() - assert wait_on_element(driver, 5, '//h1[text()="my_folder/"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header("my_folder/")) assert wait_on_element(driver, 5, '//span[text()="cloud_test.txt"]', 'clickable') @@ -371,11 +371,11 @@ def verify_all_files_are_moved_from_the_s3_bucket_to_the_dataset(driver, nas_ip) assert results['result'] is True driver.switch_to.window(driver.window_handles[1]) driver.refresh() - assert wait_on_element(driver, 5, '//h1[text()="my_folder/"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header("my_folder/")) assert wait_on_element(driver, 5, f'//span[text()="{my_bucket}"]') assert not wait_on_element(driver, 1, '//span[text()="cloud_test.txt"]') driver.find_element_by_xpath(f'//span[text()="{my_bucket}"]').click() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert not wait_on_element(driver, 1, '//span[text()="cloud_test.txt"]', 'clickable') @@ -400,12 +400,12 @@ def under_transfer_mode_select_sync_then_click_save(driver): def on_the_bucket_tab_upload_a_file(driver): """on the bucket tab, upload a file.""" driver.switch_to.window(driver.window_handles[1]) - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, xpaths.aws.upload_Button, 'clickable') s3_client = boto3.client('s3') s3_client.upload_file('cloud_test.txt', my_bucket, 'cloud_test.txt') driver.refresh() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, '//span[text()="cloud_test.txt"]', 'clickable') time.sleep(1) @@ -418,7 +418,7 @@ def verify_the_file_is_sync_from_the_s3_bucket_to_the_dataset(driver, nas_ip): assert results['result'] is True driver.switch_to.window(driver.window_handles[1]) driver.refresh() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, '//span[text()="cloud_test.txt"]', 'clickable') @@ -428,7 +428,7 @@ def delete_the_file_from_the_s3_bucket_in_the_aws_web_console(driver): driver.switch_to.window(driver.window_handles[1]) driver.refresh() time.sleep(0.5) - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, '//span[text()="cloud_test.txt"]', 'clickable') driver.find_element_by_xpath(xpaths.aws.check_All_Checkbox).click() assert wait_on_element(driver, 5, xpaths.aws.delete_Button, 'clickable') @@ -442,7 +442,7 @@ def delete_the_file_from_the_s3_bucket_in_the_aws_web_console(driver): time.sleep(0.5) assert wait_on_element(driver, 5, '//awsui-button[@class="delete-objects__exit"]/button', 'clickable') driver.find_element_by_xpath('//awsui-button[@class="delete-objects__exit"]/button').click() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) @then('verify that the file is deleted on the NAS dataset') @@ -458,7 +458,7 @@ def create_a_folder_and_upload_a_file_in_it(driver): """create a folder, and upload a file in it.""" driver.switch_to.window(driver.window_handles[1]) time.sleep(1) - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, xpaths.aws.create_Folder_Button, 'clickable') driver.find_element_by_xpath(xpaths.aws.create_Folder_Button).click() assert wait_on_element(driver, 10, '//div[contains(.,"Create folder")]') @@ -467,13 +467,13 @@ def create_a_folder_and_upload_a_file_in_it(driver): assert wait_on_element(driver, 5, xpaths.aws.create_The_Folder_Button, 'clickable') rsc.scroll_To(driver, xpaths.aws.create_The_Folder_Button) driver.find_element_by_xpath(xpaths.aws.create_The_Folder_Button).click() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, '//span[text()="my_folder/"]', 'clickable') s3_client = boto3.client('s3') s3_client.upload_file('cloud_test.txt', my_bucket, 'my_folder/cloud_test.txt') assert wait_on_element(driver, 5, '//span[text()="my_folder/"]', 'clickable') driver.find_element_by_xpath('//span[text()="my_folder/"]').click() - assert wait_on_element(driver, 5, '//h1[text()="my_folder/"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header("my_folder/")) assert wait_on_element(driver, 5, '//span[text()="cloud_test.txt"]', 'clickable') @@ -491,10 +491,10 @@ def delete_the_folder_from_the_s3_bucket_in_the_aws_web_console(driver, nas_ip): driver.switch_to.window(driver.window_handles[1]) driver.refresh() time.sleep(1) - assert wait_on_element(driver, 5, '//h1[text()="my_folder/"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header("my_folder/")) assert wait_on_element(driver, 5, f'//span[text()="{my_bucket}"]') driver.find_element_by_xpath(f'//span[text()="{my_bucket}"]').click() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) time.sleep(1) driver.find_element_by_xpath(xpaths.aws.check_All_Checkbox).click() assert wait_on_element(driver, 5, xpaths.aws.delete_Button, 'clickable') @@ -508,7 +508,7 @@ def delete_the_folder_from_the_s3_bucket_in_the_aws_web_console(driver, nas_ip): time.sleep(0.5) assert wait_on_element(driver, 5, '//awsui-button[@class="delete-objects__exit"]/button', 'clickable') driver.find_element_by_xpath('//awsui-button[@class="delete-objects__exit"]/button').click() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) cmd = 'rm -r /mnt/tank/aws_share/my_folder' results = ssh_cmd(cmd, 'root', 'testing', nas_ip) assert results['result'] is True @@ -587,7 +587,7 @@ def verify_the_file_appear_in_the_s3_bucket(driver): """verify the file appear in the S3 bucket.""" driver.switch_to.window(driver.window_handles[1]) driver.refresh() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, '//span[text()="cloud_test.txt"]', 'clickable') @@ -618,10 +618,10 @@ def verify_the_folder_appear_in_the_s3_bucket_with_the_file(driver): """verify the folder appear in the S3 bucket with the file.""" driver.switch_to.window(driver.window_handles[1]) driver.refresh() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, '//span[text()="my_folder/"]', 'clickable') driver.find_element_by_xpath('//span[text()="my_folder/"]').click() - assert wait_on_element(driver, 5, '//h1[text()="my_folder/"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header("my_folder/")) assert wait_on_element(driver, 5, '//span[text()="cloud_test.txt"]', 'clickable') @@ -630,7 +630,7 @@ def verify_the_file_appear_into_the_s3_bucket_and_is_removed_from_the_nas(driver """verify the file appear into the S3 bucket and is removed from the NAS.""" driver.switch_to.window(driver.window_handles[1]) driver.refresh() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert wait_on_element(driver, 5, '//span[text()="cloud_test.txt"]', 'clickable') cmd = 'test -f /mnt/tank/aws_share/cloud_test.txt' results = ssh_cmd(cmd, 'root', 'testing', nas_ip) @@ -668,7 +668,7 @@ def on_the_bucket_tab_verify_the_file_is_deleted(driver): """on the bucket tab, verify the file is deleted.""" driver.switch_to.window(driver.window_handles[1]) driver.refresh() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert not wait_on_element(driver, 2, '//span[text()="cloud_test.txt"]', 'clickable') @@ -702,12 +702,12 @@ def delete_the_folder_from_the_dataset_then_click_run_now(driver, nas_ip): def on_the_bucket_tab_verify_the_folder_is_deleted(driver): """on the bucket tab, verify the folder is deleted.""" driver.switch_to.window(driver.window_handles[1]) - assert wait_on_element(driver, 5, '//h1[text()="my_folder/"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header("my_folder/")) assert wait_on_element(driver, 5, f'//span[text()="{my_bucket}"]') driver.find_element_by_xpath(f'//span[text()="{my_bucket}"]').click() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) driver.refresh() - assert wait_on_element(driver, 5, f'//h1[text()="{my_bucket}"]') + assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) assert not wait_on_element(driver, 1, '//span[text()="my_folder/"]', 'clickable') driver.close() driver.switch_to.window(driver.window_handles[0]) diff --git a/tests/bdd/xpaths.py b/tests/bdd/xpaths.py index 84339ad3ed2..938c922b811 100644 --- a/tests/bdd/xpaths.py +++ b/tests/bdd/xpaths.py @@ -43,6 +43,7 @@ class google_Drive: music_Folder = '//div[@data-tooltip="Google Drive Folder: music"]' move_To_Trash = '//div[text()="Move to trash?"]' + class input: username = '//input[@ix-auto="input__Username"]' password = '//input[@ix-auto="input__Password"]' @@ -95,6 +96,14 @@ class aws: def aws_button(field): return f'(//button[@data-testid="{field}"])[1]' + def folder_header(folder_name: str): + """ + xpath for the bucket header + :param folder_name: name of the bucket + :return: the xpath of the bucket header + """ + return f'//h1[contains(.,"{folder_name}")]' + create_Folder_Button = aws_button('create-folder-button') delete_Button = aws_button('delete-objects-button') upload_Button = aws_button('upload-button') From c4c06f77f7bdc894c8a36044ca2eee64ecedf72a Mon Sep 17 00:00:00 2001 From: ericbsd Date: Fri, 26 Apr 2024 14:18:44 -0300 Subject: [PATCH 05/15] Fixed aws create folder button --- tests/bdd/xpaths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bdd/xpaths.py b/tests/bdd/xpaths.py index 938c922b811..c534877717c 100644 --- a/tests/bdd/xpaths.py +++ b/tests/bdd/xpaths.py @@ -108,4 +108,4 @@ def folder_header(folder_name: str): delete_Button = aws_button('delete-objects-button') upload_Button = aws_button('upload-button') check_All_Checkbox = '//input[@type="checkbox" and @tabindex="-1"]' - create_The_Folder_Button = '//awsui-button[@class="createFolder-object-actions__actions-submit"]' + create_The_Folder_Button = '//button[contains(@class,"createFolder-object-actions__actions-submit")]' From 18d3f8d7588d74dca13c877912a937a46f3c3461 Mon Sep 17 00:00:00 2001 From: ericbsd Date: Fri, 26 Apr 2024 14:24:36 -0300 Subject: [PATCH 06/15] Fixed set SMB service toggle. --- tests/bdd/core/test_NAS_T1222.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tests/bdd/core/test_NAS_T1222.py b/tests/bdd/core/test_NAS_T1222.py index f22f825c4de..eb27f0613a9 100644 --- a/tests/bdd/core/test_NAS_T1222.py +++ b/tests/bdd/core/test_NAS_T1222.py @@ -63,16 +63,7 @@ def on_the_service_page_if_the_smb_service_is_not_started_start_it(driver): """on the Service page, if the SMB service is not started, start it.""" assert wait_on_element(driver, 7, '//services') assert wait_on_element(driver, 10, '//li[contains(.,"Services")]') - assert wait_on_element(driver, 7, '//button[@ix-auto="button__S3_Actions"]') - # Scroll to SMB service - element = driver.find_element_by_xpath('//button[@ix-auto="button__S3_Actions"]') - driver.execute_script("arguments[0].scrollIntoView();", element) - time.sleep(1) - driver.find_element_by_xpath('//div[@ix-auto="value__SMB"]') - value_exist = attribute_value_exist(driver, '//mat-slide-toggle[@ix-auto="slider__SMB_Running"]', 'class', 'mat-checked') - if not value_exist: - driver.find_element_by_xpath('//div[@ix-auto="overlay__SMB_Running"]').click() - time.sleep(1) + rsc.set_service_toggle(driver, 'SMB') @then('kill all smbd with ssh to trigger core files alert') From 2f34eeeec22aa3053528f73cf6997478226b248b Mon Sep 17 00:00:00 2001 From: ericbsd Date: Mon, 29 Apr 2024 08:42:16 -0300 Subject: [PATCH 07/15] Fixed aws delete object button --- tests/bdd/core/test_NAS_T1121.py | 8 +++---- tests/bdd/xpaths.py | 39 ++++++++++++++++---------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/tests/bdd/core/test_NAS_T1121.py b/tests/bdd/core/test_NAS_T1121.py index 67d57ab267f..e8969dc6a2c 100644 --- a/tests/bdd/core/test_NAS_T1121.py +++ b/tests/bdd/core/test_NAS_T1121.py @@ -436,8 +436,8 @@ def delete_the_file_from_the_s3_bucket_in_the_aws_web_console(driver): assert wait_on_element(driver, 5, '//div[contains(.,"Delete objects")]') assert wait_on_element(driver, 5, '//input[@placeholder="permanently delete"]', 'inputable') driver.find_element_by_xpath('//input[@placeholder="permanently delete"]').send_keys('permanently delete') - assert wait_on_element(driver, 5, '//awsui-button[@class="delete-objects__actions-submit"]', 'clickable') - driver.find_element_by_xpath('//awsui-button[@class="delete-objects__actions-submit"]').click() + assert wait_on_element(driver, 5, xpaths.aws.delete_Objects_Button, 'clickable') + driver.find_element_by_xpath(xpaths.aws.delete_Objects_Button).click() assert wait_on_element(driver, 5, '//div[contains(.,"Delete objects: status")]') time.sleep(0.5) assert wait_on_element(driver, 5, '//awsui-button[@class="delete-objects__exit"]/button', 'clickable') @@ -502,8 +502,8 @@ def delete_the_folder_from_the_s3_bucket_in_the_aws_web_console(driver, nas_ip): assert wait_on_element(driver, 5, '//div[contains(.,"Delete objects")]') assert wait_on_element(driver, 5, '//input[@placeholder="permanently delete"]', 'inputable') driver.find_element_by_xpath('//input[@placeholder="permanently delete"]').send_keys('permanently delete') - assert wait_on_element(driver, 5, '//awsui-button[@class="delete-objects__actions-submit"]', 'clickable') - driver.find_element_by_xpath('//awsui-button[@class="delete-objects__actions-submit"]').click() + assert wait_on_element(driver, 5, xpaths.aws.delete_Objects_Button, 'clickable') + driver.find_element_by_xpath(xpaths.aws.delete_Objects_Button).click() assert wait_on_element(driver, 5, '//div[contains(.,"Delete objects: status")]') time.sleep(0.5) assert wait_on_element(driver, 5, '//awsui-button[@class="delete-objects__exit"]/button', 'clickable') diff --git a/tests/bdd/xpaths.py b/tests/bdd/xpaths.py index c534877717c..e3fda85b11a 100644 --- a/tests/bdd/xpaths.py +++ b/tests/bdd/xpaths.py @@ -8,6 +8,26 @@ class authorization: Grant_Access_To_Box_Button = '//button[@id="consent_accept_button"]' +class aws: + def aws_button(field: str): + return f'(//button[@data-testid="{field}"])[1]' + + def folder_header(folder_name: str): + """ + xpath for the bucket header + :param folder_name: name of the bucket + :return: the xpath of the bucket header + """ + return f'//h1[contains(.,"{folder_name}")]' + + create_Folder_Button = aws_button('create-folder-button') + delete_Button = aws_button('delete-objects-button') + upload_Button = aws_button('upload-button') + check_All_Checkbox = '//input[@type="checkbox" and @tabindex="-1"]' + create_The_Folder_Button = '//button[contains(@class,"createFolder-object-actions__actions-submit")]' + delete_Objects_Button = '//button[contains(@class,"delete-objects__actions-submit")]' + + class breadcrumb: dashboard = '//a[text()="Dashboard"]' @@ -90,22 +110,3 @@ class sideMenu: class topToolbar: ha_enable = '//mat-icon[@svgicon="ha_enabled"]' ha_disabled = '//mat-icon[contains(.,"ha_disabled")]' - - -class aws: - def aws_button(field): - return f'(//button[@data-testid="{field}"])[1]' - - def folder_header(folder_name: str): - """ - xpath for the bucket header - :param folder_name: name of the bucket - :return: the xpath of the bucket header - """ - return f'//h1[contains(.,"{folder_name}")]' - - create_Folder_Button = aws_button('create-folder-button') - delete_Button = aws_button('delete-objects-button') - upload_Button = aws_button('upload-button') - check_All_Checkbox = '//input[@type="checkbox" and @tabindex="-1"]' - create_The_Folder_Button = '//button[contains(@class,"createFolder-object-actions__actions-submit")]' From 44f384cfcd378f84bea5d599f48b1e4b3177222b Mon Sep 17 00:00:00 2001 From: ericbsd Date: Mon, 29 Apr 2024 08:55:43 -0300 Subject: [PATCH 08/15] Remove verification for google. --- tests/bdd/core/test_NAS_T1141.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/bdd/core/test_NAS_T1141.py b/tests/bdd/core/test_NAS_T1141.py index fa5478c0e12..7e3b10ffb63 100644 --- a/tests/bdd/core/test_NAS_T1141.py +++ b/tests/bdd/core/test_NAS_T1141.py @@ -247,17 +247,14 @@ def open_a_new_tab_navigate_to_google_drive_url_and_input_account_id(driver, dri driver.execute_script("window.open();") driver.switch_to.window(driver.window_handles[1]) driver.get(driver_url) - assert wait_on_element(driver, 5, '//a[@title="Google"]') time.sleep(1) - assert wait_on_element(driver, 5, '//div[@class="glue-header__container glue-header__container--cta"]//a[contains(text(),"Go to Drive")]', 'clickable') - driver.find_element_by_xpath('//div[@class="glue-header__container glue-header__container--cta"]//a[contains(text(),"Go to Drive")]').click() @then(parsers.parse('enter the "{user_name}" click Next and enter the "{password}" click Next')) def enter_the_user_name_click_Next_and_enter_the_password_click_Next(driver, user_name, password): """enter the click Next and enter the click Next.""" driver.switch_to.window(driver.window_handles[2]) - if wait_on_element(driver, 2, '//span[text()="Sign in"]'): + if wait_on_element(driver, 3, '//span[text()="Sign in"]'): assert wait_on_element(driver, 5, '//span[text()="Sign in"]') assert wait_on_element(driver, 5, '//input[@id="identifierId"]', 'inputable') driver.find_element_by_xpath('//input[@id="identifierId"]').send_keys(user_name) From e07fd652e75e64a2044e90def94bbcde17210869 Mon Sep 17 00:00:00 2001 From: ericbsd Date: Mon, 29 Apr 2024 12:17:01 -0300 Subject: [PATCH 09/15] fixed close in aws --- tests/bdd/core/test_NAS_T1121.py | 8 ++++---- tests/bdd/xpaths.py | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/bdd/core/test_NAS_T1121.py b/tests/bdd/core/test_NAS_T1121.py index e8969dc6a2c..d50640520f0 100644 --- a/tests/bdd/core/test_NAS_T1121.py +++ b/tests/bdd/core/test_NAS_T1121.py @@ -440,8 +440,8 @@ def delete_the_file_from_the_s3_bucket_in_the_aws_web_console(driver): driver.find_element_by_xpath(xpaths.aws.delete_Objects_Button).click() assert wait_on_element(driver, 5, '//div[contains(.,"Delete objects: status")]') time.sleep(0.5) - assert wait_on_element(driver, 5, '//awsui-button[@class="delete-objects__exit"]/button', 'clickable') - driver.find_element_by_xpath('//awsui-button[@class="delete-objects__exit"]/button').click() + assert wait_on_element(driver, 5, xpaths.aws.close, 'clickable') + driver.find_element_by_xpath(xpaths.aws.close).click() assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) @@ -506,8 +506,8 @@ def delete_the_folder_from_the_s3_bucket_in_the_aws_web_console(driver, nas_ip): driver.find_element_by_xpath(xpaths.aws.delete_Objects_Button).click() assert wait_on_element(driver, 5, '//div[contains(.,"Delete objects: status")]') time.sleep(0.5) - assert wait_on_element(driver, 5, '//awsui-button[@class="delete-objects__exit"]/button', 'clickable') - driver.find_element_by_xpath('//awsui-button[@class="delete-objects__exit"]/button').click() + assert wait_on_element(driver, 5, xpaths.aws.close, 'clickable') + driver.find_element_by_xpath(xpaths.aws.close).click() assert wait_on_element(driver, 5, xpaths.aws.folder_header(my_bucket)) cmd = 'rm -r /mnt/tank/aws_share/my_folder' results = ssh_cmd(cmd, 'root', 'testing', nas_ip) diff --git a/tests/bdd/xpaths.py b/tests/bdd/xpaths.py index e3fda85b11a..7f6157d8d8e 100644 --- a/tests/bdd/xpaths.py +++ b/tests/bdd/xpaths.py @@ -26,6 +26,7 @@ def folder_header(folder_name: str): check_All_Checkbox = '//input[@type="checkbox" and @tabindex="-1"]' create_The_Folder_Button = '//button[contains(@class,"createFolder-object-actions__actions-submit")]' delete_Objects_Button = '//button[contains(@class,"delete-objects__actions-submit")]' + close = '//button[contains(@class,"delete-objects__exit")]' class breadcrumb: From 9c007228f8482e1ca19bb0aa5fc6048d35394ff2 Mon Sep 17 00:00:00 2001 From: ericbsd Date: Mon, 29 Apr 2024 12:26:28 -0300 Subject: [PATCH 10/15] fixed google drive driver.window_handles --- tests/bdd/core/test_NAS_T1141.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/bdd/core/test_NAS_T1141.py b/tests/bdd/core/test_NAS_T1141.py index 7e3b10ffb63..d69b06358e9 100644 --- a/tests/bdd/core/test_NAS_T1141.py +++ b/tests/bdd/core/test_NAS_T1141.py @@ -253,7 +253,7 @@ def open_a_new_tab_navigate_to_google_drive_url_and_input_account_id(driver, dri @then(parsers.parse('enter the "{user_name}" click Next and enter the "{password}" click Next')) def enter_the_user_name_click_Next_and_enter_the_password_click_Next(driver, user_name, password): """enter the click Next and enter the click Next.""" - driver.switch_to.window(driver.window_handles[2]) + driver.switch_to.window(driver.window_handles[1]) if wait_on_element(driver, 3, '//span[text()="Sign in"]'): assert wait_on_element(driver, 5, '//span[text()="Sign in"]') assert wait_on_element(driver, 5, '//input[@id="identifierId"]', 'inputable') @@ -428,7 +428,7 @@ def verify_all_files_are_moved_from_the_dataset_to_the_google_drive_test_folder( results = ssh_cmd(cmd, 'root', 'testing', nas_ip) assert results['result'] is False, results['output'] - driver.switch_to.window(driver.window_handles[2]) + driver.switch_to.window(driver.window_handles[1]) time.sleep(1) driver.refresh() time.sleep(1) @@ -491,7 +491,7 @@ def verify_all_files_are_sync_to_the_dataset_folder(driver, nas_ip): @then('on the Google Drive test folder tab, delete one file') def on_the_google_drive_test_folder_tab_delete_one_file(driver): """on the Google Drive test folder tab, delete one file.""" - driver.switch_to.window(driver.window_handles[2]) + driver.switch_to.window(driver.window_handles[1]) assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') assert wait_on_element(driver, 5, '//div[@data-tooltip="Image: Gloomy_Forest_wallpaper_ForWallpapercom.jpg"]') @@ -597,7 +597,7 @@ def select_push_as_the_direction_then_under_transfer_mode_select_sync(driver): @then('verify all files are sync to the Google Drive test folder tab') def verify_all_files_are_sync_to_the_google_drive_test_folder_tab(driver): """verify all files are sync to the Google Drive test folder tab.""" - driver.switch_to.window(driver.window_handles[2]) + driver.switch_to.window(driver.window_handles[1]) time.sleep(1) driver.refresh() time.sleep(1) From a6a443c659af49e673f7e4dec7902103e3f88c6e Mon Sep 17 00:00:00 2001 From: ericbsd Date: Mon, 29 Apr 2024 16:27:40 -0300 Subject: [PATCH 11/15] fixed more google drive driver.window_handles --- tests/bdd/core/test_NAS_T1141.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/bdd/core/test_NAS_T1141.py b/tests/bdd/core/test_NAS_T1141.py index d69b06358e9..58864339b6c 100644 --- a/tests/bdd/core/test_NAS_T1141.py +++ b/tests/bdd/core/test_NAS_T1141.py @@ -369,7 +369,7 @@ def verify_all_files_are_moved_from_the_google_drive_test_folder_to_the_dataset( cmd = 'test -f /mnt/system/google_drive/music/Mr_Smith_Pequeñas_Guitarras.mp3' results = ssh_cmd(cmd, 'root', 'testing', nas_ip) assert results['result'] is True, results['output'] - driver.switch_to.window(driver.window_handles[2]) + driver.switch_to.window(driver.window_handles[1]) time.sleep(1) driver.refresh() time.sleep(1) @@ -548,7 +548,7 @@ def verify_the_file_is_removed_from_the_dataset_folder(driver, nas_ip): @then('on the Google Drive test folder tab, delete all file') def on_the_google_drive_test_folder_tab_delete_all_file(driver): """on the Google Drive test folder tab, delete all file.""" - driver.switch_to.window(driver.window_handles[2]) + driver.switch_to.window(driver.window_handles[1]) assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') assert wait_on_element(driver, 5, xpaths.google_Drive.music_Folder, 'clickable') @@ -628,7 +628,7 @@ def on_the_dataset_folder_delete_a_file(driver, nas_ip): @then('verify the file is removed from the Google Drive test folder tab') def verify_the_file_is_removed_from_the_google_drive_test_folder_tab(driver): """verify the file is removed from the Google Drive test folder tab.""" - driver.switch_to.window(driver.window_handles[2]) + driver.switch_to.window(driver.window_handles[1]) # loop for 15 second or until music disappear timeout = time.time() + 15 while timeout > time.time(): From 68b72dba6bc7cea306555a01cec054061bea6a07 Mon Sep 17 00:00:00 2001 From: ericbsd Date: Tue, 30 Apr 2024 17:40:24 -0300 Subject: [PATCH 12/15] Fixed Google Drive cloud sync UI test I also rework how selenium start so we can run it on linux. --- tests/bdd/conftest.py | 146 ++++++++++-------------------- tests/bdd/core/test_NAS_T1141.py | 95 +++++++------------ tests/bdd/reusableSeleniumCode.py | 11 ++- 3 files changed, 87 insertions(+), 165 deletions(-) diff --git a/tests/bdd/conftest.py b/tests/bdd/conftest.py index 46edc741810..7b0779468e4 100644 --- a/tests/bdd/conftest.py +++ b/tests/bdd/conftest.py @@ -7,20 +7,22 @@ import time import xpaths from configparser import ConfigParser -from function import get, post +from function import ( + get, + post, + wait_on_element, + wait_on_element_disappear, + is_element_present, + attribute_value_exist +) from platform import system from selenium import webdriver -from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.common.exceptions import ( - ElementClickInterceptedException, - NoSuchElementException, - TimeoutException + ElementClickInterceptedException ) -from selenium.webdriver.common.by import By -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions as ec from selenium.webdriver import ActionChains from selenium.webdriver.common.keys import Keys +from selenium.webdriver.firefox.options import Options # random hostname hostname = f'uitest{"".join(random.choices(string.digits, k=3))}' @@ -70,26 +72,19 @@ def iso_version(): def browser(): - profile = webdriver.FirefoxProfile() - profile.set_preference("browser.download.folderList", 2) - profile.set_preference("browser.download.dir", "/tmp") - # this is the place to add file type to autosave - # application/x-tar is use for .tar - # application/gzip is use for .tgz - profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-tar,application/gzip,application/json") - profile.set_preference("browser.download.manager.showWhenStarting", False) - profile.set_preference("browser.download.alwaysOpenPanel", False) - # browser.link.open_newwindow is frozen 2 the only way to change it is like bellow - profile.DEFAULT_PREFERENCES["frozen"]["browser.link.open_newwindow"] = 3 - binary = '/usr/bin/firefox' if system() == "Linux" else '/usr/local/bin/firefox' - firefox_capabilities = DesiredCapabilities.FIREFOX - firefox_capabilities['marionette'] = True - firefox_capabilities['firefox_profile'] = profile.encoded - firefox_capabilities['binary'] = binary - web_driver = webdriver.Firefox(capabilities=firefox_capabilities) - web_driver.set_window_size(1920, 1080) - # web_driver.implicitly_wait(2) - return web_driver + options = Options() + options.set_preference("browser.download.folderList", 2) + options.set_preference("browser.download.dir", "/tmp") + options.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-tar,application/gzip") + options.set_preference("browser.download.manager.showWhenStarting", False) + options.set_preference("browser.link.open_newwindow", 3) + binary = '/snap/firefox/current/usr/lib/firefox/firefox' if system() == "Linux" else '/usr/local/bin/firefox' + geckodriver = '/snap/firefox/current/usr/lib/firefox/geckodriver' if system() == "Linux" else '/usr/local/bin/geckodriver' + options.binary_location = binary + driver = webdriver.Firefox(options=options, executable_path=geckodriver) + driver.set_window_size(1920, 1080) + driver.implicitly_wait(1) + return driver web_driver = browser() @@ -126,7 +121,7 @@ def pytest_runtest_makereport(item): validation_error = '//h1[normalize-space(text())="ValidationErrors"]' call_error = '//h1[normalize-space(text())="CallError"]' # This looks for plugins install error box and will close the dialog. - if element_exist(error_xpath) or element_exist(failed_xpath) or element_exist(download_xpath) or element_exist(validation_error) or element_exist(call_error): + if is_element_present(web_driver, error_xpath) or is_element_present(web_driver, failed_xpath) or is_element_present(web_driver, download_xpath) or is_element_present(web_driver, validation_error) or is_element_present(web_driver, call_error): web_driver.find_element_by_xpath('//div[@ix-auto="button__backtrace-toggle"]').click() time.sleep(2) save_traceback(traceback_name) @@ -140,7 +135,7 @@ def pytest_runtest_makereport(item): ActionChains(web_driver).send_keys(Keys.ESCAPE).perform() save_screenshot(screenshot_name) # This looks for plugins install error box and will close the dialog. - if element_exist('//mat-dialog-container[contains(.,"Install") and contains(.,"Error")]'): + if is_element_present(web_driver, '//mat-dialog-container[contains(.,"Install") and contains(.,"Error")]'): try: web_driver.find_element_by_xpath('//button[@ix-auto="button__CLOSE"]').click() except ElementClickInterceptedException: @@ -148,7 +143,7 @@ def pytest_runtest_makereport(item): ActionChains(web_driver).send_keys(Keys.ESCAPE).perform() # To make sure we are not stuck on a combobox to stop other test to fail - if element_exist('//mat-option'): + if is_element_present(web_driver, '//mat-option'): ActionChains(web_driver).send_keys(Keys.TAB).perform() # If the current tab is not the initial tab close the tab # and switch to initial tab @@ -183,72 +178,23 @@ def save_traceback(name): traceback_file.close() -def element_exist(xpath): - try: - web_driver.find_element_by_xpath(xpath) - return True - except NoSuchElementException: - return False - - -def wait_on_element(wait, xpath, condition=None): - if condition == 'clickable': - try: - WebDriverWait(web_driver, wait).until(ec.element_to_be_clickable((By.XPATH, xpath))) - return True - except TimeoutException: - return False - if condition == 'presence': - try: - WebDriverWait(web_driver, wait).until(ec.presence_of_element_located((By.XPATH, xpath))) - return True - except TimeoutException: - return False - else: - try: - WebDriverWait(web_driver, wait).until(ec.visibility_of_element_located((By.XPATH, xpath))) - return True - except TimeoutException: - return False - - -def wait_on_element_disappear(wait, xpath): - timeout = time.time() + wait - while time.time() <= timeout: - if not element_exist(xpath): - return True - # this just to slow down the loop - time.sleep(0.1) - else: - return False - - -def attribute_value_exist(xpath, attribute, value): - element = web_driver.find_element_by_xpath(xpath) - class_attribute = element.get_attribute(attribute) - if value in class_attribute: - return True - else: - return False - - def enable_failover(): # make sure to scroll back up the mat-list-item element = web_driver.find_element_by_xpath('//span[contains(.,"root")]') web_driver.execute_script("arguments[0].scrollIntoView();", element) time.sleep(0.5) web_driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__System"]').click() - wait_on_element(5, '//mat-list-item[@ix-auto="option__Failover"]') + wait_on_element(web_driver, 5, '//mat-list-item[@ix-auto="option__Failover"]') web_driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Failover"]').click() - wait_on_element(5, '//h4[contains(.,"Failover Configuration")]') + wait_on_element(web_driver, 5, '//h4[contains(.,"Failover Configuration")]') element = web_driver.find_element_by_xpath('//mat-checkbox[@ix-auto="checkbox__Disable Failover"]') class_attribute = element.get_attribute('class') if 'mat-checkbox-checked' in class_attribute: web_driver.find_element_by_xpath('//mat-checkbox[@ix-auto="checkbox__Disable Failover"]').click() - wait_on_element(5, '//button[@ix-auto="button__SAVE"]') + wait_on_element(web_driver, 5, '//button[@ix-auto="button__SAVE"]') web_driver.find_element_by_xpath('//button[@ix-auto="button__SAVE"]').click() - wait_on_element(5, '//h1[contains(.,"Settings saved")]') - if element_exist('//button[@ix-auto="button__CLOSE"]'): + wait_on_element(web_driver, 5, '//h1[contains(.,"Settings saved")]') + if is_element_present(web_driver, '//button[@ix-auto="button__CLOSE"]'): web_driver.find_element_by_xpath('//button[@ix-auto="button__CLOSE"]').click() time.sleep(1) # make sure to scroll back up the mat-list-item @@ -256,7 +202,7 @@ def enable_failover(): web_driver.execute_script("arguments[0].scrollIntoView();", element) time.sleep(0.5) web_driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Dashboard"]').click() - wait_on_element(90, '//mat-icon[@svgicon="ha_enabled"]') + wait_on_element(web_driver, 90, '//mat-icon[@svgicon="ha_enabled"]') def disable_active_directory(): @@ -273,36 +219,36 @@ def disable_active_directory(): def disable_ldap(): - wait_on_element(5, '//span[contains(.,"root")]') + wait_on_element(web_driver, 5, '//span[contains(.,"root")]') element = web_driver.find_element_by_xpath('//span[contains(.,"root")]') web_driver.execute_script("arguments[0].scrollIntoView();", element) - wait_on_element(7, '//mat-list-item[@ix-auto="option__Directory Services"]', 'clickable') + wait_on_element(web_driver, 7, '//mat-list-item[@ix-auto="option__Directory Services"]', 'clickable') web_driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Directory Services"]').click() - wait_on_element(7, '//mat-list-item[@ix-auto="option__LDAP"]', 'clickable') + wait_on_element(web_driver, 7, '//mat-list-item[@ix-auto="option__LDAP"]', 'clickable') web_driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__LDAP"]').click() - assert wait_on_element(5, '//li[span/a/text()="LDAP"]') - assert wait_on_element(5, '//div[contains(.,"Server Credentials")]') + assert wait_on_element(web_driver, 5, '//li[span/a/text()="LDAP"]') + assert wait_on_element(web_driver, 5, '//div[contains(.,"Server Credentials")]') wait_on_element(5, '//mat-checkbox[@ix-auto="checkbox__Enable"]', 'clickable') - value_exist = attribute_value_exist('//mat-checkbox[@ix-auto="checkbox__Enable"]', 'class', 'mat-checkbox-checked') + value_exist = attribute_value_exist(web_driver, '//mat-checkbox[@ix-auto="checkbox__Enable"]', 'class', 'mat-checkbox-checked') if value_exist: web_driver.find_element_by_xpath('//mat-checkbox[@ix-auto="checkbox__Enable"]').click() wait_on_element(5, '//button[@ix-auto="button__SAVE"]', 'clickable') web_driver.find_element_by_xpath('//button[@ix-auto="button__SAVE"]').click() - assert wait_on_element_disappear(60, '//h6[contains(.,"Please wait")]') - assert wait_on_element(7, '//div[contains(.,"Settings saved.")]') + assert wait_on_element_disappear(web_driver, 60, '//h6[contains(.,"Please wait")]') + assert wait_on_element(web_driver, 7, '//div[contains(.,"Settings saved.")]') def disable_nis(): """click on Directory Services and select NIS, then disable NIS.""" assert wait_on_element(5, xpaths.sideMenu.directory_services, 'clickable') web_driver.find_element_by_xpath(xpaths.sideMenu.directory_services).click() - assert wait_on_element(7, xpaths.sideMenu.directory_services_nis) + assert wait_on_element(web_driver, 7, xpaths.sideMenu.directory_services_nis) web_driver.find_element_by_xpath(xpaths.sideMenu.directory_services_nis).click() - assert wait_on_element(5, '//li[span/a/text()="NIS"]') - assert wait_on_element(5, '//h4[contains(.,"Network Information Service (NIS)")]') - assert wait_on_element(5, xpaths.checkbox.enable, 'clickable') + assert wait_on_element(web_driver, 5, '//li[span/a/text()="NIS"]') + assert wait_on_element(web_driver, 5, '//h4[contains(.,"Network Information Service (NIS)")]') + assert wait_on_element(web_driver, 5, xpaths.checkbox.enable, 'clickable') web_driver.find_element_by_xpath(xpaths.checkbox.enable).click() assert wait_on_element(5, xpaths.button.save, 'clickable') web_driver.find_element_by_xpath(xpaths.button.save).click() - assert wait_on_element_disappear(30, xpaths.popupTitle.please_wait) - assert wait_on_element(7, '//div[contains(.,"Settings saved.")]') + assert wait_on_element_disappear(web_driver, 30, xpaths.popup.please_wait) + assert wait_on_element(web_driver, 7, '//div[contains(.,"Settings saved.")]') diff --git a/tests/bdd/core/test_NAS_T1141.py b/tests/bdd/core/test_NAS_T1141.py index 58864339b6c..c5aa698778b 100644 --- a/tests/bdd/core/test_NAS_T1141.py +++ b/tests/bdd/core/test_NAS_T1141.py @@ -274,34 +274,26 @@ def enter_the_user_name_click_Next_and_enter_the_password_click_Next(driver, use @then(parsers.parse('click on {folder1} then click on the test folder')) def click_on_folder1_then_click_on_the_test_folder(driver, folder1): """click on {folder1} then click on the test folder.""" - # Slow down the double click on the folder - assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') - assert wait_on_element(driver, 5, f'//div[@data-tooltip="Google Drive Folder: {folder1}"]', 'clickable') - time.sleep(1) - action = ActionChains(driver) - action.double_click(driver.find_element_by_xpath(f'//div[@data-tooltip="Google Drive Folder: {folder1}"]')).perform() + assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) + rsc.double_click(driver, f'//div[@data-tooltip="Google Drive Folder: {folder1}"]') assert wait_on_element(driver, 7, f'//div[@data-tooltip="{folder1}" and @role="button"]') - assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') + assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) assert wait_on_element(driver, 7, '//div[@data-tooltip="Google Drive Folder: initial"]', 'clickable') assert wait_on_element(driver, 5, '//div[@data-tooltip="Google Drive Folder: test"]', 'clickable') time.sleep(1) - action = ActionChains(driver) - action.double_click(driver.find_element_by_xpath('//div[@data-tooltip="Google Drive Folder: test"]')).perform() - time.sleep(1) + rsc.double_click(driver, '//div[@data-tooltip="Google Drive Folder: test"]') @then('verify all files are in the test folder') def verify_all_files_are_in_the_test_folder(driver): """verify all files are in the test folder.""" assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') - assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') + assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) assert wait_on_element(driver, 5, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') assert wait_on_element(driver, 5, '//div[@data-tooltip="Image: Gloomy_Forest_wallpaper_ForWallpapercom.jpg"]', 'clickable') - assert wait_on_element(driver, 5, xpaths.google_Drive.music_Folder, 'clickable') - action = ActionChains(driver) - action.double_click(driver.find_element_by_xpath(xpaths.google_Drive.music_Folder)).perform() - assert wait_on_element(driver, 5, '//div[@data-tooltip="music" and @role="button"]') - assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') + rsc.double_click(driver, xpaths.google_Drive.music_Folder) + assert wait_on_element(driver, 7, '//div[@data-tooltip="music" and @role="button"]') + assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) assert wait_on_element(driver, 5, '//div[@data-tooltip="Audio: Mr_Smith_Pequeñas_Guitarras.mp3"]', 'clickable') assert wait_on_element(driver, 5, '//div[@data-tooltip="test" and @data-tooltip-unhoverable="true" and @role="link"]', 'clickable') driver.find_element_by_xpath('//div[@data-tooltip="test" and @data-tooltip-unhoverable="true" and @role="link"]').click() @@ -370,19 +362,14 @@ def verify_all_files_are_moved_from_the_google_drive_test_folder_to_the_dataset( results = ssh_cmd(cmd, 'root', 'testing', nas_ip) assert results['result'] is True, results['output'] driver.switch_to.window(driver.window_handles[1]) - time.sleep(1) - driver.refresh() - time.sleep(1) assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') - assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') + assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) assert wait_on_element(driver, 5, xpaths.google_Drive.music_Folder, 'clickable') - assert not is_element_present(driver, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]') - assert not is_element_present(driver, '//div[@data-tooltip="Image: Gloomy_Forest_wallpaper_ForWallpapercom.jpg"]') - assert wait_on_element(driver, 5, xpaths.google_Drive.music_Folder) - action = ActionChains(driver) - action.double_click(driver.find_element_by_xpath(xpaths.google_Drive.music_Folder)).perform() - assert wait_on_element(driver, 5, '//div[@data-tooltip="music" and @role="button"]') - assert not is_element_present(driver, '//div[@data-tooltip="Audio: Mr_Smith_Pequeñas_Guitarras.mp3"]') + assert wait_on_element_disappear(driver, 10, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]') + assert wait_on_element_disappear(driver, 10, '//div[@data-tooltip="Image: Gloomy_Forest_wallpaper_ForWallpapercom.jpg"]') + rsc.double_click(driver, xpaths.google_Drive.music_Folder) + assert wait_on_element(driver, 7, '//div[@data-tooltip="music" and @role="button"]') + assert wait_on_element_disappear(driver, 10, '//div[@data-tooltip="Audio: Mr_Smith_Pequeñas_Guitarras.mp3"]') assert wait_on_element(driver, 5, '//div[@data-tooltip="test" and @data-tooltip-unhoverable="true" and @role="link"]', 'clickable') driver.find_element_by_xpath('//div[@data-tooltip="test" and @data-tooltip-unhoverable="true" and @role="link"]').click() @@ -429,19 +416,14 @@ def verify_all_files_are_moved_from_the_dataset_to_the_google_drive_test_folder( assert results['result'] is False, results['output'] driver.switch_to.window(driver.window_handles[1]) - time.sleep(1) - driver.refresh() - time.sleep(1) assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') - assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') - assert wait_on_element(driver, 5, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') - assert wait_on_element(driver, 5, '//div[@data-tooltip="Image: Gloomy_Forest_wallpaper_ForWallpapercom.jpg"]', 'clickable') - assert wait_on_element(driver, 5, xpaths.google_Drive.music_Folder, 'clickable') - action = ActionChains(driver) - action.double_click(driver.find_element_by_xpath(xpaths.google_Drive.music_Folder)).perform() + assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) + assert wait_on_element(driver, 10, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') + assert wait_on_element(driver, 10, '//div[@data-tooltip="Image: Gloomy_Forest_wallpaper_ForWallpapercom.jpg"]', 'clickable') + rsc.double_click(driver, xpaths.google_Drive.music_Folder) assert wait_on_element(driver, 5, '//div[@data-tooltip="music" and @role="button"]') - assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') - assert wait_on_element(driver, 5, '//div[@data-tooltip="Audio: Mr_Smith_Pequeñas_Guitarras.mp3"]', 'clickable') + assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) + assert wait_on_element(driver, 10, '//div[@data-tooltip="Audio: Mr_Smith_Pequeñas_Guitarras.mp3"]', 'clickable') assert wait_on_element(driver, 5, '//div[@data-tooltip="test" and @data-tooltip-unhoverable="true" and @role="link"]', 'clickable') driver.find_element_by_xpath('//div[@data-tooltip="test" and @data-tooltip-unhoverable="true" and @role="link"]').click() @@ -493,8 +475,8 @@ def on_the_google_drive_test_folder_tab_delete_one_file(driver): """on the Google Drive test folder tab, delete one file.""" driver.switch_to.window(driver.window_handles[1]) assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') - assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') - assert wait_on_element(driver, 5, '//div[@data-tooltip="Image: Gloomy_Forest_wallpaper_ForWallpapercom.jpg"]') + assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) + assert wait_on_element(driver, 10, '//div[@data-tooltip="Image: Gloomy_Forest_wallpaper_ForWallpapercom.jpg"]') driver.find_element_by_xpath('//div[@data-tooltip="Image: Gloomy_Forest_wallpaper_ForWallpapercom.jpg"]').click() action = ActionChains(driver) action.send_keys(Keys.DELETE).perform() @@ -550,8 +532,8 @@ def on_the_google_drive_test_folder_tab_delete_all_file(driver): """on the Google Drive test folder tab, delete all file.""" driver.switch_to.window(driver.window_handles[1]) assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') - assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') - assert wait_on_element(driver, 5, xpaths.google_Drive.music_Folder, 'clickable') + assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) + assert wait_on_element(driver, 10, xpaths.google_Drive.music_Folder, 'clickable') driver.find_element_by_xpath(xpaths.google_Drive.music_Folder).click() action = ActionChains(driver) action.send_keys(Keys.DELETE).perform() @@ -598,20 +580,16 @@ def select_push_as_the_direction_then_under_transfer_mode_select_sync(driver): def verify_all_files_are_sync_to_the_google_drive_test_folder_tab(driver): """verify all files are sync to the Google Drive test folder tab.""" driver.switch_to.window(driver.window_handles[1]) - time.sleep(1) - driver.refresh() - time.sleep(1) assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') - assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') + assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) assert wait_on_element(driver, 5, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') assert wait_on_element(driver, 5, xpaths.google_Drive.music_Folder, 'clickable') time.sleep(1) # Select driver.find_element_by_xpath(xpaths.google_Drive.music_Folder).click() - action = ActionChains(driver) - action.double_click(driver.find_element_by_xpath(xpaths.google_Drive.music_Folder)).perform() + rsc.double_click(driver, xpaths.google_Drive.music_Folder) assert wait_on_element(driver, 5, '//div[@data-tooltip="music" and @role="button"]') - assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') + assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) assert wait_on_element(driver, 5, '//div[@data-tooltip="Audio: Mr_Smith_Pequeñas_Guitarras.mp3"]', 'clickable') assert wait_on_element(driver, 5, '//div[@data-tooltip="test" and @data-tooltip-unhoverable="true" and @role="link"]', 'clickable') driver.find_element_by_xpath('//div[@data-tooltip="test" and @data-tooltip-unhoverable="true" and @role="link"]').click() @@ -629,19 +607,10 @@ def on_the_dataset_folder_delete_a_file(driver, nas_ip): def verify_the_file_is_removed_from_the_google_drive_test_folder_tab(driver): """verify the file is removed from the Google Drive test folder tab.""" driver.switch_to.window(driver.window_handles[1]) - # loop for 15 second or until music disappear - timeout = time.time() + 15 - while timeout > time.time(): - driver.refresh() - time.sleep(1) - assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') - assert wait_on_element(driver, 5, xpaths.google_Drive.name_Sort, 'clickable') - assert wait_on_element(driver, 7, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') - if not is_element_present(driver, xpaths.google_Drive.music_Folder): - assert not is_element_present(driver, xpaths.google_Drive.music_Folder) - break - else: - assert not is_element_present(driver, xpaths.google_Drive.music_Folder) + assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') + assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) + assert wait_on_element(driver, 7, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') + assert wait_on_element_disappear(driver, 15, xpaths.google_Drive.music_Folder) # clean the test folder on box tab before closing the tab. assert wait_on_element(driver, 5, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') driver.find_element_by_xpath('//div[@data-tooltip="PDF: Explaining_BSD.pdf"]').click() @@ -652,6 +621,4 @@ def verify_the_file_is_removed_from_the_google_drive_test_folder_tab(driver): driver.find_element_by_xpath('//button[*/text()="Move to trash"]').click() assert wait_on_element_disappear(driver, 10, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]') driver.close() - driver.switch_to.window(driver.window_handles[1]) - driver.close() driver.switch_to.window(driver.window_handles[0]) diff --git a/tests/bdd/reusableSeleniumCode.py b/tests/bdd/reusableSeleniumCode.py index 62c2d4adf0c..850accc273e 100644 --- a/tests/bdd/reusableSeleniumCode.py +++ b/tests/bdd/reusableSeleniumCode.py @@ -5,6 +5,7 @@ wait_on_element, attribute_value_exist ) +from selenium.webdriver import ActionChains def click_The_Summit_Button(driver: classmethod): @@ -12,6 +13,14 @@ def click_The_Summit_Button(driver: classmethod): driver.find_element_by_xpath(xpaths.button.summit).click() +def double_click(driver: classmethod, xpath: str, wait: bool = True): + assert wait_on_element(driver, 10, xpath) + driver.find_element_by_xpath(xpath).click() + action = ActionChains(driver) + action.double_click(driver.find_element_by_xpath(xpath)).perform() + time.sleep(1) + + def wait_For_The_Tab_To_Close(driver: classmethod): for num in range(10): if len(driver.window_handles) == 1: @@ -22,7 +31,7 @@ def wait_For_The_Tab_To_Close(driver: classmethod): def scroll_To(driver: classmethod, xpath: str): - assert wait_on_element(driver, 5, xpath) + assert wait_on_element(driver, 5, xpath, 'clickable') element = driver.find_element_by_xpath(xpath) driver.execute_script("arguments[0].scrollIntoView();", element) time.sleep(0.2) From 7c706fdd311d1dc7838496024a4e0985af1f34a9 Mon Sep 17 00:00:00 2001 From: ericbsd Date: Wed, 1 May 2024 09:00:46 -0300 Subject: [PATCH 13/15] Added longer wait for element --- tests/bdd/conftest.py | 1 - tests/bdd/core/test_NAS_T1141.py | 6 +++--- tests/bdd/core/test_NAS_T1143.py | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/bdd/conftest.py b/tests/bdd/conftest.py index 7b0779468e4..5fdba01d16c 100644 --- a/tests/bdd/conftest.py +++ b/tests/bdd/conftest.py @@ -83,7 +83,6 @@ def browser(): options.binary_location = binary driver = webdriver.Firefox(options=options, executable_path=geckodriver) driver.set_window_size(1920, 1080) - driver.implicitly_wait(1) return driver diff --git a/tests/bdd/core/test_NAS_T1141.py b/tests/bdd/core/test_NAS_T1141.py index c5aa698778b..94e7d5164fe 100644 --- a/tests/bdd/core/test_NAS_T1141.py +++ b/tests/bdd/core/test_NAS_T1141.py @@ -418,10 +418,10 @@ def verify_all_files_are_moved_from_the_dataset_to_the_google_drive_test_folder( driver.switch_to.window(driver.window_handles[1]) assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) - assert wait_on_element(driver, 10, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') - assert wait_on_element(driver, 10, '//div[@data-tooltip="Image: Gloomy_Forest_wallpaper_ForWallpapercom.jpg"]', 'clickable') + assert wait_on_element(driver, 15, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') + assert wait_on_element(driver, 15, '//div[@data-tooltip="Image: Gloomy_Forest_wallpaper_ForWallpapercom.jpg"]', 'clickable') rsc.double_click(driver, xpaths.google_Drive.music_Folder) - assert wait_on_element(driver, 5, '//div[@data-tooltip="music" and @role="button"]') + assert wait_on_element(driver, 7, '//div[@data-tooltip="music" and @role="button"]') assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) assert wait_on_element(driver, 10, '//div[@data-tooltip="Audio: Mr_Smith_Pequeñas_Guitarras.mp3"]', 'clickable') assert wait_on_element(driver, 5, '//div[@data-tooltip="test" and @data-tooltip-unhoverable="true" and @role="link"]', 'clickable') diff --git a/tests/bdd/core/test_NAS_T1143.py b/tests/bdd/core/test_NAS_T1143.py index c49fd175b02..34c327d868f 100644 --- a/tests/bdd/core/test_NAS_T1143.py +++ b/tests/bdd/core/test_NAS_T1143.py @@ -128,9 +128,9 @@ def click_on_Browser_Files_click_on_bucket_then_click_on_the_test_folder(driver, assert wait_on_element(driver, 10, '//span[text()="B2 Cloud Storage Buckets"]') assert wait_on_element(driver, 7, '//a[text()="Browse Files"]', 'clickable') driver.find_element_by_xpath('//a[text()="Browse Files"]').click() - assert wait_on_element(driver, 7, '//h1[text()="Browse Files"]') - assert wait_on_element(driver, 5, '//div[@class="b2-browse-crumbs" and contains(.,"Buckets")]') - assert wait_on_element(driver, 5, f'//span[contains(text(),"{bucket} ")]', 'clickable') + assert wait_on_element(driver, 10, '//h1[text()="Browse Files"]') + assert wait_on_element(driver, 10, '//div[@class="b2-browse-crumbs" and contains(.,"Buckets")]') + assert wait_on_element(driver, 10, f'//span[contains(text(),"{bucket} ")]', 'clickable') driver.find_element_by_xpath(f'//span[contains(text(),"{bucket} ")]').click() assert wait_on_element(driver, 10, f'//a[text()="{bucket}"]', 'clickable') time.sleep(1) From 91deb9a4602c1baa443e595284a1f87155589383 Mon Sep 17 00:00:00 2001 From: ericbsd Date: Wed, 1 May 2024 11:32:09 -0300 Subject: [PATCH 14/15] Added longer wait for element --- tests/bdd/core/test_NAS_T1141.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/bdd/core/test_NAS_T1141.py b/tests/bdd/core/test_NAS_T1141.py index 94e7d5164fe..0a0a0a037cd 100644 --- a/tests/bdd/core/test_NAS_T1141.py +++ b/tests/bdd/core/test_NAS_T1141.py @@ -580,12 +580,10 @@ def select_push_as_the_direction_then_under_transfer_mode_select_sync(driver): def verify_all_files_are_sync_to_the_google_drive_test_folder_tab(driver): """verify all files are sync to the Google Drive test folder tab.""" driver.switch_to.window(driver.window_handles[1]) - assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') - assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) - assert wait_on_element(driver, 5, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') - assert wait_on_element(driver, 5, xpaths.google_Drive.music_Folder, 'clickable') - time.sleep(1) - # Select + assert wait_on_element(driver, 10, '//div[@data-tooltip="test" and @role="button"]') + assert wait_on_element(driver, 15, xpaths.google_Drive.name_Sort) + assert wait_on_element(driver, 10, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') + assert wait_on_element(driver, 10, xpaths.google_Drive.music_Folder, 'clickable') driver.find_element_by_xpath(xpaths.google_Drive.music_Folder).click() rsc.double_click(driver, xpaths.google_Drive.music_Folder) assert wait_on_element(driver, 5, '//div[@data-tooltip="music" and @role="button"]') From 01381774bf6ef18c6d96a6040770913e40201518 Mon Sep 17 00:00:00 2001 From: ericbsd Date: Wed, 1 May 2024 14:08:00 -0300 Subject: [PATCH 15/15] Adding long ger wait for some GD elements --- tests/bdd/core/test_NAS_T1141.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/bdd/core/test_NAS_T1141.py b/tests/bdd/core/test_NAS_T1141.py index 0a0a0a037cd..d23784130eb 100644 --- a/tests/bdd/core/test_NAS_T1141.py +++ b/tests/bdd/core/test_NAS_T1141.py @@ -605,9 +605,9 @@ def on_the_dataset_folder_delete_a_file(driver, nas_ip): def verify_the_file_is_removed_from_the_google_drive_test_folder_tab(driver): """verify the file is removed from the Google Drive test folder tab.""" driver.switch_to.window(driver.window_handles[1]) - assert wait_on_element(driver, 7, '//div[@data-tooltip="test" and @role="button"]') - assert wait_on_element(driver, 7, xpaths.google_Drive.name_Sort) - assert wait_on_element(driver, 7, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') + assert wait_on_element(driver, 10, '//div[@data-tooltip="test" and @role="button"]') + assert wait_on_element(driver, 15, xpaths.google_Drive.name_Sort) + assert wait_on_element(driver, 10, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable') assert wait_on_element_disappear(driver, 15, xpaths.google_Drive.music_Folder) # clean the test folder on box tab before closing the tab. assert wait_on_element(driver, 5, '//div[@data-tooltip="PDF: Explaining_BSD.pdf"]', 'clickable')