From b04281fecd1aa430c1210f216baa4c91c01991b4 Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 15:33:41 +0530 Subject: [PATCH 01/21] Initial e2e test setup --- .github/workflows/ci-test.yaml | 8 ++++++++ tests/e2e/requirements.txt | 5 +++++ tests/e2e/test_login.py | 34 ++++++++++++++++++++++++++++++++++ tox.ini | 14 +++++++++++++- 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 tests/e2e/requirements.txt create mode 100644 tests/e2e/test_login.py diff --git a/.github/workflows/ci-test.yaml b/.github/workflows/ci-test.yaml index 06ce1aa10..3ed3948ff 100644 --- a/.github/workflows/ci-test.yaml +++ b/.github/workflows/ci-test.yaml @@ -45,6 +45,13 @@ jobs: recreate: true path: runner-report.md + - name: Render the e2e report to the PR + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: e2e-test-report + recreate: true + path: e2e-report.md + - name: Output reports to the job summary when tests fail shell: bash run: | @@ -52,6 +59,7 @@ jobs: echo "
Runner Test Report" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY cat "runner-report.md" >> $GITHUB_STEP_SUMMARY + cat "e2e-report.md" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "
" >> $GITHUB_STEP_SUMMARY fi diff --git a/tests/e2e/requirements.txt b/tests/e2e/requirements.txt new file mode 100644 index 000000000..4d219ea4d --- /dev/null +++ b/tests/e2e/requirements.txt @@ -0,0 +1,5 @@ +pytest~=8.0 +pytest-mock~=3.0 +pytest-cov~=6.0 +pytest-md-report~=0.6.0 +selenium~=4.28 diff --git a/tests/e2e/test_login.py b/tests/e2e/test_login.py new file mode 100644 index 000000000..2a91fc573 --- /dev/null +++ b/tests/e2e/test_login.py @@ -0,0 +1,34 @@ +from selenium import webdriver +from selenium.webdriver.chrome.options import Options +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.common.by import By + + +class TestLogin: + def setup_method(self, method): + options = Options() + options.add_argument("--headless=new") + self.driver = webdriver.Chrome(options=options) + + def teardown_method(self, method): + self.driver.quit() + + def test_login(self): + self.driver.get("http://frontend.unstract.localhost") + self.driver.implicitly_wait(0.5) + self.driver.set_window_size(960, 615) + # 3 | click | css=span | + self.driver.find_element(By.CSS_SELECTOR, "span").click() + # 4 | click | id=username | + self.driver.find_element(By.ID, "username").click() + # 5 | type | id=username | unstract + self.driver.find_element(By.ID, "username").send_keys("unstract") + # 6 | type | id=password | unstract + self.driver.find_element(By.ID, "password").send_keys("unstract") + # 7 | click | css=input:nth-child(11) | + self.driver.find_element(By.CSS_SELECTOR, "input:nth-child(11)").click() + WebDriverWait(self.driver, timeout=5).until( + lambda _: self.driver.current_url.endswith("/mock_org/onboard"), + "Login failed." + ) + self.driver.close() diff --git a/tox.ini b/tox.ini index 196cf0602..a31c99098 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -env_list = py{39,310,311}, runner +env_list = py{39,310,311}, runner, e2e # [testenv] # skip_install = true @@ -17,3 +17,15 @@ commands_pre = sh -c '[ -f cloud_requirements.txt ] && pip install -r cloud_requirements.txt || echo "cloud_requirements.txt not found"' commands = pytest -v --md-report-verbose=1 --md-report --md-report-flavor gfm --md-report-output ../runner-report.md + +[testenv:e2e] +deps = pip +allowlist_externals= + sh +commands_pre = + pip install -r tests/e2e/requirements.txt + ./run-platform.sh -b + sleep 30 + docker compose -f docker/docker-compose.yaml ps -a +commands = + pytest -v --md-report-verbose=1 --md-report --md-report-flavor gfm --md-report-output ../e2e-report.md tests/e2e/ From 04428a103ee154819b4c4214f12669172f95a8fd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 10:04:50 +0000 Subject: [PATCH 02/21] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/e2e/test_login.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/test_login.py b/tests/e2e/test_login.py index 2a91fc573..181908492 100644 --- a/tests/e2e/test_login.py +++ b/tests/e2e/test_login.py @@ -1,7 +1,7 @@ from selenium import webdriver from selenium.webdriver.chrome.options import Options -from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait class TestLogin: @@ -29,6 +29,6 @@ def test_login(self): self.driver.find_element(By.CSS_SELECTOR, "input:nth-child(11)").click() WebDriverWait(self.driver, timeout=5).until( lambda _: self.driver.current_url.endswith("/mock_org/onboard"), - "Login failed." + "Login failed.", ) self.driver.close() From f0bbc43a2553e652af5377137e95de7d76e6c7f9 Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 15:39:13 +0530 Subject: [PATCH 03/21] Corrected the runplatform script portion to use sh --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index a31c99098..117746578 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ allowlist_externals= sh commands_pre = pip install -r tests/e2e/requirements.txt - ./run-platform.sh -b + sh run-platform.sh -b sleep 30 docker compose -f docker/docker-compose.yaml ps -a commands = From ba5c9577c69019536aa423f49f693662d343d9ca Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 15:48:20 +0530 Subject: [PATCH 04/21] Removed the e2e test from env list --- .github/workflows/ci-test.yaml | 8 -------- tox.ini | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/ci-test.yaml b/.github/workflows/ci-test.yaml index 3ed3948ff..06ce1aa10 100644 --- a/.github/workflows/ci-test.yaml +++ b/.github/workflows/ci-test.yaml @@ -45,13 +45,6 @@ jobs: recreate: true path: runner-report.md - - name: Render the e2e report to the PR - uses: marocchino/sticky-pull-request-comment@v2 - with: - header: e2e-test-report - recreate: true - path: e2e-report.md - - name: Output reports to the job summary when tests fail shell: bash run: | @@ -59,7 +52,6 @@ jobs: echo "
Runner Test Report" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY cat "runner-report.md" >> $GITHUB_STEP_SUMMARY - cat "e2e-report.md" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "
" >> $GITHUB_STEP_SUMMARY fi diff --git a/tox.ini b/tox.ini index 117746578..eeee4bd9c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -env_list = py{39,310,311}, runner, e2e +env_list = py{39,310,311}, runner # [testenv] # skip_install = true From d3d91edeb9586629c9872b98e0d8fa42422e0512 Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 15:52:37 +0530 Subject: [PATCH 05/21] Trying to run the e2e tox in build workflow --- .github/workflows/ci-container-build.yaml | 39 +++++++++++++++++++++++ tox.ini | 6 ---- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-container-build.yaml b/.github/workflows/ci-container-build.yaml index bb555ec5d..d7b9823a0 100644 --- a/.github/workflows/ci-container-build.yaml +++ b/.github/workflows/ci-container-build.yaml @@ -49,3 +49,42 @@ jobs: exit 1 fi docker compose -f docker/docker-compose.yaml down -v + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.9' + + - name: Cache tox environments + uses: actions/cache@v4 + with: + path: .tox/ + key: ${{ runner.os }}-tox-${{ hashFiles('**/pyproject.toml', '**/tox.ini') }} + restore-keys: | + ${{ runner.os }}-tox- + + - name: Install tox + run: pip install tox + + - name: Run tox + id: tox + run: | + tox -e e2e + + - name: Render the report to the PR + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: e2e-test-report + recreate: true + path: e2e-report.md + + - name: Output reports to the job summary when tests fail + shell: bash + run: | + if [ -f "e2e-report.md" ]; then + echo "
E2E Test Report" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + cat "e2e-report.md" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY + fi diff --git a/tox.ini b/tox.ini index eeee4bd9c..eb978d0d2 100644 --- a/tox.ini +++ b/tox.ini @@ -19,13 +19,7 @@ commands = pytest -v --md-report-verbose=1 --md-report --md-report-flavor gfm --md-report-output ../runner-report.md [testenv:e2e] -deps = pip -allowlist_externals= - sh commands_pre = pip install -r tests/e2e/requirements.txt - sh run-platform.sh -b - sleep 30 - docker compose -f docker/docker-compose.yaml ps -a commands = pytest -v --md-report-verbose=1 --md-report --md-report-flavor gfm --md-report-output ../e2e-report.md tests/e2e/ From 643ea78f50b66887bdc418b7bc8e741a7626acdf Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 15:55:47 +0530 Subject: [PATCH 06/21] Corrected build workflow yaml indendation --- .github/workflows/ci-container-build.yaml | 68 ++++++++++++----------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci-container-build.yaml b/.github/workflows/ci-container-build.yaml index d7b9823a0..8ea0eca94 100644 --- a/.github/workflows/ci-container-build.yaml +++ b/.github/workflows/ci-container-build.yaml @@ -17,11 +17,13 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Container Run run: | ./run-platform.sh -b @@ -50,41 +52,41 @@ jobs: fi docker compose -f docker/docker-compose.yaml down -v - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.9' + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.9' - - name: Cache tox environments - uses: actions/cache@v4 - with: - path: .tox/ - key: ${{ runner.os }}-tox-${{ hashFiles('**/pyproject.toml', '**/tox.ini') }} - restore-keys: | - ${{ runner.os }}-tox- + - name: Cache tox environments + uses: actions/cache@v4 + with: + path: .tox/ + key: ${{ runner.os }}-tox-${{ hashFiles('**/pyproject.toml', '**/tox.ini') }} + restore-keys: | + ${{ runner.os }}-tox- - - name: Install tox - run: pip install tox + - name: Install tox + run: pip install tox - - name: Run tox - id: tox - run: | - tox -e e2e + - name: Run tox + id: tox + run: | + tox -e e2e - - name: Render the report to the PR - uses: marocchino/sticky-pull-request-comment@v2 - with: - header: e2e-test-report - recreate: true - path: e2e-report.md + - name: Render the report to the PR + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: e2e-test-report + recreate: true + path: e2e-report.md - - name: Output reports to the job summary when tests fail - shell: bash - run: | - if [ -f "e2e-report.md" ]; then - echo "
E2E Test Report" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - cat "e2e-report.md" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "
" >> $GITHUB_STEP_SUMMARY - fi + - name: Output reports to the job summary when tests fail + shell: bash + run: | + if [ -f "e2e-report.md" ]; then + echo "
E2E Test Report" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + cat "e2e-report.md" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY + fi From e88b137c5cb503d67c3a936c1d399e2f5c474ee1 Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 16:52:00 +0530 Subject: [PATCH 07/21] Added waiting logic for container load --- tests/e2e/test_login.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/e2e/test_login.py b/tests/e2e/test_login.py index 181908492..6d28dcba8 100644 --- a/tests/e2e/test_login.py +++ b/tests/e2e/test_login.py @@ -13,8 +13,20 @@ def setup_method(self, method): def teardown_method(self, method): self.driver.quit() + def _check_page_load(self): + try: + self.driver.get("http://frontend.unstract.localhost") + except Exception as e: + print(f"Page load exception: {e}") + return False + else: + return True + def test_login(self): - self.driver.get("http://frontend.unstract.localhost") + WebDriverWait(self.driver, timeout=30, poll_frequency=2).until( + lambda _: self._check_page_load(), + "Page load failed", + ) self.driver.implicitly_wait(0.5) self.driver.set_window_size(960, 615) # 3 | click | css=span | From 6346ba40002d2bd45b989b201fb414afb383b030 Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 18:08:43 +0530 Subject: [PATCH 08/21] Debugging network issue --- .github/workflows/ci-container-build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-container-build.yaml b/.github/workflows/ci-container-build.yaml index 8ea0eca94..3a91f7ae9 100644 --- a/.github/workflows/ci-container-build.yaml +++ b/.github/workflows/ci-container-build.yaml @@ -26,7 +26,7 @@ jobs: - name: Container Run run: | - ./run-platform.sh -b + ./run-platform.sh sleep 30 docker compose -f docker/docker-compose.yaml ps -a # Get the names of exited containers @@ -51,6 +51,7 @@ jobs: exit 1 fi docker compose -f docker/docker-compose.yaml down -v + curl -vvv http://frontend.unstract.localhost - name: Set up Python uses: actions/setup-python@v5 From 05879cf425abe973c25de239fc5c554a76c1d7af Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 20:10:21 +0530 Subject: [PATCH 09/21] Corrected the docker compose down part --- .github/workflows/ci-container-build.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-container-build.yaml b/.github/workflows/ci-container-build.yaml index 3a91f7ae9..098da3dbb 100644 --- a/.github/workflows/ci-container-build.yaml +++ b/.github/workflows/ci-container-build.yaml @@ -26,7 +26,7 @@ jobs: - name: Container Run run: | - ./run-platform.sh + ./run-platform.sh -b sleep 30 docker compose -f docker/docker-compose.yaml ps -a # Get the names of exited containers @@ -50,7 +50,6 @@ jobs: docker compose -f docker/docker-compose.yaml down -v exit 1 fi - docker compose -f docker/docker-compose.yaml down -v curl -vvv http://frontend.unstract.localhost - name: Set up Python From 2cd421ecbad5ffc0f49c6801273d5d60dd28bb37 Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 20:17:34 +0530 Subject: [PATCH 10/21] Added docker tear down step --- .github/workflows/ci-container-build.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-container-build.yaml b/.github/workflows/ci-container-build.yaml index 098da3dbb..259930c67 100644 --- a/.github/workflows/ci-container-build.yaml +++ b/.github/workflows/ci-container-build.yaml @@ -90,3 +90,5 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY fi + - name: Stop any running containers + run: docker compose -f docker/docker-compose.yaml down -v From 131a3ba31813b16b0f579bf1aea45e5581590669 Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 20:26:31 +0530 Subject: [PATCH 11/21] Changed the css selector for login button --- tests/e2e/test_login.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/test_login.py b/tests/e2e/test_login.py index 6d28dcba8..925331bb1 100644 --- a/tests/e2e/test_login.py +++ b/tests/e2e/test_login.py @@ -30,7 +30,7 @@ def test_login(self): self.driver.implicitly_wait(0.5) self.driver.set_window_size(960, 615) # 3 | click | css=span | - self.driver.find_element(By.CSS_SELECTOR, "span").click() + self.driver.find_element(By.CSS_SELECTOR, "button").click() # 4 | click | id=username | self.driver.find_element(By.ID, "username").click() # 5 | type | id=username | unstract From 4058d2f32acd2d8267de1ef98e63732ac9302635 Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 20:41:20 +0530 Subject: [PATCH 12/21] Added explicit wait --- tests/e2e/test_login.py | 54 +++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/tests/e2e/test_login.py b/tests/e2e/test_login.py index 925331bb1..2fc1c02d4 100644 --- a/tests/e2e/test_login.py +++ b/tests/e2e/test_login.py @@ -2,12 +2,17 @@ from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC class TestLogin: def setup_method(self, method): options = Options() options.add_argument("--headless=new") + options.add_argument("--disable-gpu") + options.add_argument("--window-size=1920,1080") + options.add_argument("--disable-dev-shm-usage") + options.add_argument("--no-sandbox") self.driver = webdriver.Chrome(options=options) def teardown_method(self, method): @@ -23,24 +28,47 @@ def _check_page_load(self): return True def test_login(self): + # Wait for the page to load WebDriverWait(self.driver, timeout=30, poll_frequency=2).until( lambda _: self._check_page_load(), "Page load failed", ) - self.driver.implicitly_wait(0.5) + + # Set the window size self.driver.set_window_size(960, 615) - # 3 | click | css=span | - self.driver.find_element(By.CSS_SELECTOR, "button").click() - # 4 | click | id=username | - self.driver.find_element(By.ID, "username").click() - # 5 | type | id=username | unstract - self.driver.find_element(By.ID, "username").send_keys("unstract") - # 6 | type | id=password | unstract - self.driver.find_element(By.ID, "password").send_keys("unstract") - # 7 | click | css=input:nth-child(11) | - self.driver.find_element(By.CSS_SELECTOR, "input:nth-child(11)").click() - WebDriverWait(self.driver, timeout=5).until( + + # Explicit wait for the button to be clickable + WebDriverWait(self.driver, timeout=10).until( + EC.element_to_be_clickable((By.CSS_SELECTOR, "button")), + "Button not clickable.", + ).click() + + # Explicit wait for the username field to be visible + username_field = WebDriverWait(self.driver, timeout=10).until( + EC.visibility_of_element_located((By.ID, "username")), + "Username field not visible.", + ) + username_field.click() + username_field.send_keys("unstract") + + # Explicit wait for the password field to be visible + password_field = WebDriverWait(self.driver, timeout=10).until( + EC.visibility_of_element_located((By.ID, "password")), + "Password field not visible.", + ) + password_field.send_keys("unstract") + + # Explicit wait for the login button to be clickable + WebDriverWait(self.driver, timeout=10).until( + EC.element_to_be_clickable((By.CSS_SELECTOR, "input:nth-child(11)")), + "Login button not clickable.", + ).click() + + # Wait for the URL to change to indicate successful login + WebDriverWait(self.driver, timeout=10).until( lambda _: self.driver.current_url.endswith("/mock_org/onboard"), - "Login failed.", + "Login failed or URL did not change.", ) + + # Close the browser self.driver.close() From e1bc12ac750bf59eb3f19c7889d2e666e404e26e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 15:12:07 +0000 Subject: [PATCH 13/21] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/e2e/test_login.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/test_login.py b/tests/e2e/test_login.py index 2fc1c02d4..02e9ac61f 100644 --- a/tests/e2e/test_login.py +++ b/tests/e2e/test_login.py @@ -1,8 +1,8 @@ from selenium import webdriver from selenium.webdriver.chrome.options import Options 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.webdriver.support.ui import WebDriverWait class TestLogin: From 09b4c30becbe249b42b75082ec61ff994c46f8cf Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 21:06:58 +0530 Subject: [PATCH 14/21] added chrome and chrome dirver installtion --- .github/workflows/ci-container-build.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci-container-build.yaml b/.github/workflows/ci-container-build.yaml index 259930c67..b2de1475a 100644 --- a/.github/workflows/ci-container-build.yaml +++ b/.github/workflows/ci-container-build.yaml @@ -57,6 +57,11 @@ jobs: with: python-version: '3.9' + - uses: browser-actions/setup-chrome@v1 + with: + chrome-version: 126 + install-chromedriver: true + - name: Cache tox environments uses: actions/cache@v4 with: From e63a2bf29a6a93305d339d2b34b46573b1e84c6d Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 21:18:28 +0530 Subject: [PATCH 15/21] added chrome and chrome dirver installtion --- .github/workflows/ci-container-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-container-build.yaml b/.github/workflows/ci-container-build.yaml index b2de1475a..483200306 100644 --- a/.github/workflows/ci-container-build.yaml +++ b/.github/workflows/ci-container-build.yaml @@ -59,7 +59,7 @@ jobs: - uses: browser-actions/setup-chrome@v1 with: - chrome-version: 126 + chrome-version: latest install-chromedriver: true - name: Cache tox environments From 9c7b9e9d1897ce6a93483dc679c0ef1fff9f0394 Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Fri, 31 Jan 2025 21:35:03 +0530 Subject: [PATCH 16/21] Added driver installation via code --- .github/workflows/ci-container-build.yaml | 2 +- tests/e2e/requirements.txt | 1 + tests/e2e/test_login.py | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-container-build.yaml b/.github/workflows/ci-container-build.yaml index 483200306..9b0bc324b 100644 --- a/.github/workflows/ci-container-build.yaml +++ b/.github/workflows/ci-container-build.yaml @@ -60,7 +60,7 @@ jobs: - uses: browser-actions/setup-chrome@v1 with: chrome-version: latest - install-chromedriver: true + install-chromedriver: false - name: Cache tox environments uses: actions/cache@v4 diff --git a/tests/e2e/requirements.txt b/tests/e2e/requirements.txt index 4d219ea4d..150a6c4ec 100644 --- a/tests/e2e/requirements.txt +++ b/tests/e2e/requirements.txt @@ -3,3 +3,4 @@ pytest-mock~=3.0 pytest-cov~=6.0 pytest-md-report~=0.6.0 selenium~=4.28 +webdriver-manager~=4.0 diff --git a/tests/e2e/test_login.py b/tests/e2e/test_login.py index 02e9ac61f..4db6afa1c 100644 --- a/tests/e2e/test_login.py +++ b/tests/e2e/test_login.py @@ -1,8 +1,10 @@ from selenium import webdriver from selenium.webdriver.chrome.options import Options +from selenium.webdriver.chrome.service import Service as ChromeService from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait +from webdriver_manager.chrome import ChromeDriverManager class TestLogin: @@ -13,7 +15,7 @@ def setup_method(self, method): options.add_argument("--window-size=1920,1080") options.add_argument("--disable-dev-shm-usage") options.add_argument("--no-sandbox") - self.driver = webdriver.Chrome(options=options) + self.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options) def teardown_method(self, method): self.driver.quit() From bbfb5b8b36ba8dd8a1bff26ead4fb36b6d62d9d6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 16:06:31 +0000 Subject: [PATCH 17/21] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/e2e/test_login.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/e2e/test_login.py b/tests/e2e/test_login.py index 4db6afa1c..467beca08 100644 --- a/tests/e2e/test_login.py +++ b/tests/e2e/test_login.py @@ -15,7 +15,9 @@ def setup_method(self, method): options.add_argument("--window-size=1920,1080") options.add_argument("--disable-dev-shm-usage") options.add_argument("--no-sandbox") - self.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options) + self.driver = webdriver.Chrome( + service=ChromeService(ChromeDriverManager().install()), options=options + ) def teardown_method(self, method): self.driver.quit() From c2f62e1d4ee4f1c981c9457696ba0fd31cb1a5ad Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Sat, 1 Feb 2025 01:15:06 +0530 Subject: [PATCH 18/21] Added additional log and logic for debugging --- tests/e2e/test_login.py | 14 +++++++------- tox.ini | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/e2e/test_login.py b/tests/e2e/test_login.py index 4db6afa1c..25cb9e8c7 100644 --- a/tests/e2e/test_login.py +++ b/tests/e2e/test_login.py @@ -11,11 +11,8 @@ class TestLogin: def setup_method(self, method): options = Options() options.add_argument("--headless=new") - options.add_argument("--disable-gpu") - options.add_argument("--window-size=1920,1080") - options.add_argument("--disable-dev-shm-usage") - options.add_argument("--no-sandbox") self.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options) + self.driver.implicitly_wait(5) def teardown_method(self, method): self.driver.quit() @@ -31,17 +28,20 @@ def _check_page_load(self): def test_login(self): # Wait for the page to load - WebDriverWait(self.driver, timeout=30, poll_frequency=2).until( + WebDriverWait(self.driver, timeout=30).until( lambda _: self._check_page_load(), "Page load failed", ) - + WebDriverWait(self.driver, timeout=30).until( + EC.presence_of_element_located((By.CLASS_NAME, "login-main")) + ) + print(self.driver.find_element(By.CLASS_NAME, "login-main").text) # Set the window size self.driver.set_window_size(960, 615) # Explicit wait for the button to be clickable WebDriverWait(self.driver, timeout=10).until( - EC.element_to_be_clickable((By.CSS_SELECTOR, "button")), + EC.element_to_be_clickable((By.CSS_SELECTOR, "span")), "Button not clickable.", ).click() diff --git a/tox.ini b/tox.ini index eb978d0d2..bdd9bdaea 100644 --- a/tox.ini +++ b/tox.ini @@ -22,4 +22,4 @@ commands = commands_pre = pip install -r tests/e2e/requirements.txt commands = - pytest -v --md-report-verbose=1 --md-report --md-report-flavor gfm --md-report-output ../e2e-report.md tests/e2e/ + pytest -s -v --md-report-verbose=1 --md-report --md-report-flavor gfm --md-report-output ../e2e-report.md tests/e2e/ From 903ab81aecfd42b8387237d135c2670383df209a Mon Sep 17 00:00:00 2001 From: Ritwik G Date: Sat, 1 Feb 2025 01:27:27 +0530 Subject: [PATCH 19/21] corrected the report path for e2e test --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index bdd9bdaea..52cb7f7db 100644 --- a/tox.ini +++ b/tox.ini @@ -22,4 +22,4 @@ commands = commands_pre = pip install -r tests/e2e/requirements.txt commands = - pytest -s -v --md-report-verbose=1 --md-report --md-report-flavor gfm --md-report-output ../e2e-report.md tests/e2e/ + pytest -s -v --md-report-verbose=1 --md-report --md-report-flavor gfm --md-report-output e2e-report.md tests/e2e/ From bfcf2ea7c3348919e30a75589bc3c6ce09b02a54 Mon Sep 17 00:00:00 2001 From: Ritwik G <100672805+ritwik-g@users.noreply.github.com> Date: Sun, 2 Feb 2025 15:06:12 +0530 Subject: [PATCH 20/21] Added title to E2E test report message Signed-off-by: Ritwik G <100672805+ritwik-g@users.noreply.github.com> --- .github/workflows/ci-container-build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-container-build.yaml b/.github/workflows/ci-container-build.yaml index 9b0bc324b..333aa5a59 100644 --- a/.github/workflows/ci-container-build.yaml +++ b/.github/workflows/ci-container-build.yaml @@ -76,7 +76,8 @@ jobs: - name: Run tox id: tox run: | - tox -e e2e + tox -e e2e && + echo -e "## E2E Tests\n\n$(cat e2e-report.md)" > e2e-report.md - name: Render the report to the PR uses: marocchino/sticky-pull-request-comment@v2 From 3a7005d9f48c35597af9f866ecdc93e945ae4d44 Mon Sep 17 00:00:00 2001 From: Ritwik G <100672805+ritwik-g@users.noreply.github.com> Date: Sun, 2 Feb 2025 15:20:56 +0530 Subject: [PATCH 21/21] Updated echo with printf to preserve special characters in the report Signed-off-by: Ritwik G <100672805+ritwik-g@users.noreply.github.com> --- .github/workflows/ci-container-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-container-build.yaml b/.github/workflows/ci-container-build.yaml index 333aa5a59..82d7552b1 100644 --- a/.github/workflows/ci-container-build.yaml +++ b/.github/workflows/ci-container-build.yaml @@ -77,7 +77,7 @@ jobs: id: tox run: | tox -e e2e && - echo -e "## E2E Tests\n\n$(cat e2e-report.md)" > e2e-report.md + printf '$$\\textcolor{#0051db}{\\tt{E2E\\ Tests}}$$\n\n%s' "$(cat e2e-report.md)" > e2e-report.md - name: Render the report to the PR uses: marocchino/sticky-pull-request-comment@v2