Loading load-copy.py +75 −20 Original line number Diff line number Diff line Loading @@ -12,6 +12,11 @@ import threading # Import the threading module from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC 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.common.exceptions import TimeoutException # Import TimeoutException class MultipleTest(unittest.TestCase): def setUp(self): options = webdriver.ChromeOptions() Loading Loading @@ -41,7 +46,7 @@ class MultipleTest(unittest.TestCase): self.verificationErrors = [] self.accept_next_alert = True def _interact_with_time_filters(self, driver, start_with_6_hours=False): def _interact_with_time_filters(self, driver): """ Automates the interaction with time filter buttons on a webpage using Selenium WebDriver. This function specifically targets the time filter dropdown and options found in Loading @@ -49,28 +54,17 @@ class MultipleTest(unittest.TestCase): This function performs the following steps: 1. Clicks the main dropdown button to reveal time filter options. 2. Selects either 'Recent 3 Hours' or 'Recent 6 Hours' based on the 'start_with_6_hours' parameter. 2. Selects either 'Recent 3 Hours' option. 3. Clicks the main dropdown button again to re-open the options. 4. Selects the 'Recent 7 Days' option. 5. Clicks the main dropdown button one more time. 6. Selects the 'Recent 60 Days' option. Args: driver: The Selenium WebDriver instance, which is used to find and interact with web elements. Ensure that the WebDriver is already initialized and navigated to the correct page before calling this function. start_with_6_hours (bool): If True, starts by selecting '최근 6 시간'. If False (default), starts by selecting '최근 3 시간'. """ # Click the dropdown button to open the time filter options driver.find_element_by_xpath("//div[@id='page-wrapper']/div/div/div[2]/div/span[2]/div/button[2]/span").click() # Select either 'Recent 3 Hours' or 'Recent 6 Hours' if start_with_6_hours: initial_time_button_xpath = "//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 6 시간')]]" else: initial_time_button_xpath = "//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 3 시간')]]" driver.find_element_by_xpath(initial_time_button_xpath).click() driver.find_element_by_xpath("//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 3 시간')]]").click() # Click the dropdown button again to re-open the time filter options driver.find_element_by_xpath("//div[@id='page-wrapper']/div/div/div[2]/div/span[2]/div/button[2]/span").click() Loading @@ -86,6 +80,67 @@ class MultipleTest(unittest.TestCase): recent_60_days_button_xpath = "//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 60 일')]]" driver.find_element_by_xpath(recent_60_days_button_xpath).click() def _interact_with_time_filters_for_la(self, driver): """ Automates the interaction with time filter buttons on a webpage using Selenium WebDriver. This function specifically targets the time filter dropdown and options found in sections like 'Performance/Operation' (성능/운영). This function performs the following steps: 1. Clicks the main dropdown button to reveal time filter options. 2. Selects either 'Recent 3 Hours' option. 3. Clicks the main dropdown button again to re-open the options. 4. Selects the 'Recent 7 Days' option. 5. Clicks the main dropdown button one more time. 6. Selects the 'Recent 60 Days' option. """ wait = WebDriverWait(driver, 5) # Initialize WebDriverWait # Click the dropdown button to open the time filter options try: dropdown_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='page-wrapper']/div/div/div/div/span/div/button[2]/span"))) dropdown_button.click() except TimeoutException: print("Timeout waiting for the dropdown button in _interact_with_time_filters_for_la.") # Handle the exception, perhaps re-try or log an error try: recent_6_hours_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 6 시간')]]"))) recent_6_hours_button.click() except TimeoutException: print("Timeout waiting for '최근 6 시간' button in _interact_with_time_filters_for_la.") # Click the dropdown button again to re-open the time filter options try: dropdown_button_reopen = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='page-wrapper']/div/div/div/div/span/div/button[2]/span"))) dropdown_button_reopen.click() except TimeoutException: print("Timeout waiting for the dropdown button to re-open in _interact_with_time_filters_for_la.") # Define XPath for 'Recent 7 Days' button and click it recent_7_days_button_xpath = "//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 7 일')]]" try: recent_7_days_button = wait.until(EC.element_to_be_clickable((By.XPATH, recent_7_days_button_xpath))) recent_7_days_button.click() except TimeoutException: print("Timeout waiting for '최근 7 일' button in _interact_with_time_filters_for_la.") # Click the dropdown button one more time to re-open the time filter options try: dropdown_button_reopen_2 = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='page-wrapper']/div/div/div/div/span/div/button[2]/span"))) dropdown_button_reopen_2.click() except TimeoutException: print("Timeout waiting for the dropdown button to re-open (second time) in _interact_with_time_filters_for_la.") # Define XPath for 'Recent 60 Days' button and click it recent_60_days_button_xpath = "//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 60 일')]]" try: recent_60_days_button = wait.until(EC.element_to_be_clickable((By.XPATH, recent_60_days_button_xpath))) recent_60_days_button.click() except TimeoutException: print("Timeout waiting for '최근 60 일' button in _interact_with_time_filters_for_la.") def _run_driver1_actions(self, driver, address, id, pw): # Initialize WebDriverWait for this specific driver instance wait = WebDriverWait(driver, 10) Loading Loading @@ -206,7 +261,7 @@ class MultipleTest(unittest.TestCase): driver.execute_script("arguments[0].click();", analysis_tab) # Call the new function to handle time filter interactions for this section self._interact_with_time_filters(driver, start_with_6_hours=False) # Example: Use '최근 3 시간' first self._interact_with_time_filters(driver) ############################ # 2번째 모듈 Loading @@ -219,7 +274,7 @@ class MultipleTest(unittest.TestCase): driver.find_element_by_id("tab-analysis").click() # Call the new function to handle time filter interactions for this section self._interact_with_time_filters(driver, start_with_6_hours=False) # Example: Use '최근 3 시간' first self._interact_with_time_filters(driver) ############################ # 3번째 모듈 Loading @@ -232,7 +287,7 @@ class MultipleTest(unittest.TestCase): driver.find_element_by_id("tab-analysis").click() # Call the new function to handle time filter interactions for this section self._interact_with_time_filters(driver, start_with_6_hours=False) # Example: Use '최근 3 시간' first self._interact_with_time_filters(driver) # chart # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[4]/a/div"))).click() Loading @@ -240,13 +295,13 @@ class MultipleTest(unittest.TestCase): # session 5 actions - Log-analysis time.sleep(0.5) # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[5]/a/div"))).click() # 로그 분석 > 전체 로그 > 우측 상단 시간 조정(최근 3시간, 최근 7일, 최근 60일) # 로그 분석 > 전체 로그 > 우측 상단 시간 조정(최근 6시간, 최근 7일, 최근 60일) # 로그 분석 driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[5]/a/div").click() # 전체 로그 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div/div/div/div/div/span[2]/span/span").click() self._interact_with_time_filters(driver, start_with_6_hours=True) # Example: Use '최근 3 시간' first self._interact_with_time_filters_for_la(driver) # session 6 actions - Event-status time.sleep(0.5) Loading @@ -269,7 +324,7 @@ class MultipleTest(unittest.TestCase): # 최상위 그룹(물리 그룹) driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div/span[2]/span/span[2]").click() self._interact_with_time_filters(driver, start_with_6_hours=False) # Example: Use '최근 3 시간' first self._interact_with_time_filters(driver) # session 7 actions - Work time.sleep(0.5) Loading Loading
load-copy.py +75 −20 Original line number Diff line number Diff line Loading @@ -12,6 +12,11 @@ import threading # Import the threading module from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC 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.common.exceptions import TimeoutException # Import TimeoutException class MultipleTest(unittest.TestCase): def setUp(self): options = webdriver.ChromeOptions() Loading Loading @@ -41,7 +46,7 @@ class MultipleTest(unittest.TestCase): self.verificationErrors = [] self.accept_next_alert = True def _interact_with_time_filters(self, driver, start_with_6_hours=False): def _interact_with_time_filters(self, driver): """ Automates the interaction with time filter buttons on a webpage using Selenium WebDriver. This function specifically targets the time filter dropdown and options found in Loading @@ -49,28 +54,17 @@ class MultipleTest(unittest.TestCase): This function performs the following steps: 1. Clicks the main dropdown button to reveal time filter options. 2. Selects either 'Recent 3 Hours' or 'Recent 6 Hours' based on the 'start_with_6_hours' parameter. 2. Selects either 'Recent 3 Hours' option. 3. Clicks the main dropdown button again to re-open the options. 4. Selects the 'Recent 7 Days' option. 5. Clicks the main dropdown button one more time. 6. Selects the 'Recent 60 Days' option. Args: driver: The Selenium WebDriver instance, which is used to find and interact with web elements. Ensure that the WebDriver is already initialized and navigated to the correct page before calling this function. start_with_6_hours (bool): If True, starts by selecting '최근 6 시간'. If False (default), starts by selecting '최근 3 시간'. """ # Click the dropdown button to open the time filter options driver.find_element_by_xpath("//div[@id='page-wrapper']/div/div/div[2]/div/span[2]/div/button[2]/span").click() # Select either 'Recent 3 Hours' or 'Recent 6 Hours' if start_with_6_hours: initial_time_button_xpath = "//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 6 시간')]]" else: initial_time_button_xpath = "//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 3 시간')]]" driver.find_element_by_xpath(initial_time_button_xpath).click() driver.find_element_by_xpath("//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 3 시간')]]").click() # Click the dropdown button again to re-open the time filter options driver.find_element_by_xpath("//div[@id='page-wrapper']/div/div/div[2]/div/span[2]/div/button[2]/span").click() Loading @@ -86,6 +80,67 @@ class MultipleTest(unittest.TestCase): recent_60_days_button_xpath = "//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 60 일')]]" driver.find_element_by_xpath(recent_60_days_button_xpath).click() def _interact_with_time_filters_for_la(self, driver): """ Automates the interaction with time filter buttons on a webpage using Selenium WebDriver. This function specifically targets the time filter dropdown and options found in sections like 'Performance/Operation' (성능/운영). This function performs the following steps: 1. Clicks the main dropdown button to reveal time filter options. 2. Selects either 'Recent 3 Hours' option. 3. Clicks the main dropdown button again to re-open the options. 4. Selects the 'Recent 7 Days' option. 5. Clicks the main dropdown button one more time. 6. Selects the 'Recent 60 Days' option. """ wait = WebDriverWait(driver, 5) # Initialize WebDriverWait # Click the dropdown button to open the time filter options try: dropdown_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='page-wrapper']/div/div/div/div/span/div/button[2]/span"))) dropdown_button.click() except TimeoutException: print("Timeout waiting for the dropdown button in _interact_with_time_filters_for_la.") # Handle the exception, perhaps re-try or log an error try: recent_6_hours_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 6 시간')]]"))) recent_6_hours_button.click() except TimeoutException: print("Timeout waiting for '최근 6 시간' button in _interact_with_time_filters_for_la.") # Click the dropdown button again to re-open the time filter options try: dropdown_button_reopen = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='page-wrapper']/div/div/div/div/span/div/button[2]/span"))) dropdown_button_reopen.click() except TimeoutException: print("Timeout waiting for the dropdown button to re-open in _interact_with_time_filters_for_la.") # Define XPath for 'Recent 7 Days' button and click it recent_7_days_button_xpath = "//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 7 일')]]" try: recent_7_days_button = wait.until(EC.element_to_be_clickable((By.XPATH, recent_7_days_button_xpath))) recent_7_days_button.click() except TimeoutException: print("Timeout waiting for '최근 7 일' button in _interact_with_time_filters_for_la.") # Click the dropdown button one more time to re-open the time filter options try: dropdown_button_reopen_2 = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='page-wrapper']/div/div/div/div/span/div/button[2]/span"))) dropdown_button_reopen_2.click() except TimeoutException: print("Timeout waiting for the dropdown button to re-open (second time) in _interact_with_time_filters_for_la.") # Define XPath for 'Recent 60 Days' button and click it recent_60_days_button_xpath = "//div[contains(@class, 'el-popover')]//button[span[contains(text(), '최근 60 일')]]" try: recent_60_days_button = wait.until(EC.element_to_be_clickable((By.XPATH, recent_60_days_button_xpath))) recent_60_days_button.click() except TimeoutException: print("Timeout waiting for '최근 60 일' button in _interact_with_time_filters_for_la.") def _run_driver1_actions(self, driver, address, id, pw): # Initialize WebDriverWait for this specific driver instance wait = WebDriverWait(driver, 10) Loading Loading @@ -206,7 +261,7 @@ class MultipleTest(unittest.TestCase): driver.execute_script("arguments[0].click();", analysis_tab) # Call the new function to handle time filter interactions for this section self._interact_with_time_filters(driver, start_with_6_hours=False) # Example: Use '최근 3 시간' first self._interact_with_time_filters(driver) ############################ # 2번째 모듈 Loading @@ -219,7 +274,7 @@ class MultipleTest(unittest.TestCase): driver.find_element_by_id("tab-analysis").click() # Call the new function to handle time filter interactions for this section self._interact_with_time_filters(driver, start_with_6_hours=False) # Example: Use '최근 3 시간' first self._interact_with_time_filters(driver) ############################ # 3번째 모듈 Loading @@ -232,7 +287,7 @@ class MultipleTest(unittest.TestCase): driver.find_element_by_id("tab-analysis").click() # Call the new function to handle time filter interactions for this section self._interact_with_time_filters(driver, start_with_6_hours=False) # Example: Use '최근 3 시간' first self._interact_with_time_filters(driver) # chart # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[4]/a/div"))).click() Loading @@ -240,13 +295,13 @@ class MultipleTest(unittest.TestCase): # session 5 actions - Log-analysis time.sleep(0.5) # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[5]/a/div"))).click() # 로그 분석 > 전체 로그 > 우측 상단 시간 조정(최근 3시간, 최근 7일, 최근 60일) # 로그 분석 > 전체 로그 > 우측 상단 시간 조정(최근 6시간, 최근 7일, 최근 60일) # 로그 분석 driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[5]/a/div").click() # 전체 로그 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div/div/div/div/div/span[2]/span/span").click() self._interact_with_time_filters(driver, start_with_6_hours=True) # Example: Use '최근 3 시간' first self._interact_with_time_filters_for_la(driver) # session 6 actions - Event-status time.sleep(0.5) Loading @@ -269,7 +324,7 @@ class MultipleTest(unittest.TestCase): # 최상위 그룹(물리 그룹) driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div/span[2]/span/span[2]").click() self._interact_with_time_filters(driver, start_with_6_hours=False) # Example: Use '최근 3 시간' first self._interact_with_time_filters(driver) # session 7 actions - Work time.sleep(0.5) Loading