From 537794e90293d448f4165fb67e12c061733a3bb4 Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 19 May 2026 01:23:48 -0300 Subject: [PATCH 1/5] Add test_new_items_cycle --- tests/test_folder_configuration_buttons.py | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/test_folder_configuration_buttons.py diff --git a/tests/test_folder_configuration_buttons.py b/tests/test_folder_configuration_buttons.py new file mode 100644 index 00000000..c7fa5a6f --- /dev/null +++ b/tests/test_folder_configuration_buttons.py @@ -0,0 +1,53 @@ +from selenium.webdriver import ActionChains +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +import pytest +import random, string + +def rnd(k): + return ''.join(random.choices(string.ascii_letters + string.digits, k=k)) + +@pytest.mark.dependency +def test_create_folder(browser): + wait = WebDriverWait(browser, 10) + wait.until(EC.visibility_of_element_located((By.XPATH, '//*[@href="/view/all/newJob"]'))).click() + wait.until(EC.visibility_of_element_located((By.XPATH, "//*[@id='name']"))).send_keys("Folder") + wait.until(EC.visibility_of_element_located((By.XPATH, "//span[text()='Folder']"))).click() + wait.until(EC.visibility_of_element_located((By.XPATH, "//button[@id='ok-button']"))).click() + wait.until(EC.element_to_be_clickable((By.ID, "jenkins-head-icon"))).click() + + actions = ActionChains(browser) + parent_element = browser.find_element(By.XPATH, "//*[@href='job/Folder/']") + actions.move_to_element(parent_element).perform() + browser.find_element(By.XPATH, "//button[contains(@data-href, '/job/Folder/')]").click() + browser.find_element(By.XPATH, "//a[contains(@href, 'configure')]").click() + # browser.find_element(By.XPATH, "//button[@data-id='ok']").click() + # wait = WebDriverWait(browser, 10) + # wait.until(expected_conditions.element_to_be_clickable((By.ID, "jenkins-head-icon"))).click() + # assert пользователь на странице конфигурации + +@pytest.mark.dependency(depends=["test_create_folder"]) +def test_config_save(browser): + wait = WebDriverWait(browser, 10) + wait.until(EC.visibility_of_element_located((By.XPATH, "//a[contains(@href, 'newJob')]"))) + browser.get("http://localhost:8080/job/Folder/configure") + wait.until(EC.visibility_of_element_located((By.XPATH, '//input[@name="_.displayNameOrNull"]'))).send_keys(rnd(15)) + wait.until(EC.visibility_of_element_located((By.XPATH, '//textarea[@name="_.description"]'))).send_keys(rnd(50)) + wait.until(EC.visibility_of_element_located((By.XPATH, '//button[@name = "Submit"]'))).click() + + assert ("configure" not in browser.current_url), "Url changed, Save button redirected" + +@pytest.mark.dependency(depends=["test_create_folder"]) +def test_config_apply(browser): + wait = WebDriverWait(browser, 10) + wait.until(EC.visibility_of_element_located((By.XPATH, "//a[contains(@href, 'newJob')]"))) + browser.get("http://localhost:8080/job/Folder/configure") + wait.until(EC.element_to_be_clickable((By.XPATH, '//input[@name="_.displayNameOrNull"]'))).clear() + wait.until(EC.element_to_be_clickable((By.XPATH, '//textarea[@name="_.description"]'))).clear() + wait.until(EC.element_to_be_clickable((By.XPATH, '//button[@name="Apply"]'))).click() + wait.until(EC.visibility_of_element_located((By.XPATH, "//*[@id='notification-bar']//span[text()='Saved']"))) + wait.until(EC.element_to_be_clickable((By.XPATH, '//button[@name="Apply"]'))).click() + wait.until(EC.presence_of_element_located((By.XPATH , "//*[@id='notification-bar']//span[text()='Saved']"))) + + assert "configure" in browser.current_url, "Apply применяется, редиректа нет" From fe6d65a0b7254f33fd72d8ce4512e2e9bc933ca9 Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 19 May 2026 01:39:03 -0300 Subject: [PATCH 2/5] Add test_new_items_cycle --- tests/test_folder_configuration_buttons.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/test_folder_configuration_buttons.py b/tests/test_folder_configuration_buttons.py index c7fa5a6f..1177ded0 100644 --- a/tests/test_folder_configuration_buttons.py +++ b/tests/test_folder_configuration_buttons.py @@ -15,13 +15,14 @@ def test_create_folder(browser): wait.until(EC.visibility_of_element_located((By.XPATH, "//*[@id='name']"))).send_keys("Folder") wait.until(EC.visibility_of_element_located((By.XPATH, "//span[text()='Folder']"))).click() wait.until(EC.visibility_of_element_located((By.XPATH, "//button[@id='ok-button']"))).click() - wait.until(EC.element_to_be_clickable((By.ID, "jenkins-head-icon"))).click() - - actions = ActionChains(browser) - parent_element = browser.find_element(By.XPATH, "//*[@href='job/Folder/']") - actions.move_to_element(parent_element).perform() - browser.find_element(By.XPATH, "//button[contains(@data-href, '/job/Folder/')]").click() - browser.find_element(By.XPATH, "//a[contains(@href, 'configure')]").click() + # wait.until(EC.url_contains("/job/Folder")) + # wait.until(EC.element_to_be_clickable((By.ID, "jenkins-head-icon"))).click() + # + # actions = ActionChains(browser) + # parent_element = browser.find_element(By.XPATH, "//*[@href='job/Folder/']") + # actions.move_to_element(parent_element).perform() + # browser.find_element(By.XPATH, "//button[contains(@data-href, '/job/Folder/')]").click() + # browser.find_element(By.XPATH, "//a[contains(@href, 'configure')]").click() # browser.find_element(By.XPATH, "//button[@data-id='ok']").click() # wait = WebDriverWait(browser, 10) # wait.until(expected_conditions.element_to_be_clickable((By.ID, "jenkins-head-icon"))).click() From 0e9dfa1caee074f2a5cbdc037dc248a4ead38208 Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 19 May 2026 01:47:20 -0300 Subject: [PATCH 3/5] Add test_new_items_cycle --- tests/test_folder_configuration_buttons.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_folder_configuration_buttons.py b/tests/test_folder_configuration_buttons.py index 1177ded0..28e51a55 100644 --- a/tests/test_folder_configuration_buttons.py +++ b/tests/test_folder_configuration_buttons.py @@ -32,7 +32,8 @@ def test_create_folder(browser): def test_config_save(browser): wait = WebDriverWait(browser, 10) wait.until(EC.visibility_of_element_located((By.XPATH, "//a[contains(@href, 'newJob')]"))) - browser.get("http://localhost:8080/job/Folder/configure") + wait.until(EC.element_to_be_clickable((By.XPATH, '//a[@href="job/Folder/"]'))).click() + wait.until(EC.element_to_be_clickable((By.XPATH, '//a[contains(@href, "/configure")]'))).click() wait.until(EC.visibility_of_element_located((By.XPATH, '//input[@name="_.displayNameOrNull"]'))).send_keys(rnd(15)) wait.until(EC.visibility_of_element_located((By.XPATH, '//textarea[@name="_.description"]'))).send_keys(rnd(50)) wait.until(EC.visibility_of_element_located((By.XPATH, '//button[@name = "Submit"]'))).click() @@ -43,7 +44,8 @@ def test_config_save(browser): def test_config_apply(browser): wait = WebDriverWait(browser, 10) wait.until(EC.visibility_of_element_located((By.XPATH, "//a[contains(@href, 'newJob')]"))) - browser.get("http://localhost:8080/job/Folder/configure") + wait.until(EC.element_to_be_clickable((By.XPATH, '//a[@href="job/Folder/"]'))).click() + wait.until(EC.element_to_be_clickable((By.XPATH, '//a[contains(@href, "/configure")]'))).click() wait.until(EC.element_to_be_clickable((By.XPATH, '//input[@name="_.displayNameOrNull"]'))).clear() wait.until(EC.element_to_be_clickable((By.XPATH, '//textarea[@name="_.description"]'))).clear() wait.until(EC.element_to_be_clickable((By.XPATH, '//button[@name="Apply"]'))).click() From 9d969d52df7b6b1c27d2ebae55796c8bbc17494f Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 19 May 2026 01:51:27 -0300 Subject: [PATCH 4/5] Add test_new_items_cycle --- tests/test_folder_configuration_buttons.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_folder_configuration_buttons.py b/tests/test_folder_configuration_buttons.py index 28e51a55..9f18833e 100644 --- a/tests/test_folder_configuration_buttons.py +++ b/tests/test_folder_configuration_buttons.py @@ -52,5 +52,6 @@ def test_config_apply(browser): wait.until(EC.visibility_of_element_located((By.XPATH, "//*[@id='notification-bar']//span[text()='Saved']"))) wait.until(EC.element_to_be_clickable((By.XPATH, '//button[@name="Apply"]'))).click() wait.until(EC.presence_of_element_located((By.XPATH , "//*[@id='notification-bar']//span[text()='Saved']"))) + WebDriverWait(browser, 10).until(EC.url_changes(browser.current_url)) assert "configure" in browser.current_url, "Apply применяется, редиректа нет" From fa5dfd960929b1d42ba135f3c0b8a816f8dca26b Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 19 May 2026 01:54:35 -0300 Subject: [PATCH 5/5] Add test_new_items_cycle --- tests/test_folder_configuration_buttons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_folder_configuration_buttons.py b/tests/test_folder_configuration_buttons.py index 9f18833e..901fd68f 100644 --- a/tests/test_folder_configuration_buttons.py +++ b/tests/test_folder_configuration_buttons.py @@ -37,6 +37,7 @@ def test_config_save(browser): wait.until(EC.visibility_of_element_located((By.XPATH, '//input[@name="_.displayNameOrNull"]'))).send_keys(rnd(15)) wait.until(EC.visibility_of_element_located((By.XPATH, '//textarea[@name="_.description"]'))).send_keys(rnd(50)) wait.until(EC.visibility_of_element_located((By.XPATH, '//button[@name = "Submit"]'))).click() + WebDriverWait(browser, 10).until(EC.url_changes(browser.current_url)) assert ("configure" not in browser.current_url), "Url changed, Save button redirected" @@ -52,6 +53,5 @@ def test_config_apply(browser): wait.until(EC.visibility_of_element_located((By.XPATH, "//*[@id='notification-bar']//span[text()='Saved']"))) wait.until(EC.element_to_be_clickable((By.XPATH, '//button[@name="Apply"]'))).click() wait.until(EC.presence_of_element_located((By.XPATH , "//*[@id='notification-bar']//span[text()='Saved']"))) - WebDriverWait(browser, 10).until(EC.url_changes(browser.current_url)) assert "configure" in browser.current_url, "Apply применяется, редиректа нет"