def test_login_chrome(self, browser, env): driver = browser # Create Time Stamp Variable (using Date Time Generator Class in utilities) dg = date_time_generator() time_stamp = dg.return_time_stamp() # This section reads in values from csv file using Pandas Library # Declare Test Case ID test_case_ID = 'QTML-T54' # Declare csv directory df = pd.read_csv(csv_directory) # print(df) # Select Row where "Test_Case_ID" Column Matches the test_case_ID declared above (Line 31) # This is the row that contains the data values for this test scenario test_case_row = df.loc[df.Test_Case_ID == test_case_ID] # print(test_case_row) # Read in Values from "test_case_row" object test_scenario = test_case_row['Test_Scenario'].values[0] username = test_case_row['User'].values[0] password = test_case_row['Password'].values[0] browser = test_case_row['Browser'].values[0] account_number = test_case_row['account_number'].values[0] rep_code = test_case_row['rep_code'].values[0] test_data1 = test_case_row['test_data1'].values[0] test_data2 = test_case_row['test_data_2'].values[0] control_point_1 = test_case_row['control_point_1'].values[0] control_point_2 = test_case_row['control_point_2'].values[0] control_point_3 = test_case_row['control_point_3'].values[0] control_point_4 = test_case_row['control_point_4'].values[0] # To DEBUG, Uncomment this NEXT line AND Comment lines 13, 15 and 18. Also, SHIFT + TAB lines 17 - 86 (This will remove indents) # driver = webdriver.Chrome(str(CONFIG_PATH / 'chromedriver.exe')) ## Select Appropriate URL based on the Environment Value (env) # env = "UAT" baseURL = Environments_BICL.return_environments(env) # baseURL = "https://beta.bi.dev.wedbus.com" driver.get(baseURL) driver.maximize_window() time.sleep(5) # Login to Site lp = LoginPage(driver) # Verify if page loads (username_field should be clickable), if not, throw exception and take screenshot lp.verify_username_field_displays(test_case_ID, browser, env, time_stamp) lp.login(username, password) lp.click_login_button() time.sleep(10) gp = generic_page(driver) # Take Screenshot 1 screenshot_number = "1" time_stamp_1 = dg.return_time_stamp() gp.take_screenshot(test_case_ID, browser, control_point_1, screenshot_number, env, time_stamp_1) dp = default_page(driver) # Timeout method for page to load, timeout set to 30 seconds gp.verify_page_loads(test_case_ID, browser, env, time_stamp) time.sleep(15) # Enter Account Number and click Search dp.enter_account_number_search(account_number) time.sleep(15) # Click Tools dp.click_tools_icon() time.sleep(15) t = tools(driver) # Click FOLIODX t.click_foliodx() time.sleep(5) # switch to opened window driver.switch_to.window(driver.window_handles[1]) time.sleep(5) # Take Screenshot 2 screenshot_number = "2" time_stamp_2 = dg.return_time_stamp() gp.take_screenshot(test_case_ID, browser, control_point_2, screenshot_number, env, time_stamp_2) time.sleep(5) # Close new Window driver.close() # Switch to First Window (Broker Insight) driver.switch_to.window(driver.window_handles[0]) # LOGOUT Section # Force Logout # Logout Workaround # Get current URL string, find base URL # Add logout_string to base_url to force logout current_url = driver.current_url slashparts = current_url.split('/') # Now join back the first three sections 'http:', '' and 'example.com' base_url = '/'.join(slashparts[:3]) + '/' logout_string = "user/login?logout=1" logout_screen = base_url + logout_string # Navigate to Logout Screen driver.get(logout_screen) # Take Screenshot 3 screenshot_number = "3" time_stamp_3 = dg.return_time_stamp() gp.take_screenshot(test_case_ID, browser, control_point_3, screenshot_number, env, time_stamp_3) time.sleep(5) # Close Browser driver.quit()
def test_login_chrome(self, browser, env): driver = browser # Create Time Stamp Variable (using Date Time Generator Class in utilities) dg = date_time_generator() time_stamp = dg.return_time_stamp() # This section reads in values from csv file using Pandas Library # Declare Test Case ID test_case_ID = 'QTML-T350' # Declare csv directory df = pd.read_csv(csv_directory) # print(df) # Select Row where "Test_Case_ID" Column Matches the test_case_ID declared above (Line 31) # This is the row that contains the data values for this test scenario test_case_row = df.loc[df.Test_Case_ID == test_case_ID] # print(test_case_row) # Read in Values from "test_case_row" object test_scenario = test_case_row['Test_Scenario'].values[0] username = test_case_row['User'].values[0] password = test_case_row['Password'].values[0] browser = test_case_row['Browser'].values[0] account_number = test_case_row['account_number'].values[0] rep_code = test_case_row['rep_code'].values[0] test_data1 = test_case_row['test_data1'].values[0] test_data2 = test_case_row['test_data_2'].values[0] control_point_1 = test_case_row['control_point_1'].values[0] control_point_2 = test_case_row['control_point_2'].values[0] control_point_3 = test_case_row['control_point_3'].values[0] control_point_4 = test_case_row['control_point_4'].values[0] # To DEBUG, Uncomment this NEXT line AND Comment lines 13, 15 and 18. Also, SHIFT + TAB lines 17 - 86 (This will remove indents) # driver = webdriver.Chrome(str(CONFIG_PATH / 'chromedriver.exe')) ## Select Appropriate URL based on the Environment Value (env) # env = "UAT" baseURL = Environments_BICL.return_environments(env) # baseURL = "https://beta.bi.dev.wedbus.com" driver.get(baseURL) driver.maximize_window() time.sleep(5) # Login to Site lp = LoginPage(driver) # Verify if page loads (username_field should be clickable), if not, throw exception and take screenshot lp.verify_username_field_displays(test_case_ID, browser, env, time_stamp) lp.login(username, password) lp.click_login_button() time.sleep(10) gp = generic_page(driver) # Take Screenshot 1 screenshot_number = "1" time_stamp_1 = dg.return_time_stamp() gp.take_screenshot(test_case_ID, browser, control_point_1, screenshot_number, env, time_stamp_1) dp = default_page(driver) # Timeout method for page to load, timeout set to 30 seconds gp.verify_page_loads(test_case_ID, browser, env, time_stamp) time.sleep(15) # Click Tools dp.click_tools_icon() time.sleep(15) # Take Screenshot 2 screenshot_number = "2" time_stamp_2 = dg.return_time_stamp() gp.take_screenshot(test_case_ID, browser, control_point_2, screenshot_number, env, time_stamp_2) t = tools(driver) time.sleep(5) # Click Client Search (Should already display by default t.click_client_search() time.sleep(5) # Validate that correct panel displays (correct title displays on screen) gp.validate_correct_text_displays(test_data1, test_case_ID, browser, env, time_stamp) time.sleep(5) # Click User Drop Down (on BICL Default Page) dp.click_user_drop_down() udd = user_drop_down(driver) udd.click_logout() # Take Screenshot 3 screenshot_number = "3" time_stamp_3 = dg.return_time_stamp() gp.take_screenshot(test_case_ID, browser, control_point_3, screenshot_number, env, time_stamp_3) time.sleep(5) # Close Browser driver.quit()
def test_login_chrome(self, browser, env): driver = browser # Create Time Stamp Variable (using Date Time Generator Class in utilities) dg = date_time_generator() time_stamp = dg.return_time_stamp() # Create a valid date (1 month ago) date_previous_month = dg.return_date_one_month_ago() dv = date_validator() valid_date = dv.return_valid_date(date_previous_month).strftime("%m-%d-%Y") # This section reads in values from csv file using Pandas Library # Declare Test Case ID test_case_ID = 'QTML-T156_b' # Declare csv directory df = pd.read_csv(csv_directory) # print(df) # Select Row where "Test_Case_ID" Column Matches the test_case_ID declared above (Line 31) # This is the row that contains the data values for this test scenario test_case_row = df.loc[df.Test_Case_ID == test_case_ID] # print(test_case_row) # Read in Values from "test_case_row" object test_scenario = test_case_row['Test_Scenario'].values[0] username = test_case_row['User'].values[0] password = test_case_row['Password'].values[0] browser = test_case_row['Browser'].values[0] account_number = test_case_row['account_number'].values[0] rep_code = test_case_row['rep_code'].values[0] test_data1 = test_case_row['test_data1'].values[0] test_data2 = test_case_row['test_data_2'].values[0] control_point_1 = test_case_row['control_point_1'].values[0] control_point_2 = test_case_row['control_point_2'].values[0] control_point_3 = test_case_row['control_point_3'].values[0] control_point_4 = test_case_row['control_point_4'].values[0] # To DEBUG, Uncomment this NEXT line AND Comment lines 13, 15 and 18. Also, SHIFT + TAB lines 17 - 86 (This will remove indents) # driver = webdriver.Chrome(str(CONFIG_PATH / 'chromedriver.exe')) ## Select Appropriate URL based on the Environment Value (env) # env = "UAT" baseURL_Admin = Environments_ADMIN.return_environments(env) # baseURL = "https://beta.bi.dev.wedbus.com" # Launch Admin Site driver.get(baseURL_Admin) driver.maximize_window() # Workaround to Navigate to User Admin Screen current_url = driver.current_url slashparts = current_url.split('/') # Now join back the first three sections 'http:', '' and 'example.com' base_url = '/'.join(slashparts[:3]) + '/' manage_user_string = "ManageUser.aspx" manage_user_screen = base_url + manage_user_string # Navigate to Manage User Screen driver.get(manage_user_screen) time.sleep(5) adm = admin(driver) # search for user account adm.enter_user_account_click_search(username) time.sleep(5) adm.click_first_name_tab_3_times() time.sleep(5) # Change Office Code to CA adm.update_office_code_new(rep_code) time.sleep(5) # click Save adm.click_save() # Take screenshot, save to utilities/test_results/screenshots screenshot_1 = test_case_ID + "_" + browser + "_" + env + "_" + "screenshot_1" + "_" + control_point_1 + "_" + time_stamp + ".png" saved_screenshot_location_1 = str(screenshot_directory / screenshot_1) driver.get_screenshot_as_file(saved_screenshot_location_1) # Set to at least 20 time.sleep(20) # Launch BICL Site # env = "UAT" baseURL_BICL = Environments_BICL.return_environments(env) # baseURL = "https://beta.bi.dev.wedbus.com" time.sleep(1) driver.get(baseURL_BICL) driver.maximize_window() # Login to Site lp = LoginPage(driver) # Verify if page loads (username_field should be clickable), if not, throw exception and take screenshot try: username_field = lp.Page_Elements().driver.find_element_by_id("UserName") username_field.click() except NoSuchElementException: screenshot_name = "FAIL" + "_" + test_case_ID + "_" + browser + "_" + env + "_" + time_stamp + ".png" saved_screenshot_location = str(screenshot_directory / screenshot_name) driver.get_screenshot_as_file(saved_screenshot_location) raise lp.login(username, password) lp.click_login_button() time.sleep(10) # Take screenshot after login and save to utilities/test_results/screenshots screenshot_2 = test_case_ID + "_" + browser + "_" + env + "_" + "screenshot_2" + "_" + control_point_2 + "_" + time_stamp + ".png" saved_screenshot_location_2 = str(screenshot_directory / screenshot_2) driver.get_screenshot_as_file(saved_screenshot_location_2) dp = default_page(driver) # Timeout method for page to load, timeout set to 30 seconds try: driver.set_page_load_timeout(30) except: screenshot_name = "FAIL" + "_" + test_case_ID + "_" + browser + "_" + env + "_" + time_stamp + ".png" saved_screenshot_location = str(screenshot_directory / screenshot_name) driver.get_screenshot_as_file(saved_screenshot_location) raise time.sleep(10) # Enter Account Number and click Search dp.enter_account_number_search(account_number) time.sleep(5) # Click Tools dp.click_tools_icon() tls = tools(driver) time.sleep(10) # Confirm that Firelight Displays tls.confirm_firelight_displays(test_case_ID, browser, env, time_stamp) time.sleep(1) # Take screenshot save to utilities/test_results/screenshots screenshot_3 = test_case_ID + "_" + browser + "_" + env + "_" + "screenshot_3" + "_" + control_point_3 + "_" + time_stamp + ".png" saved_screenshot_location_3 = str(screenshot_directory / screenshot_3) driver.get_screenshot_as_file(saved_screenshot_location_3) errorDisplays = False # Check if Error Modal Displays if len(driver.find_elements(By.XPATH, "/html/body/div[1]/div/div/div/button")) > 0: errorDisplays = True else: print("No Error") time.sleep(1) # Try / Except Block to test if errorDisplays False # If True, throw exception, take screenshot and FAIL test try: assert errorDisplays is False except AssertionError: screenshot_name = "FAIL" + "_" + test_case_ID + "_" + browser + "_" + env + "_" + time_stamp + ".png" saved_screenshot_location = str(screenshot_directory / screenshot_name) driver.get_screenshot_as_file(saved_screenshot_location) raise time.sleep(1) # Take screenshot save to utilities/test_results/screenshots screenshot_4 = test_case_ID + "_" + browser + "_" + env + "_" + "screenshot_4" + "_" + control_point_4 + "_" + time_stamp + ".png" saved_screenshot_location_4 = str(screenshot_directory / screenshot_4) driver.get_screenshot_as_file(saved_screenshot_location_4) # LOGOUT Section # TODO: Move Logout methods to Logout Class # Force Logout # Logout Workaround # Get current URL string, find base URL # Add logout_string to base_url to force logout current_url = driver.current_url slashparts = current_url.split('/') # Now join back the first three sections 'http:', '' and 'example.com' base_url = '/'.join(slashparts[:3]) + '/' logout_string = "user/login?logout=1" logout_screen = base_url + logout_string # Navigate to Logout Screen driver.get(logout_screen)
def test_login_chrome(self, browser, env): driver = browser # Create Time Stamp Variable (using Date Time Generator Class in utilities) dg = date_time_generator() time_stamp = dg.return_time_stamp() # This section reads in values from csv file using Pandas Library # Declare Test Case ID test_case_ID = 'QTML-T216' # Declare csv directory df = pd.read_csv(csv_directory) # print(df) # Select Row where "Test_Case_ID" Column Matches the test_case_ID declared above (Line 31) # This is the row that contains the data values for this test scenario test_case_row = df.loc[df.Test_Case_ID == test_case_ID] # print(test_case_row) # Read in Values from "test_case_row" object test_scenario = test_case_row['Test_Scenario'].values[0] username = test_case_row['User'].values[0] password = test_case_row['Password'].values[0] browser = test_case_row['Browser'].values[0] account_number = test_case_row['account_number'].values[0] rep_code = test_case_row['rep_code'].values[0] test_data1 = test_case_row['test_data1'].values[0] test_data2 = test_case_row['test_data_2'].values[0] control_point_1 = test_case_row['control_point_1'].values[0] control_point_2 = test_case_row['control_point_2'].values[0] control_point_3 = test_case_row['control_point_3'].values[0] control_point_4 = test_case_row['control_point_4'].values[0] # To DEBUG, Uncomment this NEXT line AND Comment lines 13, 15 and 18. Also, SHIFT + TAB lines 17 - 86 (This will remove indents) # driver = webdriver.Chrome(str(CONFIG_PATH / 'chromedriver.exe')) ## Select Appropriate URL based on the Environment Value (env) # Launch BICL Site # env = "UAT" baseURL_BICL = Environments_BICL.return_environments(env) # baseURL = "https://beta.bi.dev.wedbus.com" time.sleep(1) driver.get(baseURL_BICL) driver.maximize_window() # Login to Site lp = LoginPage(driver) # Verify if page loads (username_field should be clickable), if not, throw exception and take screenshot try: username_field = lp.Page_Elements().driver.find_element_by_id("UserName") username_field.click() except NoSuchElementException: screenshot_name = "FAIL" + "_" + test_case_ID + "_" + browser + "_" + env + "_" + time_stamp + ".png" saved_screenshot_location = str(screenshot_directory / screenshot_name) driver.get_screenshot_as_file(saved_screenshot_location) raise lp.login(username, password) lp.click_login_button() time.sleep(10) # Take screenshot after login and save to utilities/test_results/screenshots screenshot_1 = test_case_ID + "_" + browser + "_" + env + "_" + "screenshot_1" + "_" + control_point_1 + "_" + time_stamp + ".png" saved_screenshot_location_1 = str(screenshot_directory / screenshot_1) driver.get_screenshot_as_file(saved_screenshot_location_1) dp = default_page(driver) # Timeout method for page to load, timeout set to 30 seconds try: driver.set_page_load_timeout(30) except: screenshot_name = "FAIL" + "_" + test_case_ID + "_" + browser + "_" + env + "_" + time_stamp + ".png" saved_screenshot_location = str(screenshot_directory / screenshot_name) driver.get_screenshot_as_file(saved_screenshot_location) raise time.sleep(1) # Enter Account Number and click Search dp.enter_account_number_search(account_number) time.sleep(1) # Click Tools dp.click_tools_icon() tls = tools(driver) time.sleep(1) cl = client_search(driver) # Take screenshot save to utilities/test_results/screenshots screenshot_2 = test_case_ID + "_" + browser + "_" + env + "_" + "screenshot_2" + "_" + control_point_2 + "_" + time_stamp + ".png" saved_screenshot_location_2 = str(screenshot_directory / screenshot_2) driver.get_screenshot_as_file(saved_screenshot_location_2) # On Tools \ Client Search, input Rep Code cl.input_rep_code(rep_code) # Select "Total Value" From Criteria Column cl.select_value_from_criteria_column() # Select Greater Than 0 cl.select_from_greater_than_less_than_equal() cl.click_rep_code_field() # this will re-focus the mouse time.sleep(5) cl.input_number_value() # Click Go Button cl.click_go_button() time.sleep(5) # verify values in account number column cl.verify_values_in_account_number_column(test_case_ID, browser, env, time_stamp) cl.verify_values_in_name_column(test_case_ID, browser, env, time_stamp) cl.verify_values_in_total_column(test_case_ID, browser, env, time_stamp) # Commenting out phone & business phone verifications cl.verify_values_in_phone_column(test_case_ID, browser, env, time_stamp) cl.verify_values_in_bus_phone_column(test_case_ID, browser, env, time_stamp) cl.verify_values_in_rep_code_column(test_case_ID, browser, env, time_stamp) time.sleep(5) # Take screenshot save to utilities/test_results/screenshots screenshot_3 = test_case_ID + "_" + browser + "_" + env + "_" + "screenshot_3" + "_" + control_point_3 + "_" + time_stamp + ".png" saved_screenshot_location_3 = str(screenshot_directory / screenshot_3) driver.get_screenshot_as_file(saved_screenshot_location_3) errorDisplays = False # Check if Error Modal Displays if len(driver.find_elements(By.XPATH, "/html/body/div[1]/div/div/div/button")) > 0: errorDisplays = True else: print("No Error") time.sleep(1) # Try / Except Block to test if errorDisplays False # If True, throw exception, take screenshot and FAIL test try: assert errorDisplays is False except AssertionError: screenshot_name = "FAIL" + "_" + test_case_ID + "_" + browser + "_" + env + "_" + time_stamp + ".png" saved_screenshot_location = str(screenshot_directory / screenshot_name) driver.get_screenshot_as_file(saved_screenshot_location) raise time.sleep(1) # Take screenshot save to utilities/test_results/screenshots screenshot_4 = test_case_ID + "_" + browser + "_" + env + "_" + "screenshot_4" + "_" + control_point_4 + "_" + time_stamp + ".png" saved_screenshot_location_4 = str(screenshot_directory / screenshot_4) driver.get_screenshot_as_file(saved_screenshot_location_4) # LOGOUT Section # TODO: Move Logout methods to Logout Class # Force Logout # Logout Workaround # Get current URL string, find base URL # Add logout_string to base_url to force logout current_url = driver.current_url slashparts = current_url.split('/') # Now join back the first three sections 'http:', '' and 'example.com' base_url = '/'.join(slashparts[:3]) + '/' logout_string = "user/login?logout=1" logout_screen = base_url + logout_string # Navigate to Logout Screen driver.get(logout_screen)