Commit c73b4e9d authored by Watchtek's avatar Watchtek
Browse files

Merge branch 'dev' into 'main'

Remove old file

See merge request !1
parents a31b590b 6f3101e1
Loading
Loading
Loading
Loading
Loading

2ndTest_3.py

deleted100644 → 0
+0 −90
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 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()

InternalTest.py

deleted100644 → 0
+0 −91
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 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()

MultipleParaell.py

deleted100644 → 0
+0 −217
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('--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

MultipleTest.py

deleted100644 → 0
+0 −139
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 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()

MultipleparagonParaell.py

deleted100644 → 0
+0 −216

File deleted.

Preview size limit exceeded, changes collapsed.

Loading