diff --git a/Doczy.AI_Automation/config/env.yaml b/Doczy.AI_Automation/config/env.yaml index 398fe69..6b72106 100644 --- a/Doczy.AI_Automation/config/env.yaml +++ b/Doczy.AI_Automation/config/env.yaml @@ -5,7 +5,7 @@ environment: password: "" contract_files_path: "C:\\Ankit\\Marked Up PDFs\\test\\" contract_files: - - '050540697 Deepak Nanda 2017 PHSP MU.pdf' + - '050540697 Deepak Nanda 2017 PHSP MU1.pdf' - '2014-01-01 United Health Centers San Joaquin AMD MU (1).pdf' - '2019 06 01 Dr Raul Rivera & Associates (Amend 1)_MU.pdf' - 'Bay Ridge Medical Imaging Universal (113045841) MU.pdf' diff --git a/Doczy.AI_Automation/pages/Email_sign_in_page.py b/Doczy.AI_Automation/pages/Email_sign_in_page.py index 1eb01a3..27c6bb6 100644 --- a/Doczy.AI_Automation/pages/Email_sign_in_page.py +++ b/Doczy.AI_Automation/pages/Email_sign_in_page.py @@ -1,5 +1,5 @@ from selenium.webdriver.common.by import By -from utils.common_methods import get_element, get_clickable_element +from utils.element_related_methods import get_element, get_clickable_element class Email_sign_in_page: diff --git a/Doczy.AI_Automation/pages/Password_sign_in_page.py b/Doczy.AI_Automation/pages/Password_sign_in_page.py index 0bffbee..f92df4c 100644 --- a/Doczy.AI_Automation/pages/Password_sign_in_page.py +++ b/Doczy.AI_Automation/pages/Password_sign_in_page.py @@ -1,6 +1,6 @@ from selenium.webdriver.common.by import By -from utils.common_methods import get_clickable_element, get_element +from utils.element_related_methods import get_clickable_element, get_element class Password_sign_in_page: diff --git a/Doczy.AI_Automation/pages/Pre_sign_in_page.py b/Doczy.AI_Automation/pages/Pre_sign_in_page.py index 099d589..bc86910 100644 --- a/Doczy.AI_Automation/pages/Pre_sign_in_page.py +++ b/Doczy.AI_Automation/pages/Pre_sign_in_page.py @@ -2,7 +2,7 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as ec -from utils.common_methods import get_clickable_element +from utils.element_related_methods import get_clickable_element class Pre_sign_in_page: diff --git a/Doczy.AI_Automation/pages/Remember_sign_in_page.py b/Doczy.AI_Automation/pages/Remember_sign_in_page.py index 631c8a0..d7c9fd2 100644 --- a/Doczy.AI_Automation/pages/Remember_sign_in_page.py +++ b/Doczy.AI_Automation/pages/Remember_sign_in_page.py @@ -1,6 +1,6 @@ from selenium.webdriver.common.by import By -from utils.common_methods import get_clickable_element +from utils.element_related_methods import get_clickable_element class Remember_sign_in_page: diff --git a/Doczy.AI_Automation/pages/interface_0_page_objects.py b/Doczy.AI_Automation/pages/interface_0_page_objects.py index 66a0f80..09cbf11 100644 --- a/Doczy.AI_Automation/pages/interface_0_page_objects.py +++ b/Doczy.AI_Automation/pages/interface_0_page_objects.py @@ -1,23 +1,22 @@ import random import time +from selenium.common import InvalidArgumentException from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait -from utils.common_methods import get_clickable_element, get_element, get_invisible_element +from utils.element_related_methods import get_clickable_element, get_element, get_invisible_element from utils.logger import get_logger class Interface_0: logger = get_logger() + p_element = None def __init__(self, driver): self.driver = driver self.client_name_dropdown = get_clickable_element(driver, By.XPATH, '/html/body/div/div[1]/div[1]/div/div/div/section/div[1]/div/div/div/div[3]/div[2]/div/div/div/div/div/div/div') - # self.file_input = self.driver.find_element(By.XPATH, "//input[@type='file']") - - self.create_batch_btn = self.driver.find_element(By.XPATH, "//div[@data-testid='stButton']/button[@data-testid='baseButton-secondary']") def select_client(self): self.client_name_dropdown.click() @@ -26,29 +25,36 @@ class Interface_0: random_number = random.randint(1, len(client_list) - 1) time.sleep(1) self.logger.info(f"Selected Client Name: {client_list[random_number].text}") + client_name = client_list[random_number].text client_list[random_number].click() time.sleep(5) + return client_name def upload_files(self, config): # file_input = self.driver.find_element(By.XPATH, "//input[@type='file']") - file_input = get_invisible_element(self.driver, By.XPATH, "//input[@type='file']") - contract_files = config["contract_files"] - random_count = random.randint(1, len(contract_files)) - random_elements = random.sample(contract_files, random_count) - contracts = f'\n{config['contract_files_path']}'.join(random_elements) - self.logger.info(f"Selected Contract File Name: {', '.join(random_elements)}") - file_input.send_keys(f"{config['contract_files_path']}{contracts}") - time.sleep(1) - WebDriverWait(self.driver, timeout=50).until( - lambda browser: len(browser.find_elements(By.XPATH, '//div[@role="progressbar"]')) == 0 - ) - time.sleep(5) + try: + file_input = get_invisible_element(self.driver, By.XPATH, "//input[@type='file']") + contract_files = config["contract_files"] + random_count = random.randint(1, len(contract_files)) + random_elements = random.sample(contract_files, random_count) + contracts = f'\n{config['contract_files_path']}'.join(random_elements) + self.logger.info(f"Selected Contract File Name: {', '.join(random_elements)}") + file_input.send_keys(f"{config['contract_files_path']}{contracts}") + time.sleep(1) + WebDriverWait(self.driver, timeout=50).until( + lambda browser: len(browser.find_elements(By.XPATH, '//div[@role="progressbar"]')) == 0 + ) + time.sleep(5) + except InvalidArgumentException: + self.logger.info(f"File not found in test folder{', '.join(random_elements)}") + except: + self.logger.info(f"Exception occur") def create_batch(self): create_batch_btn = self.driver.find_element(By.XPATH, "//div[@data-testid='stButton']/button[@data-testid='baseButton-secondary']") create_batch_btn.click() self.logger.info("Creating batch") time.sleep(3) - p_element = get_element(self.driver, By.XPATH, "//p[starts-with(., 'batch')]")#self.driver.find_element("//p[starts-with(., 'batch')]") - self.logger.info(f"Created batch with Batch ID: {p_element.text}") + self.p_element = get_element(self.driver, By.XPATH, "//p[starts-with(., 'batch')]") + time.sleep(3) diff --git a/Doczy.AI_Automation/pages/interface_1_page_objects.py b/Doczy.AI_Automation/pages/interface_1_page_objects.py new file mode 100644 index 0000000..9cea7ea --- /dev/null +++ b/Doczy.AI_Automation/pages/interface_1_page_objects.py @@ -0,0 +1,75 @@ +import random +import time + +from selenium.common import InvalidArgumentException +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait + +from utils.element_related_methods import get_clickable_element, get_element, get_invisible_element +from utils.logger import get_logger + + +class Interface_1: + logger = get_logger() + selected_batch = '' + result_message = None + p_element = None + def __init__(self, driver): + self.driver = driver + self.client_name_dropdown = get_clickable_element(driver, By.XPATH, + '/html/body/div/div[1]/div[1]/div/div/div/section/div[1]/div/div/div/div[3]/div[2]/div/div/div/div/div/div/div') + + def select_client(self): + self.client_name_dropdown.click() + client_list = self.driver.find_elements(By.XPATH, "//li") + assert len(client_list) > 0 + random_number = random.randint(1, len(client_list) - 1) + time.sleep(1) + self.logger.info(f"Selected Client Name: {client_list[random_number].text}") + client_list[random_number].click() + time.sleep(5) + + def select_batch(self): + batch_id = get_clickable_element(self.driver, By.XPATH, '/html/body/div[1]/div[1]/div[1]/div/div/div/section/div[1]/div/div/div/div[3]/div[2]/div/div/div/div/div/div/div') + batch_id.click() + batch_id_list = self.driver.find_elements(By.XPATH, "//li") + assert len(batch_id_list) > 0 + random_number = random.randint(2, len(batch_id_list) - 1) + self.selected_batch = batch_id_list[random_number].text + self.logger.info(f"Selected Batch: {batch_id_list[random_number].text}") + batch_id_list[random_number].click() + time.sleep(5) + + def check_group_no(self): + checkbox_list = self.driver.find_elements(By.XPATH, "//div[@data-testid='stCheckbox']") + assert len(checkbox_list) > 0 + random_number = random.randint(0, len(checkbox_list) - 1) + random_elements = random.sample(checkbox_list, random_number) + checked_groups = '' + for checkbox in random_elements: + checkbox.click() + checked_groups = f'{checked_groups}{checkbox.text}, ' + self.logger.info(f"checked Group No.: {checked_groups[:-2]}") + time.sleep(5) + + def click_read_the_contracts_from_path(self): + read_the_contracts_from_path_btn = get_clickable_element(self.driver, By.XPATH, '/html/body/div[1]/div[1]/div[1]/div/div/div/section/div[1]/div/div/div/div[6]/div/button') + read_the_contracts_from_path_btn.click() + time.sleep(5) + + def check_table_contain(self): + result_table = self.driver.find_element(By.XPATH, "//table[@aria-colcount='9']") + rows = result_table.find_elements(By.XPATH, ".//tbody/tr") + if len(rows) > 0: + self.logger.info(f"{len(rows)} contracts are read from batch: {self.selected_batch}") + assert True + else: + assert False + time.sleep(5) + + def click_run_doczy_ai_pipeline(self): + run_doczy_ai_pipeline_btn = get_clickable_element(self.driver, By.XPATH, '/html/body/div[1]/div[1]/div[1]/div/div/div/section/div[1]/div/div/div/div[11]/div[2]/div/div/div/div/div/button') + run_doczy_ai_pipeline_btn.click() + time.sleep(3) + self.result_message = get_element(self.driver, By.XPATH, "//p[starts-with(., 'Success')]") + time.sleep(3) diff --git a/Doczy.AI_Automation/pytest.ini b/Doczy.AI_Automation/pytest.ini index c15b014..b3942f3 100644 --- a/Doczy.AI_Automation/pytest.ini +++ b/Doczy.AI_Automation/pytest.ini @@ -1,2 +1,2 @@ [pytest] -addopts = --html=reports/test_report.html \ No newline at end of file +addopts = --html=reports/test_report.html --json=reports/test_report.json \ No newline at end of file diff --git a/Doczy.AI_Automation/reports/test_report.html b/Doczy.AI_Automation/reports/test_report.html index fff4dfe..04a51cc 100644 --- a/Doczy.AI_Automation/reports/test_report.html +++ b/Doczy.AI_Automation/reports/test_report.html @@ -7,7 +7,7 @@
Report generated on 09-May-2024 at 17:29:24 by pytest-html +
Report generated on 20-May-2024 at 17:08:29 by pytest-html v4.1.1
5 tests took 00:03:02.
+10 tests took 00:09:34.
(Un)check the boxes to filter the results.