From 6f3101e1ff784c2b84b8e43807794dfe149b191c Mon Sep 17 00:00:00 2001 From: Watchtek Date: Thu, 21 Aug 2025 00:08:02 +0900 Subject: [PATCH] remove old file --- 2ndTest_3.py | 90 --------- InternalTest.py | 91 --------- MultipleParaell.py | 217 -------------------- MultipleTest.py | 139 ------------- MultipleparagonParaell.py | 216 -------------------- WatchallFirstTest.py | 89 -------- WatchallFirstTest_2.py | 78 ------- load-copy.py | 414 -------------------------------------- test_with_demo.py | 216 -------------------- 9 files changed, 1550 deletions(-) delete mode 100644 2ndTest_3.py delete mode 100644 InternalTest.py delete mode 100644 MultipleParaell.py delete mode 100644 MultipleTest.py delete mode 100644 MultipleparagonParaell.py delete mode 100644 WatchallFirstTest.py delete mode 100644 WatchallFirstTest_2.py delete mode 100644 load-copy.py delete mode 100644 test_with_demo.py diff --git a/2ndTest_3.py b/2ndTest_3.py deleted file mode 100644 index d3e2fcc..0000000 --- a/2ndTest_3.py +++ /dev/null @@ -1,90 +0,0 @@ -# -*- 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 NoAlertPresentException -import unittest, time, re - -class SecondTest(unittest.TestCase): - def setUp(self): - - options = webdriver.ChromeOptions() - options.add_experimental_option("excludeSwitches", ["enable-logging"]) # urlopen시 에러코드 발생 -> 불필요한 로그이기때문에 숨김 - options.add_argument('--start-maximized') # 크롬 1920*1080 사이즈로 실행 / 최대 : window-size=1920x1080 - options.add_argument('--incognito') # 시크릿 모드로 실행 - # options.add_argument('--headless') # 크롬 화면 표현하지 않는 설정 (테스트 동안은 주석처리) - - self.driver = webdriver.Chrome(executable_path=r'C:\Users\watchtek\Documents\chromedriver-win64\chromedriver.exe', options=options) - self.driver.implicitly_wait(30) - self.base_url = "https://www.google.com/" - self.verificationErrors = [] - self.accept_next_alert = True - - def test_2nd(self): - driver = self.driver - driver.get("https://watchall.biblio19.net/#/login") - time.sleep(0.3) - 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("administrator") - driver.find_element_by_xpath("//input[@type='password']").clear() - driver.find_element_by_xpath("//input[@type='password']").send_keys("watchall") - driver.find_element_by_xpath("//button[@type='button']").click() - time.sleep(0.3) - driver.get("https://watchall.biblio19.net/#/dashboard/grid_dashboard-1.2") - time.sleep(0.3) - driver.get("https://watchall.biblio19.net/#/topologymap") - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[2]/a/div").click() - time.sleep(0.3) - driver.get("https://watchall.biblio19.net/#/perf-oper/logical-1") - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[3]/a/div").click() - time.sleep(0.3) - driver.get("https://watchall.biblio19.net/#/chart") - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[4]/a/div").click() - time.sleep(0.3) - driver.get("https://watchall.biblio19.net/#/log/log-1/search") - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[5]/a/div").click() - time.sleep(0.3) - driver.get("https://watchall.biblio19.net/#/event/logical-1/event-status") - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[6]/a/div").click() - time.sleep(0.3) - driver.get("https://watchall.biblio19.net/#/work") - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[7]/a/div").click() - time.sleep(0.3) - driver.get("https://watchall.biblio19.net/#/report/report-1") - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[8]/a/div").click() - time.sleep(0.3) - driver.get("https://watchall.biblio19.net/#/report/report-RPT_WATCHALL_CONFIG") - driver.find_element_by_xpath("//div[@id='wrapper']/header/div[2]/ul/li[7]/i").click() - driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='마지막 로그인 시각: 2025-07-16 14:46'])[1]/following::span[1]").click() - driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='아니오'])[1]/following::button[1]").click() - - 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.assertEqual([], self.verificationErrors) - -if __name__ == "__main__": - unittest.main() diff --git a/InternalTest.py b/InternalTest.py deleted file mode 100644 index b1deb98..0000000 --- a/InternalTest.py +++ /dev/null @@ -1,91 +0,0 @@ -# -*- 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 NoAlertPresentException -import unittest, time, re - -class InternalTest(unittest.TestCase): - def setUp(self): - - options = webdriver.ChromeOptions() - options.add_experimental_option("excludeSwitches", ["enable-logging"]) # urlopen시 에러코드 발생 -> 불필요한 로그이기때문에 숨김 - options.add_argument('--start-maximized') # 크롬 1920*1080 사이즈로 실행 / 최대 : window-size=1920x1080 - # options.add_argument('--incognito') # 시크릿 모드로 실행 - options.add_argument('--guest') # 게스트 모드로 실행 - # options.add_argument('--headless') # 크롬 화면 표현하지 않는 설정 (테스트 동안은 주석처리) - - self.driver = webdriver.Chrome(executable_path=r'C:\Users\watchtek\Documents\chromedriver-win64\chromedriver.exe', options=options) - self.driver.implicitly_wait(30) - self.base_url = "about:blank" - self.verificationErrors = [] - self.accept_next_alert = True - - def test_internal(self): - driver = self.driver - - id1 = 'administrator' - id2 = 'local_manager' - id3 = 'manager' - id4 = 'user' - pw = 'watchall' - - driver.get("http://192.168.20.212/") - time.sleep(0.5) - 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(id4) - 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.get("http://192.168.20.212/#/dashboard/coord_dashboard-2.9") - time.sleep(0.5) - # driver.get("http://192.168.20.212/#/topologymap") - time.sleep(0.5) - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[2]/a/div").click() - # driver.get("http://192.168.20.212/#/perf-oper/logical-1") - time.sleep(0.5) - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[3]/a/div").click() - # driver.get("http://192.168.20.212/#/chart") - time.sleep(0.5) - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[4]/a/div").click() - # driver.get("http://192.168.20.212/#/event/logical-1/event-status") - time.sleep(0.5) - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[5]/a/div").click() - # driver.get("http://192.168.20.212/#/work") - time.sleep(0.5) - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[6]/a/div").click() - # driver.get("http://192.168.20.212/#/report/report-1") - time.sleep(0.5) - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[7]/a/div").click() - time.sleep(1) - - 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.assertEqual([], self.verificationErrors) - -if __name__ == "__main__": - unittest.main() diff --git a/MultipleParaell.py b/MultipleParaell.py deleted file mode 100644 index 19f3c15..0000000 --- a/MultipleParaell.py +++ /dev/null @@ -1,217 +0,0 @@ -# -*- 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('--start-maximized') - options.add_argument('--incognito') - - self.driver = webdriver.Chrome(executable_path=r'C:\Users\watchtek\Documents\chromedriver-win64\chromedriver.exe', options=options) - self.driver.implicitly_wait(30) - self.base_url = "about:blank" - self.verificationErrors = [] - self.accept_next_alert = True - - self.driver2 = webdriver.Chrome(executable_path=r'C:\Users\watchtek\Documents\chromedriver-win64\chromedriver.exe', options=options) - self.driver2.implicitly_wait(30) - - def _wait_for_image_and_measure(self, driver_instance, image_url, timeout=20): - """ - Waits for a specific image to load and measures the loading time. - Returns the loading time in seconds if successful, None otherwise. - """ - start_time = time.time() - try: - # Create a WebDriverWait instance specifically for this driver and timeout - image_wait = WebDriverWait(driver_instance, timeout) - image_wait.until( - lambda driver: driver.execute_script( - f"var img = new Image(); img.src = '{image_url}'; return img.complete;" - ) - ) - end_time = time.time() - loading_time = end_time - start_time - print(f"Image '{image_url}' loaded in {loading_time:.2f} seconds.") - return loading_time - except TimeoutException: - print(f"Timeout waiting for image '{image_url}' to load.") - return None - except Exception as e: - print(f"An error occurred while waiting for image '{image_url}': {e}") - return None - - def _run_driver1_actions(self, driver, id1, pw): - # Initialize WebDriverWait for this specific driver instance - wait = WebDriverWait(driver, 10) - - # session 1 actions - driver.get("http://192.168.20.212/") - time.sleep(0.5) - 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(id1) - 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.get("http://192.168.20.212/#/dashboard/coord_dashboard-2.9") - # Wait for the dashboard URL - wait.until(EC.url_to_be("http://192.168.20.212/#/dashboard/coord_dashboard-2.9")) - - # --- WAITING FOR IMAGE AND MEASURING TIME --- - image_to_wait_for = 'http://192.168.20.212/image/custom/23_%ED%95%9C%EC%88%98%EC%9B%90_%ED%86%B5%ED%95%A9_%EB%B9%84%EC%A0%95%EC%83%81.png' - loading_time = self._wait_for_image_and_measure(driver, image_to_wait_for) - if loading_time is not None: - print(f"{id1}: Dashboard image loading time: {loading_time:.2f} seconds.") - # --- END IMAGE WAIT --- - - - driver.get("http://192.168.20.212/#/topologymap") - time.sleep(0.5) - - driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[2]/a/div").click() - driver.get("http://192.168.20.212/#/perf-oper/logical-1") - time.sleep(0.5) - - driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[3]/a/div").click() - driver.get("http://192.168.20.212/#/chart") - time.sleep(0.5) - - driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[4]/a/div").click() - driver.get("http://192.168.20.212/#/event/logical-1/event-status") - time.sleep(0.5) - - driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[5]/a/div").click() - driver.get("http://192.168.20.212/#/work") - time.sleep(0.5) - - driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[6]/a/div").click() - driver.get("http://192.168.20.212/#/report/report-1") - time.sleep(0.5) - - driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[7]/a/div").click() - time.sleep(1) - - def _run_driver2_actions(self, driver2, id2, pw): - # Initialize WebDriverWait for this specific driver instance - wait = WebDriverWait(driver2, 10) - - # session 2 actions - driver2.get("http://192.168.20.212/") - time.sleep(0.5) - driver2.find_element(By.XPATH, "//input[@type='text']").click() - driver2.find_element(By.XPATH, "//input[@type='text']").clear() - driver2.find_element(By.XPATH, "//input[@type='text']").send_keys(id2) - driver2.find_element(By.XPATH, "//input[@type='password']").clear() - driver2.find_element(By.XPATH, "//input[@type='password']").send_keys(pw) - driver2.find_element(By.XPATH, "//button[@type='button']").click() - - driver2.get("http://192.168.20.212/#/dashboard/coord_dashboard-0.2.9") - driver2.find_element_by_xpath( - "//div[@id='wrapper']/div/div/aside/div/div/div/div/article/div/div/div/div/div/div[2]/div/div[2]/div/div/span[2]/span/span").click() - - driver2.get("http://192.168.20.212/#/dashboard/coord_dashboard-0.2.9") - # Wait for the dashboard URL - wait.until(EC.url_to_be("http://192.168.20.212/#/dashboard/coord_dashboard-0.2.9")) - - # --- WAITING FOR IMAGE AND MEASURING TIME --- - image_to_wait_for = 'http://192.168.20.212/image/custom/23_%ED%95%9C%EC%88%98%EC%9B%90_%ED%86%B5%ED%95%A9_%EB%B9%84%EC%A0%95%EC%83%81.png' - loading_time = self._wait_for_image_and_measure(driver2, image_to_wait_for) - if loading_time is not None: - print(f"{id2}: Dashboard image loading time: {loading_time:.2f} seconds.") - # --- END IMAGE WAIT --- - - - driver2.get("http://192.168.20.212/#/topologymap") - time.sleep(0.5) - - driver2.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[2]/a/div").click() - driver2.get("http://192.168.20.212/#/perf-oper/logical-1") - time.sleep(0.5) - - driver2.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[3]/a/div").click() - driver2.get("http://192.168.20.212/#/chart") - time.sleep(0.5) - - driver2.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[4]/a/div").click() - driver2.get("http://192.168.20.212/#/event/logical-1/event-status") - time.sleep(0.5) - - driver2.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[5]/a/div").click() - driver2.get("http://192.168.20.212/#/work") - time.sleep(0.5) - - # Note: Original code had driver2 not clicking on li[6] - # driver2.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[6]/a/div").click() - # driver2.get("http://192.168.20.212/#/report/report-1") - time.sleep(0.5) # Still keeping this sleep for consistency - - driver2.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[7]/a/div").click() - time.sleep(1) - - def test_multiple(self): - driver = self.driver - driver2 = self.driver2 - - id1 = 'administrator' - id2 = 'local_manager' - id3 = 'manager' - id4 = 'user' - pw = 'watchall' - - #id4 = 'user' - #pw = 'watchall' - - # Create threads for each driver's actions - thread1 = threading.Thread(target=self._run_driver1_actions, args=(driver, id1, pw)) - thread2 = threading.Thread(target=self._run_driver2_actions, args=(driver2, id2, pw)) - - # Start the threads - thread1.start() - thread2.start() - - # Wait for both threads to complete - thread1.join() - thread2.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() # Ensure both drivers are quit - self.assertEqual([], self.verificationErrors) - -if __name__ == "__main__": - unittest.main() \ No newline at end of file diff --git a/MultipleTest.py b/MultipleTest.py deleted file mode 100644 index c34a59b..0000000 --- a/MultipleTest.py +++ /dev/null @@ -1,139 +0,0 @@ -# -*- 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 NoAlertPresentException -import unittest, time, re - -class MultipleTest(unittest.TestCase): - def setUp(self): - - options = webdriver.ChromeOptions() - options.add_experimental_option("excludeSwitches", ["enable-logging"]) # urlopen시 에러코드 발생 -> 불필요한 로그이기때문에 숨김 - options.add_argument('--start-maximized') # 크롬 1920*1080 사이즈로 실행 / 최대 : window-size=1920x1080 - options.add_argument('--incognito') # 시크릿 모드로 실행 - # options.add_argument('--headless') # 크롬 화면 표현하지 않는 설정 (테스트 동안은 주석처리) - - self.driver = webdriver.Chrome(executable_path=r'C:\Users\watchtek\Documents\chromedriver-win64\chromedriver.exe', options=options) - self.driver.implicitly_wait(30) - self.base_url = "about:blank" - self.verificationErrors = [] - self.accept_next_alert = True - - self.driver2 = webdriver.Chrome(executable_path=r'C:\Users\watchtek\Documents\chromedriver-win64\chromedriver.exe', options=options) - self.driver2.implicitly_wait(30) - - - def test_multiple(self): - driver = self.driver - driver2 = self.driver2 - - id1 = 'administrator' - id2 = 'local_manager' - id3 = 'manager' - id4 = 'user' - pw = 'watchall' - - # session 1 - driver.get("http://192.168.20.212/") - # session 2 - driver2.get("http://192.168.20.212/") - time.sleep(0.5) - - # session 1 - 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(id4) - 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.get("http://192.168.20.212/#/dashboard/coord_dashboard-2.9") - # session 2 - driver2.find_element_by_xpath("//input[@type='text']").click() - driver2.find_element_by_xpath("//input[@type='text']").clear() - driver2.find_element_by_xpath("//input[@type='text']").send_keys(id4) - driver2.find_element_by_xpath("//input[@type='password']").clear() - driver2.find_element_by_xpath("//input[@type='password']").send_keys(pw) - driver2.find_element_by_xpath("//button[@type='button']").click() - driver2.get("http://192.168.20.212/#/dashboard/coord_dashboard-2.9") - time.sleep(0.5) - - # session 1 - driver.get("http://192.168.20.212/#/topologymap") - # session 2 - driver2.get("http://192.168.20.212/#/topologymap") - time.sleep(0.5) - - # session 1 - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[2]/a/div").click() - driver.get("http://192.168.20.212/#/perf-oper/logical-1") - # session 2 - driver2.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[2]/a/div").click() - driver2.get("http://192.168.20.212/#/perf-oper/logical-1") - time.sleep(0.5) - - # session 1 - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[3]/a/div").click() - driver.get("http://192.168.20.212/#/chart") - # session 2 - driver2.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[3]/a/div").click() - driver2.get("http://192.168.20.212/#/chart") - time.sleep(0.5) - - # session 1 - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[4]/a/div").click() - driver.get("http://192.168.20.212/#/event/logical-1/event-status") - # session 2 - driver2.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[4]/a/div").click() - driver2.get("http://192.168.20.212/#/event/logical-1/event-status") - time.sleep(0.5) - - # session 1 - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[5]/a/div").click() - driver.get("http://192.168.20.212/#/work") - # session 2 - driver2.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[5]/a/div").click() - driver2.get("http://192.168.20.212/#/work") - time.sleep(0.5) - - # session 1 - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[6]/a/div").click() - driver.get("http://192.168.20.212/#/report/report-1") - # session 2 - time.sleep(0.5) - - # session 1 - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[7]/a/div").click() - # session 2 - driver2.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[7]/a/div").click() - time.sleep(1) - - 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.assertEqual([], self.verificationErrors) - -if __name__ == "__main__": - unittest.main() diff --git a/MultipleparagonParaell.py b/MultipleparagonParaell.py deleted file mode 100644 index 561d7e6..0000000 --- a/MultipleparagonParaell.py +++ /dev/null @@ -1,216 +0,0 @@ -# -*- 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.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(30) - self.base_url = "about:blank" - self.verificationErrors = [] - self.accept_next_alert = True - - # self.driver2 = webdriver.Chrome(executable_path=webdriver_path, options=options) - # self.driver2.implicitly_wait(30) - # - # self.driver3 = webdriver.Chrome(executable_path=webdriver_path, options=options) - # self.driver3.implicitly_wait(30) - # - # self.driver4 = webdriver.Chrome(executable_path=webdriver_path, options=options) - # self.driver4.implicitly_wait(30) - - # def _wait_for_image_and_measure(self, driver_instance, image_url, timeout=20): - # """ - # Waits for a specific image to load and measures the loading time. - # Returns the loading time in seconds if successful, None otherwise. - # """ - # start_time = time.time() - # try: - # # Create a WebDriverWait instance specifically for this driver and timeout - # image_wait = WebDriverWait(driver_instance, timeout) - # image_wait.until( - # lambda driver: driver.execute_script( - # f"var img = new Image(); img.src = '{image_url}'; return img.complete;" - # ) - # ) - # end_time = time.time() - # loading_time = end_time - start_time - # print(f"Image '{image_url}' loaded in {loading_time:.2f} seconds.") - # return loading_time - # except TimeoutException: - # print(f"Timeout waiting for image '{image_url}' to load.") - # return None - # except Exception as e: - # print(f"An error occurred while waiting for image '{image_url}': {e}") - # return None - - def _run_driver1_actions(self, driver, address, id, pw): - # Initialize WebDriverWait for this specific driver instance - wait = WebDriverWait(driver, 10) - - # session 1 actions - driver.get(address) - # time.sleep(0.5) - - 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() - - # time.sleep(0.5) - # driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/div[2]/label[2]/span/span").click() - # 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() - # Wait for and click elements after login - # Replace time.sleep() with explicit waits for each click - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/div/div/aside/div/div/div/div/div[2]/label[2]/span/span"))).click() - wait.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/div/span[2]/span/span"))).click() - - #driver.get("http://192.168.20.212/#/dashboard/coord_dashboard-2.9") - - # # Wait for the dashboard URL - # wait.until(EC.url_to_be("http://192.168.20.212/#/dashboard/coord_dashboard-2.9")) - # - # # --- WAITING FOR IMAGE AND MEASURING TIME --- - # image_to_wait_for = 'http://192.168.20.212/image/custom/23_%ED%95%9C%EC%88%98%EC%9B%90_%ED%86%B5%ED%95%A9_%EB%B9%84%EC%A0%95%EC%83%81.png' - # loading_time = self._wait_for_image_and_measure(driver, image_to_wait_for) - # if loading_time is not None: - # print(f"{id1}: Dashboard image loading time: {loading_time:.2f} seconds.") - # # --- END IMAGE WAIT --- - - - #driver.get("http://192.168.20.212/#/topologymap") - # time.sleep(0.5) - # - # driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[2]/a/div").click() - # #driver.get("http://192.168.20.212/#/perf-oper/logical-1") - # time.sleep(0.5) - # - # driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[3]/a/div").click() - # #driver.get("http://192.168.20.212/#/chart") - # time.sleep(0.5) - # - # driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[4]/a/div").click() - # #driver.get("http://192.168.20.212/#/event/logical-1/event-status") - # time.sleep(0.5) - # - # driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[5]/a/div").click() - # #driver.get("http://192.168.20.212/#/work") - # time.sleep(0.5) - # - # driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[6]/a/div").click() - # #driver.get("http://192.168.20.212/#/report/report-1") - # time.sleep(0.5) - # - # driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[7]/a/div").click() - - # --- Navigation Clicks with Explicit Waits --- - # topologymap - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[2]/a/div"))).click() - # perf-oper - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[3]/a/div"))).click() - # chart - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[4]/a/div"))).click() - # event-status - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[5]/a/div"))).click() - # work - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[6]/a/div"))).click() - # report - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[7]/a/div"))).click() - - time.sleep(1) - - def test_multiple(self): - driver = self.driver - # driver2 = self.driver2 - # driver3 = self.driver3 - # driver4 = self.driver4 - 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)) - # thread2 = threading.Thread(target=self._run_driver1_actions, args=(driver2, address, id2, pw)) - # thread3 = threading.Thread(target=self._run_driver1_actions, args=(driver3, address, id3, pw)) - # thread4 = threading.Thread(target=self._run_driver1_actions, args=(driver4, address, id4, pw)) - - - # Start the threads - thread1.start() - # thread2.start() - # thread3.start() - # thread4.start() - - # Wait for both threads to complete - thread1.join() - # thread2.join() - # thread3.join() - # thread4.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 diff --git a/WatchallFirstTest.py b/WatchallFirstTest.py deleted file mode 100644 index 5db0a42..0000000 --- a/WatchallFirstTest.py +++ /dev/null @@ -1,89 +0,0 @@ -# -*- 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 NoAlertPresentException -from selenium.webdriver.chrome.options import Options -import unittest, time, re - -class WatchallFirstTest(unittest.TestCase): - def setUp(self): - - options = webdriver.ChromeOptions() - options.add_experimental_option("excludeSwitches", ["enable-logging"]) # urlopen시 에러코드 발생 -> 불필요한 로그이기때문에 숨김 - options.add_argument('--start-maximized') # 크롬 1920*1080 사이즈로 실행 / 최대 : window-size=1920x1080 - options.add_argument('--incognito') # 시크릿 모드로 실행 - # options.add_argument('--headless') # 크롬 화면 표현하지 않는 설정 (테스트 동안은 주석처리) - - - self.driver = webdriver.Chrome(executable_path=r'C:\Users\watchtek\Documents\chromedriver-win64\chromedriver.exe', options=options) - # self.driver = webdriver.Chrome(executable_path=r'C:\Users\watchtek\PycharmProjects\Work_QA_AutomationTest_applemango-master\91\chromedriver.exe') - - self.driver.implicitly_wait(30) - self.base_url = "https://google.com" - self.verificationErrors = [] - self.accept_next_alert = True - - def test_watchall_first(self): - driver = self.driver - driver.get("https://watchall.biblio19.net/#/login") - driver.find_element_by_xpath("//input[@type='text']").clear() - driver.find_element_by_xpath("//input[@type='text']").send_keys("administrator") - driver.find_element_by_xpath("//input[@type='password']").clear() - driver.find_element_by_xpath("//input[@type='password']").send_keys("watchall") - driver.find_element_by_xpath("//div[@id='app']/div/div/div/div[2]/div[2]/button/span").click() - driver.get("https://watchall.biblio19.net/#/dashboard/grid_dashboard-1.2") - driver.get("https://watchall.biblio19.net/#/perf-oper/logical-1") - 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").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/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[2]/div/div[2]/div/div/span").click() - driver.get("https://watchall.biblio19.net/#/perf-oper/physical-1.NMS.8072.O2/summary") - 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() - driver.get("https://watchall.biblio19.net/#/perf-oper/physical-1.NMS.8072.O2/analysis") - driver.find_element_by_id("tab-analysis").click() - driver.get("https://watchall.biblio19.net/#/perf-oper/physical-1.NMS.8072.O2/operation") - driver.find_element_by_id("tab-operation").click() - driver.get("https://watchall.biblio19.net/#/perf-oper/physical-1.NMS.8072.O2/config") - driver.find_element_by_id("tab-config").click() - driver.get("https://watchall.biblio19.net/#/perf-oper/physical-1.NMS.8072.O2/event") - driver.find_element_by_id("tab-event").click() - driver.get("https://watchall.biblio19.net/#/event/physical-1.NMS.8072.O2/event-status") - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[6]/a/div").click() - driver.get("https://watchall.biblio19.net/#/event/physical-1/event-status") - 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() - driver.get("https://watchall.biblio19.net/#/event/physical-1/event-hist") - driver.find_element_by_id("tab-event-hist").click() - driver.find_element_by_xpath("//div[@id='wrapper']/header/div[2]/ul/li[7]/i").click() - driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='마지막 로그인 시각: 2025-07-16 09:00'])[1]/following::button[1]").click() - driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='아니오'])[1]/following::button[1]").click() - - 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.assertEqual([], self.verificationErrors) - -if __name__ == "__main__": - unittest.main() diff --git a/WatchallFirstTest_2.py b/WatchallFirstTest_2.py deleted file mode 100644 index 0fe78b4..0000000 --- a/WatchallFirstTest_2.py +++ /dev/null @@ -1,78 +0,0 @@ -# -*- 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 NoAlertPresentException -import unittest, time, re - -class WatchallFirstTest(unittest.TestCase): - def setUp(self): - self.driver = webdriver.Chrome(executable_path=r'C:\Users\watchtek\Documents\chrome-win64\chrome.exe') - self.driver.implicitly_wait(30) - self.base_url = "https://www.google.com/" - self.verificationErrors = [] - self.accept_next_alert = True - - def test_watchall_first(self): - driver = self.driver - driver.get("https://watchall.biblio19.net/#/login") - driver.find_element_by_xpath("//input[@type='text']").clear() - driver.find_element_by_xpath("//input[@type='text']").send_keys("administrator") - driver.find_element_by_xpath("//input[@type='password']").clear() - driver.find_element_by_xpath("//input[@type='password']").send_keys("watchall") - driver.find_element_by_xpath("//div[@id='app']/div/div/div/div[2]/div[2]/button/span").click() - driver.get("https://watchall.biblio19.net/#/dashboard/grid_dashboard-1.2") - driver.get("https://watchall.biblio19.net/#/perf-oper/logical-1") - 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").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/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[2]/div/div[2]/div/div/span").click() - driver.get("https://watchall.biblio19.net/#/perf-oper/physical-1.NMS.8072.O2/summary") - 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() - driver.get("https://watchall.biblio19.net/#/perf-oper/physical-1.NMS.8072.O2/analysis") - driver.find_element_by_id("tab-analysis").click() - driver.get("https://watchall.biblio19.net/#/perf-oper/physical-1.NMS.8072.O2/operation") - driver.find_element_by_id("tab-operation").click() - driver.get("https://watchall.biblio19.net/#/perf-oper/physical-1.NMS.8072.O2/config") - driver.find_element_by_id("tab-config").click() - driver.get("https://watchall.biblio19.net/#/perf-oper/physical-1.NMS.8072.O2/event") - driver.find_element_by_id("tab-event").click() - driver.get("https://watchall.biblio19.net/#/event/physical-1.NMS.8072.O2/event-status") - driver.find_element_by_xpath("//div[@id='wrapper']/nav/ul/li[6]/a/div").click() - driver.get("https://watchall.biblio19.net/#/event/physical-1/event-status") - 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() - driver.get("https://watchall.biblio19.net/#/event/physical-1/event-hist") - driver.find_element_by_id("tab-event-hist").click() - driver.find_element_by_xpath("//div[@id='wrapper']/header/div[2]/ul/li[7]/i").click() - driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='마지막 로그인 시각: 2025-07-16 09:00'])[1]/following::button[1]").click() - driver.find_element_by_xpath(u"(.//*[normalize-space(text()) and normalize-space(.)='아니오'])[1]/following::button[1]").click() - - 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.assertEqual([], self.verificationErrors) - -if __name__ == "__main__": - unittest.main() diff --git a/load-copy.py b/load-copy.py deleted file mode 100644 index e8bc8b1..0000000 --- a/load-copy.py +++ /dev/null @@ -1,414 +0,0 @@ -# -*- 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 - -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() - 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): - """ - 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. - - """ - # 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() - - 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() - - # 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 _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) - - # 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) - - ############################ - # 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) - - ############################ - # 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) - - # 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() - # 로그 분석 > 전체 로그 > 우측 상단 시간 조정(최근 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_for_la(driver) - - # 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) - - # 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 diff --git a/test_with_demo.py b/test_with_demo.py deleted file mode 100644 index 6f08968..0000000 --- a/test_with_demo.py +++ /dev/null @@ -1,216 +0,0 @@ -# -*- 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.1.11/' - - # 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(30) - self.base_url = "about:blank" - self.verificationErrors = [] - self.accept_next_alert = True - - # self.driver2 = webdriver.Chrome(executable_path=webdriver_path, options=options) - # self.driver2.implicitly_wait(30) - # - # self.driver3 = webdriver.Chrome(executable_path=webdriver_path, options=options) - # self.driver3.implicitly_wait(30) - # - # self.driver4 = webdriver.Chrome(executable_path=webdriver_path, options=options) - # self.driver4.implicitly_wait(30) - - def _wait_for_image_and_measure(self, driver_instance, image_url, timeout=20): - """ - Waits for a specific image to load and measures the loading time. - Returns the loading time in seconds if successful, None otherwise. - """ - start_time = time.time() - try: - # Create a WebDriverWait instance specifically for this driver and timeout - image_wait = WebDriverWait(driver_instance, timeout) - image_wait.until( - lambda driver: driver.execute_script( - f"var img = new Image(); img.src = '{image_url}'; return img.complete;" - ) - ) - end_time = time.time() - loading_time = end_time - start_time - print(f"Image '{image_url}' loaded in {loading_time:.2f} seconds.") - return loading_time - except TimeoutException: - print(f"Timeout waiting for image '{image_url}' to load.") - return None - except Exception as e: - print(f"An error occurred while waiting for image '{image_url}': {e}") - return None - - def _run_driver1_actions(self, driver, address, id, pw): - # Initialize WebDriverWait for this specific driver instance - wait = WebDriverWait(driver, 10) - - # session 1 actions - driver.get(address) - # time.sleep(0.5) - - 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() - - # time.sleep(0.5) - # driver.find_element_by_xpath("//div[@id='wrapper']/div/div/aside/div/div/div/div/div[2]/label[2]/span/span").click() - # 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() - # Wait for and click elements after login - # Replace time.sleep() with explicit waits for each click - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/div/div/aside/div/div/div/div/div[2]/label[2]/span/span"))).click() - wait.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/div/span[2]/span/span"))).click() - - #driver.get("http://192.168.20.212/#/dashboard/coord_dashboard-2.9") - - # # Wait for the dashboard URL - # wait.until(EC.url_to_be("http://192.168.20.212/#/dashboard/coord_dashboard-2.9")) - # - # # --- WAITING FOR IMAGE AND MEASURING TIME --- - # image_to_wait_for = 'http://192.168.20.212/image/custom/23_%ED%95%9C%EC%88%98%EC%9B%90_%ED%86%B5%ED%95%A9_%EB%B9%84%EC%A0%95%EC%83%81.png' - # loading_time = self._wait_for_image_and_measure(driver, image_to_wait_for) - # if loading_time is not None: - # print(f"{id1}: Dashboard image loading time: {loading_time:.2f} seconds.") - # # --- END IMAGE WAIT --- - - - #driver.get("http://192.168.20.212/#/topologymap") - # time.sleep(0.5) - # - # driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[2]/a/div").click() - # #driver.get("http://192.168.20.212/#/perf-oper/logical-1") - # time.sleep(0.5) - # - # driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[3]/a/div").click() - # #driver.get("http://192.168.20.212/#/chart") - # time.sleep(0.5) - # - # driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[4]/a/div").click() - # #driver.get("http://192.168.20.212/#/event/logical-1/event-status") - # time.sleep(0.5) - # - # driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[5]/a/div").click() - # #driver.get("http://192.168.20.212/#/work") - # time.sleep(0.5) - # - # driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[6]/a/div").click() - # #driver.get("http://192.168.20.212/#/report/report-1") - # time.sleep(0.5) - # - # driver.find_element(By.XPATH, "//div[@id='wrapper']/nav/ul/li[7]/a/div").click() - - # --- Navigation Clicks with Explicit Waits --- - # topologymap - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[2]/a/div"))).click() - # perf-oper - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[3]/a/div"))).click() - # chart - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[4]/a/div"))).click() - # event-status - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[5]/a/div"))).click() - # work - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[6]/a/div"))).click() - # report - wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@id='wrapper']/nav/ul/li[7]/a/div"))).click() - - time.sleep(1) - - def test_multiple(self): - driver = self.driver - # driver2 = self.driver2 - # driver3 = self.driver3 - # driver4 = self.driver4 - 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)) - # thread2 = threading.Thread(target=self._run_driver1_actions, args=(driver2, address, id2, pw)) - # thread3 = threading.Thread(target=self._run_driver1_actions, args=(driver3, address, id3, pw)) - # thread4 = threading.Thread(target=self._run_driver1_actions, args=(driver4, address, id4, pw)) - - - # Start the threads - thread1.start() - # thread2.start() - # thread3.start() - # thread4.start() - - # Wait for both threads to complete - thread1.join() - # thread2.join() - # thread3.join() - # thread4.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 -- GitLab