Loading load-copy.py 0 → 100644 +359 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select # from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoSuchElementException, NoAlertPresentException, TimeoutException import unittest, time, re import threading # Import the threading module # Import for Explicit Waits from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC class MultipleTest(unittest.TestCase): def setUp(self): options = webdriver.ChromeOptions() options.add_experimental_option("excludeSwitches", ["enable-logging"]) # options.add_argument("disable-gpu") options.add_argument("--ignore-certificate-errors") options.add_argument('--start-maximized') # options.add_argument('--incognito') options.add_argument('--guest') # options.add_argument('--headless') # Set a specific window size for headless mode options.add_argument("--window-size=1920,1080") # Linux Only # options.add_argument("--no-sandbox") # options.add_argument("--disable-dev-shm-usage") webdriver_path = 'C:\\Users\\watchtek\\Documents\\chromedriver-win64\\chromedriver.exe' # self.DC_address = 'https://192.168.20.212/' self.DC_address = 'https://watchall.biblio19.net/' # self.driver = webdriver.Chrome(executable_path=r'C:\Users\watchtek\Documents\chromedriver-win64\chromedriver.exe', options=options) self.driver = webdriver.Chrome(executable_path=webdriver_path, options=options) self.driver.implicitly_wait(10) # 공통 설정 - n초 대기 self.base_url = "about:blank" self.verificationErrors = [] self.accept_next_alert = True def _interact_with_time_filters(self, driver, start_with_6_hours=False): """ 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' or 'Recent 6 Hours' based on the 'start_with_6_hours' parameter. 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() # 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() # 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 일')]]" driver.find_element_by_xpath(recent_7_days_button_xpath).click() # Click the dropdown button one more time 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() # 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 일')]]" driver.find_element_by_xpath(recent_60_days_button_xpath).click() def _run_driver1_actions(self, driver, address, id, pw): # Initialize WebDriverWait for this specific driver instance wait = WebDriverWait(driver, 10) # session 1 actions - Login # DC 접속 driver.get(address) time.sleep(0.5) # Login wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@type='text']"))).click() driver.find_element(By.XPATH, "//input[@type='text']").click() driver.find_element(By.XPATH, "//input[@type='text']").clear() driver.find_element(By.XPATH, "//input[@type='text']").send_keys(id) driver.find_element(By.XPATH, "//input[@type='password']").clear() driver.find_element(By.XPATH, "//input[@type='password']").send_keys(pw) driver.find_element(By.XPATH, "//button[@type='button']").click() # driver.find_element_by_xpath("//div[@id='app']/div/div/div/div[2]/div[2]/button/span").click() time.sleep(0.5) # session 2 actions - Dashboard # time.sleep(0.5) # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[2]/a/div"))).click() # 대시보드 > 기본대시보드 상위 3개, # 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[1]/a/div").click() # 1번째 기본 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div/div/div/div/div/div/div[2]/div/div/span[2]/span/span").click() # time.sleep(5.0) # 2번째 기본 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div/div/div/div/div/div/div[2]/div[2]/div/span[2]/span/span").click() # time.sleep(5.0) # 3번째 기본 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div/div/div/div/div/div/div[2]/div[3]/div/span[2]/span/span").click() # time.sleep(5.0) # 커스텀 대시보드 상위 3개 클릭 (전체 조회 될 때까지 충분히 기다림 20초 정도) # 커스텀 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/div[2]/label[2]/span/span").click() # 1번째 커스텀 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div[2]/div/div/div/div/div/div[2]/div/div/span[2]/span/span").click() # time.sleep(5.0) # 2번째 커스텀 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div[2]/div/div/div/div/div/div[2]/div[2]/div/span[2]/span/span").click() # time.sleep(5.0) # # 3번째 커스텀 대시보드 # # 3rd custom dashboard - MODIFIED BLOCK # try: # # Wait a maximum of 5 seconds for the element to be clickable # third_dashboard = WebDriverWait(driver, 5).until( # EC.element_to_be_clickable((By.XPATH, # "//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div[2]/div/div/div/div/div/div[2]/div[3]/div/span[2]/span/span")) # ) # third_dashboard.click() # print("Clicked the third custom dashboard element.") # except TimeoutException: # # This block executes if the element isn't clickable within 5 seconds # print("The third custom dashboard element was not found within 5 seconds. Skipping.") # pass # # time.sleep(5.0) # session 3 actions - Topology map time.sleep(0.5) # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[2]/a/div"))).click() # 토폴로지맵 > 상위 3개 맵 순차 클릭 # 토폴로지맵 driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[2]/a/div").click() # 최상위 3개 # 1번째 토폴로지맵 # driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/article/div/div/div/div/div/div/span[2]/span/span[2]").click() # 2번째 토폴로지맵 # driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/article/div/div/div/div/div[2]/div/span[2]/span/span[2]").click() # 3번째 토폴로지맵 # driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/article/div/div/div/div/div[3]/div/span[2]/span/span[2]").click() # 하위 depths 따라가기 # 1.1번째 토폴로지맵 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/article/div/div/div/div/div/div[2]/div/div/span[2]/span/span[2]").click() # 1.1.1번째 토폴로지맵 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/article/div/div/div/div/div/div[2]/div/div[2]/div/div/span[2]/span/span[2]").click() ### 1.1.1.1번째 토폴로지맵 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/article/div/div/div/div/div/div[2]/div/div[2]/div/div[2]/div/div/span[2]/span/span[2]").click() # session 4 actions - perf-oper time.sleep(0.5) # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[3]/a/div"))).click() # 성능/운영 > 물리그룹 > 최상위 그룹 클릭 > 성능 정보 클릭, # 성능/운영 driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[3]/a/div").click() # 물리 그룹 클릭 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[2]/label[2]/span/span").click() # 최상위 그룹 클릭 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").click() # 성능 정보 클릭 driver.find_element_by_id("tab-performance").click() # > 성능/운영 > 물리그룹 > 모듈별 대상 1번씩 클릭 > 분석 화면 클릭 > 우측 상단 시간 조정(최근 3시간, 최근 7일, 최근 60일) # 1번째 모듈 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div/div").click() # 최상위 벤더 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div/div[2]/div/div/span[2]/span/span[2]").click() # 최상위 기기 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div/div[2]/div/div[2]/div/div/span[2]/span/span/span/span/span[3]").click() # 분석 화면 클릭 # Deprecated Method # driver.find_element_by_id("tab-analysis").click() # Modern Replacement # driver.find_element(By.ID, "tab-analysis").click() # Find the element you want to click analysis_tab = driver.find_element(By.ID, "tab-analysis") # Use JavaScript to perform the click 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 ############################ # 2번째 모듈 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div[2]/div/span[2]/span/span[2]").click() # 최상위 벤더 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div[2]/div[2]/div/div/span[2]/span/span[2]").click() # 최상위 기기 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/span[2]/span/span/span/span/span[3]").click() # 분석 화면 클릭 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 ############################ # 3번째 모듈 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div[3]/div/span[2]/span/span[2]").click() # 최상위 벤더 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div[3]/div[2]/div/div/span[2]/span/span[2]").click() # 최상위 기기 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div[3]/div[2]/div/div[2]/div/div/span[2]/span/span/span/span/span[3]").click() # 분석 화면 클릭 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 # chart # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[4]/a/div"))).click() # 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일) # 로그 분석 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 # session 6 actions - Event-status time.sleep(0.5) # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[6]/a/div"))).click() # 이벤트 > 이벤트 현황 > 물리그룹 > 최상위 그룹 클릭 # 이벤트 driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[6]/a/div").click() # 이벤트 현황 driver.find_element_by_id("tab-event-status").click() # 물리 그룹 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[2]/label[2]/span/span").click() # 최상위 그룹(물리 그룹) 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() # 이벤트 이력 > 물리그룹 > 최상위 그룹 클릭 > 우측 상단 시간 조정(최근 3시간, 최근 7일, 최근 60일) # 이벤트 이력 driver.find_element_by_id("tab-event-hist").click() # 물리 그룹 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[2]/label[2]/span/span").click() # 최상위 그룹(물리 그룹) 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 # session 7 actions - Work time.sleep(0.5) wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[7]/a/div"))).click() # 작업관리 > 월간, 목록, 이력 클릭 # 작업 관리 driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[7]/a/div").click() # 월간 driver.find_element_by_xpath("//div[@id='page-wrapper']/div/div[2]/div/div/div/div/div/div/div/label/span").click() # 목록 driver.find_element_by_xpath("//div[@id='page-wrapper']/div/div[2]/div/div/div/div/div/div/div/label[2]/span").click() # 이력 driver.find_element_by_xpath("//div[@id='page-wrapper']/div/div[2]/div/div/div/div/div/div/div/label[3]/span").click() # report # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[8]/a/div"))).click() # session 8 actions - only admin time.sleep(0.5) # [어드민만] 설정 > 초기설정 > 장비 등록 > 모듈별 장비 확인 driver.find_element_by_xpath("//div[@id='wrapper']/nav/span/a/div").click() driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='신규 장비 등록 및 관리 여부 설정이 가능합니다.'])[1]/following::button[1]").click() time.sleep(0.5) driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='네트워크'])[1]/following::li[1]").click() driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='서버'])[1]/following::li[1]").click() driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='시설장비'])[1]/following::li[1]").click() # 운영설정 > 기준정보 설정 > 수집/판단 기준> 이벤트/알람 기준 클릭 time.sleep(0.5) driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='초기 설정'])[1]/following::span[1]").click() driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='기준 정보 편집'])[1]/following::span[1]").click() driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='수집/판단 기준'])[1]/following::li[1]").click() # End of Test time.sleep(1) def test_multiple(self): driver = self.driver address = self.DC_address id1 = 'administrator' id2 = 'local_manager' id3 = 'manager' id4 = 'user' pw = 'watchall' # Create threads for each driver's actions thread1 = threading.Thread(target=self._run_driver1_actions, args=(driver, address, id1, pw)) # Start the threads thread1.start() # Wait for both threads to complete thread1.join() def is_element_present(self, how, what): try: self.driver.find_element(by=how, value=what) except NoSuchElementException as e: return False return True def is_alert_present(self): try: self.driver.switch_to.alert except NoAlertPresentException as e: return False return True def close_alert_and_get_its_text(self): try: alert = self.driver.switch_to.alert alert_text = alert.text if self.accept_next_alert: alert.accept() else: alert.dismiss() return alert_text finally: self.accept_next_alert = True def tearDown(self): self.driver.quit() # self.driver2.quit() # self.driver3.quit() # self.driver4.quit() # Ensure both drivers are quit self.assertEqual([], self.verificationErrors) if __name__ == "__main__": unittest.main() No newline at end of file Loading
load-copy.py 0 → 100644 +359 −0 Original line number Diff line number Diff line # -*- coding: utf-8 -*- from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select # from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoSuchElementException, NoAlertPresentException, TimeoutException import unittest, time, re import threading # Import the threading module # Import for Explicit Waits from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC class MultipleTest(unittest.TestCase): def setUp(self): options = webdriver.ChromeOptions() options.add_experimental_option("excludeSwitches", ["enable-logging"]) # options.add_argument("disable-gpu") options.add_argument("--ignore-certificate-errors") options.add_argument('--start-maximized') # options.add_argument('--incognito') options.add_argument('--guest') # options.add_argument('--headless') # Set a specific window size for headless mode options.add_argument("--window-size=1920,1080") # Linux Only # options.add_argument("--no-sandbox") # options.add_argument("--disable-dev-shm-usage") webdriver_path = 'C:\\Users\\watchtek\\Documents\\chromedriver-win64\\chromedriver.exe' # self.DC_address = 'https://192.168.20.212/' self.DC_address = 'https://watchall.biblio19.net/' # self.driver = webdriver.Chrome(executable_path=r'C:\Users\watchtek\Documents\chromedriver-win64\chromedriver.exe', options=options) self.driver = webdriver.Chrome(executable_path=webdriver_path, options=options) self.driver.implicitly_wait(10) # 공통 설정 - n초 대기 self.base_url = "about:blank" self.verificationErrors = [] self.accept_next_alert = True def _interact_with_time_filters(self, driver, start_with_6_hours=False): """ 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' or 'Recent 6 Hours' based on the 'start_with_6_hours' parameter. 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() # 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() # 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 일')]]" driver.find_element_by_xpath(recent_7_days_button_xpath).click() # Click the dropdown button one more time 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() # 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 일')]]" driver.find_element_by_xpath(recent_60_days_button_xpath).click() def _run_driver1_actions(self, driver, address, id, pw): # Initialize WebDriverWait for this specific driver instance wait = WebDriverWait(driver, 10) # session 1 actions - Login # DC 접속 driver.get(address) time.sleep(0.5) # Login wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@type='text']"))).click() driver.find_element(By.XPATH, "//input[@type='text']").click() driver.find_element(By.XPATH, "//input[@type='text']").clear() driver.find_element(By.XPATH, "//input[@type='text']").send_keys(id) driver.find_element(By.XPATH, "//input[@type='password']").clear() driver.find_element(By.XPATH, "//input[@type='password']").send_keys(pw) driver.find_element(By.XPATH, "//button[@type='button']").click() # driver.find_element_by_xpath("//div[@id='app']/div/div/div/div[2]/div[2]/button/span").click() time.sleep(0.5) # session 2 actions - Dashboard # time.sleep(0.5) # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[2]/a/div"))).click() # 대시보드 > 기본대시보드 상위 3개, # 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[1]/a/div").click() # 1번째 기본 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div/div/div/div/div/div/div[2]/div/div/span[2]/span/span").click() # time.sleep(5.0) # 2번째 기본 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div/div/div/div/div/div/div[2]/div[2]/div/span[2]/span/span").click() # time.sleep(5.0) # 3번째 기본 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div/div/div/div/div/div/div[2]/div[3]/div/span[2]/span/span").click() # time.sleep(5.0) # 커스텀 대시보드 상위 3개 클릭 (전체 조회 될 때까지 충분히 기다림 20초 정도) # 커스텀 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/div[2]/label[2]/span/span").click() # 1번째 커스텀 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div[2]/div/div/div/div/div/div[2]/div/div/span[2]/span/span").click() # time.sleep(5.0) # 2번째 커스텀 대시보드 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div[2]/div/div/div/div/div/div[2]/div[2]/div/span[2]/span/span").click() # time.sleep(5.0) # # 3번째 커스텀 대시보드 # # 3rd custom dashboard - MODIFIED BLOCK # try: # # Wait a maximum of 5 seconds for the element to be clickable # third_dashboard = WebDriverWait(driver, 5).until( # EC.element_to_be_clickable((By.XPATH, # "//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div[2]/div/div/div/div/div/div[2]/div[3]/div/span[2]/span/span")) # ) # third_dashboard.click() # print("Clicked the third custom dashboard element.") # except TimeoutException: # # This block executes if the element isn't clickable within 5 seconds # print("The third custom dashboard element was not found within 5 seconds. Skipping.") # pass # # time.sleep(5.0) # session 3 actions - Topology map time.sleep(0.5) # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[2]/a/div"))).click() # 토폴로지맵 > 상위 3개 맵 순차 클릭 # 토폴로지맵 driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[2]/a/div").click() # 최상위 3개 # 1번째 토폴로지맵 # driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/article/div/div/div/div/div/div/span[2]/span/span[2]").click() # 2번째 토폴로지맵 # driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/article/div/div/div/div/div[2]/div/span[2]/span/span[2]").click() # 3번째 토폴로지맵 # driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/article/div/div/div/div/div[3]/div/span[2]/span/span[2]").click() # 하위 depths 따라가기 # 1.1번째 토폴로지맵 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/article/div/div/div/div/div/div[2]/div/div/span[2]/span/span[2]").click() # 1.1.1번째 토폴로지맵 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/article/div/div/div/div/div/div[2]/div/div[2]/div/div/span[2]/span/span[2]").click() ### 1.1.1.1번째 토폴로지맵 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/article/div/div/div/div/div/div[2]/div/div[2]/div/div[2]/div/div/span[2]/span/span[2]").click() # session 4 actions - perf-oper time.sleep(0.5) # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[3]/a/div"))).click() # 성능/운영 > 물리그룹 > 최상위 그룹 클릭 > 성능 정보 클릭, # 성능/운영 driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[3]/a/div").click() # 물리 그룹 클릭 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[2]/label[2]/span/span").click() # 최상위 그룹 클릭 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").click() # 성능 정보 클릭 driver.find_element_by_id("tab-performance").click() # > 성능/운영 > 물리그룹 > 모듈별 대상 1번씩 클릭 > 분석 화면 클릭 > 우측 상단 시간 조정(최근 3시간, 최근 7일, 최근 60일) # 1번째 모듈 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div/div").click() # 최상위 벤더 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div/div[2]/div/div/span[2]/span/span[2]").click() # 최상위 기기 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div/div[2]/div/div[2]/div/div/span[2]/span/span/span/span/span[3]").click() # 분석 화면 클릭 # Deprecated Method # driver.find_element_by_id("tab-analysis").click() # Modern Replacement # driver.find_element(By.ID, "tab-analysis").click() # Find the element you want to click analysis_tab = driver.find_element(By.ID, "tab-analysis") # Use JavaScript to perform the click 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 ############################ # 2번째 모듈 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div[2]/div/span[2]/span/span[2]").click() # 최상위 벤더 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div[2]/div[2]/div/div/span[2]/span/span[2]").click() # 최상위 기기 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/span[2]/span/span/span/span/span[3]").click() # 분석 화면 클릭 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 ############################ # 3번째 모듈 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div[3]/div/span[2]/span/span[2]").click() # 최상위 벤더 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div[3]/div[2]/div/div/span[2]/span/span[2]").click() # 최상위 기기 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[3]/div[2]/div/div/div/div/div/div[2]/div[3]/div[2]/div/div[2]/div/div/span[2]/span/span/span/span/span[3]").click() # 분석 화면 클릭 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 # chart # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[4]/a/div"))).click() # 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일) # 로그 분석 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 # session 6 actions - Event-status time.sleep(0.5) # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[6]/a/div"))).click() # 이벤트 > 이벤트 현황 > 물리그룹 > 최상위 그룹 클릭 # 이벤트 driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[6]/a/div").click() # 이벤트 현황 driver.find_element_by_id("tab-event-status").click() # 물리 그룹 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[2]/label[2]/span/span").click() # 최상위 그룹(물리 그룹) 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() # 이벤트 이력 > 물리그룹 > 최상위 그룹 클릭 > 우측 상단 시간 조정(최근 3시간, 최근 7일, 최근 60일) # 이벤트 이력 driver.find_element_by_id("tab-event-hist").click() # 물리 그룹 driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div[2]/label[2]/span/span").click() # 최상위 그룹(물리 그룹) 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 # session 7 actions - Work time.sleep(0.5) wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[7]/a/div"))).click() # 작업관리 > 월간, 목록, 이력 클릭 # 작업 관리 driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[7]/a/div").click() # 월간 driver.find_element_by_xpath("//div[@id='page-wrapper']/div/div[2]/div/div/div/div/div/div/div/label/span").click() # 목록 driver.find_element_by_xpath("//div[@id='page-wrapper']/div/div[2]/div/div/div/div/div/div/div/label[2]/span").click() # 이력 driver.find_element_by_xpath("//div[@id='page-wrapper']/div/div[2]/div/div/div/div/div/div/div/label[3]/span").click() # report # wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[8]/a/div"))).click() # session 8 actions - only admin time.sleep(0.5) # [어드민만] 설정 > 초기설정 > 장비 등록 > 모듈별 장비 확인 driver.find_element_by_xpath("//div[@id='wrapper']/nav/span/a/div").click() driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='신규 장비 등록 및 관리 여부 설정이 가능합니다.'])[1]/following::button[1]").click() time.sleep(0.5) driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='네트워크'])[1]/following::li[1]").click() driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='서버'])[1]/following::li[1]").click() driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='시설장비'])[1]/following::li[1]").click() # 운영설정 > 기준정보 설정 > 수집/판단 기준> 이벤트/알람 기준 클릭 time.sleep(0.5) driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='초기 설정'])[1]/following::span[1]").click() driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='기준 정보 편집'])[1]/following::span[1]").click() driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='수집/판단 기준'])[1]/following::li[1]").click() # End of Test time.sleep(1) def test_multiple(self): driver = self.driver address = self.DC_address id1 = 'administrator' id2 = 'local_manager' id3 = 'manager' id4 = 'user' pw = 'watchall' # Create threads for each driver's actions thread1 = threading.Thread(target=self._run_driver1_actions, args=(driver, address, id1, pw)) # Start the threads thread1.start() # Wait for both threads to complete thread1.join() def is_element_present(self, how, what): try: self.driver.find_element(by=how, value=what) except NoSuchElementException as e: return False return True def is_alert_present(self): try: self.driver.switch_to.alert except NoAlertPresentException as e: return False return True def close_alert_and_get_its_text(self): try: alert = self.driver.switch_to.alert alert_text = alert.text if self.accept_next_alert: alert.accept() else: alert.dismiss() return alert_text finally: self.accept_next_alert = True def tearDown(self): self.driver.quit() # self.driver2.quit() # self.driver3.quit() # self.driver4.quit() # Ensure both drivers are quit self.assertEqual([], self.verificationErrors) if __name__ == "__main__": unittest.main() No newline at end of file