Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timo #7

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lesson1/api_tests/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

url = "http://localhost:5173/"

@pytest.fixture
def setup():
browser = webdriver.Chrome()
browser.get(url)
yield browser
browser.quit()
91 changes: 91 additions & 0 deletions lesson1/api_tests/tests/test_auto_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import pytest
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

import time
from conftest import url

def test_get_by_endpoint():
response = requests.get(url)
assert response.status_code == 200
def test_get_by_selector():
browser = webdriver.Chrome()
browser.get(url)
# time.sleep(5)
assert url == "http://localhost:5173/", "URLs do not match"


# @pytest.fixture
# def setup():
# browser = webdriver.Chrome()
# browser.get(url)
# yield browser
# browser.quit()

def test_add_test_case(setup):
driver = setup

# Fill in the "Name" field
name_field = driver.find_element(By.ID, "name")
name_field.clear()
name_field.send_keys("Test Case 1")

# Fill in the "Description" field
description_field = driver.find_element(By.ID, 'description')
description_field.clear()
description_field.send_keys("Test Case 99 Description")

# Fill in the steps
steps_field = driver.find_element(By.ID, 'steps')
steps_field.clear()
steps_field.send_keys("Open home page, check navigation bar, check header, check content body, check footer")

# Fill in the "Expected Result" field
expected_result_field = driver.find_element(By.ID, "expected_result")
expected_result_field.clear()
expected_result_field.send_keys("UI should be visible and clickable")

# Select priority
priority_dropdown = driver.find_element(By.ID, "priority")
priority_dropdown.click()
priority_options = driver.find_element(By.XPATH, "//option[text()='высокий']")
priority_options.click()

# Click the "Add Test Case" button
add_button = driver.find_element(By.XPATH, "//button[@class='btn btn-primary']")
add_button.click()

# Validation Table Data
# TODO : example 1 >>
# table_row_name = driver.find_element(By.XPATH, "//td[text()='Test Case 1']")
# assert table_row_name is not None, "Row not found" and table_row_name.text == "Test Case 1"
# TODO : example 2 >>
table = driver.find_element(By.XPATH, "//td")
assert table is not None, "Row not found" and "Test Case 1" in table.text
assert table is not None, "Row not found" and "Test Case 1 Description" in table.text
assert table is not None, "Row not found" and "UI should be visible and clickable" in table.text
assert table is not None, "Row not found" and "средний" in table.text

time.sleep(5)

def test_delete_test_case(setup):
driver = setup
id_str = '1'

# rows = driver.find_elements(By.XPATH, "//table/tbody")
# for i, row in enumerate(rows):
# print(f"Row {i}: {row.text}")
# table_id = driver.find_element(By.XPATH, f"//td[text()={id_str}]")
# assert table_id is not None, "The specified ID was not found in the table."

# TODO : Click the "Delete" button
# delete_button = driver.find_element(By.XPATH, f"//table/tbody/tr/td[text()='{id_str}']//td/button[@class='btn btn-danger']")
delete_button = driver.find_element(By.XPATH, "//button[text()='Удалить']")
# delete_button = driver.find_element(By.XPATH, "//button[@class='btn btn-primary']")
delete_button.click()
time.sleep(2)


assert id_str not in driver.find_element(By.XPATH, f"//td[text()='{id_str}']").text
2 changes: 1 addition & 1 deletion lesson1/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[pytest]

addopts = -s -vv --alluredir=allure-results --clean-alluredir
addopts = -s -vv --alluredir=allure-results --clean-
69 changes: 69 additions & 0 deletions lesson3/waits/tests_timo/test_expl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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
import pytest
import time


# ! : EXPLICIT waits

@pytest.fixture
def chrome_options():
options = Options()
options.add_argument('--start-maximized')
return options

@pytest.fixture
def driver(chrome_options):
driver = webdriver.Chrome(options=chrome_options)
return driver

@pytest.fixture
def wait(driver):
wait = WebDriverWait(driver, timeout=5)
return wait

class TestExample:
selector_start_test = "//button[@id='startTest']"
selector_login = "//input[@id='login']"
selector_password = "//input[@id='password']"
selector_check_box_agree = "//input[@id='agree']"
selector_reg_button = "//button[@id='register']"
selector_loader = "//div[@id='loader']"
selector_success = "//p[@id='successMessage']"

data = TestExample


def test_hw_expl(driver, wait):

# Check title
driver.get('https://victoretc.github.io/selenium_waits/')
assert driver.title == "Практика Selenium"
# Check start test button
start_test_button = wait.until(EC.element_to_be_clickable((By.XPATH, data.selector_start_test)))
assert start_test_button.text == "Начать тестирование"
start_test_button.click()
# Fill form
driver.find_element(By.XPATH, data.selector_login).send_keys("login")
driver.find_element(By.XPATH, data.selector_password).send_keys("password")
# Check agree checkbox
check_box = driver.find_element(By.XPATH, data.selector_check_box_agree)
if not check_box.is_selected():
check_box.click()
driver.find_element(By.XPATH, data.selector_reg_button).click()
# Check loader
load_check = driver.find_element(By.XPATH, data.selector_loader)
assert load_check.is_displayed()
# Check success message
success_check = wait.until(EC.element_to_be_clickable((By.XPATH, data.selector_success)))
assert success_check.text == "Вы успешно зарегистрированы!"

time.sleep(5)





59 changes: 59 additions & 0 deletions lesson3/waits/tests_timo/test_impl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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
import pytest
import time


# ! : IMPLICIT waits

@pytest.fixture
def chrome_options():
options = Options()
options.add_argument('--start-maximized')
return options

@pytest.fixture
def driver(chrome_options):
driver = webdriver.Chrome(options=chrome_options)
driver.implicitly_wait(10)
yield driver
driver.quit()

class TestExample:
selector_start_test = "//button[@id='startTest']"
selector_login = "//input[@id='login']"
selector_password = "//input[@id='password']"
selector_check_box_agree = "//input[@id='agree']"
selector_reg_button = "//button[@id='register']"
selector_loader = "//div[@id='loader']"
selector_success = "//p[@id='successMessage']"

data = TestExample

def test_hw_impl(driver):
# Check title
driver.get('https://victoretc.github.io/selenium_waits/')
assert driver.title == "Практика Selenium"
# Check start test button
start_test_button = driver.find_element(By.XPATH, data.selector_start_test)
assert start_test_button.is_displayed
start_test_button.click()
# Fill form
driver.find_element(By.XPATH, data.selector_login).send_keys("login")
driver.find_element(By.XPATH, data.selector_password).send_keys("password")
# Check agree checkbox
check_box = driver.find_element(By.XPATH, data.selector_check_box_agree)
if not check_box.is_selected():
check_box.click()
driver.find_element(By.XPATH, data.selector_reg_button).click()
# Check loader
check_loader = driver.find_element(By.XPATH, data.selector_loader)
assert check_loader.is_displayed
# Check success message
check_sucess_msg = driver.find_element(By.XPATH, data.selector_success)
assert check_sucess_msg.is_displayed
time.sleep(5)