-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add POM and main page tests #19
Open
ezoenovak
wants to merge
13
commits into
main
Choose a base branch
from
Zoe_mainpage_UI
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7c61dee
add POM structure and some header and footer tests
ezoenovak 7be1f72
Delete database_connection.py
ezoenovak 2c4e6f5
refactor: edit .gitignore
ezoenovak a279189
Merge branch 'Zoe_mainpage_UI' of https://github.com/Train-lab-intern…
ezoenovak c67fae0
refactor: add missing lines
ezoenovak 551a75a
refactor: add ignore rule to pylintrc
ezoenovak 4b075a0
refactor: optimized tests according to comments: optimize method call…
ezoenovak 8c68421
refactor: delete unused import
ezoenovak 6f535ec
refactor: rewrite methods on base page
ezoenovak 61f9eb6
refactor: add main page initiation to main page and refactor tests re…
ezoenovak bbe545c
refactor: delete unused import from conftest
ezoenovak bdf3035
refactor: fix texts and locators
ezoenovak f2f1eef
refactor: delete trailing newlines
ezoenovak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
venv | ||
venv | ||
|
||
.idea/ | ||
__pycache__/ | ||
data/__pycache__/ | ||
locators/__pycache__/ | ||
|
||
database_connection.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ disable= | |
C0116, | ||
C0115, | ||
E0401, | ||
W0621 | ||
W0621, | ||
R0903 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
class Urls: | ||
MAIN_PAGE = "https://www.it-roast.com/#" | ||
MAIN_PAGE_TEST = "https://front-test-a2ykv.ondigitalocean.app" | ||
LINKEDIN_PAGE = "https://www.linkedin.com/company/train-lab-interns/" | ||
REG_PAGE = "https://www.it-roast.com/auth" | ||
GITHUB_PAGE = "https://github.com/Train-lab-intern" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from selenium.webdriver.common.by import By | ||
|
||
|
||
class MainPageLocators: | ||
LOGO = (By.CSS_SELECTOR, 'img[alt="Logo"]') | ||
LINKEDIN_LINK = (By.CSS_SELECTOR, "[alt='linkedin']") | ||
GITHUB_LINK = (By.CSS_SELECTOR, "[alt='github']") | ||
ABOUT_US_BUTTON = (By.CSS_SELECTOR, '[class="Navigation_link__Jlf0e active"]:first-of-type') | ||
TASKS_BUTTON = (By.CSS_SELECTOR, '[class="Navigation_link__Jlf0e active"]:nth-of-type(2)') | ||
REG_BUTTON = (By.CSS_SELECTOR, "[href='/auth']") | ||
HEADER_BUTTONS = [ABOUT_US_BUTTON, TASKS_BUTTON, REG_BUTTON] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
|
||
|
||
class BasePage: | ||
|
||
def __init__(self, driver, link=None): | ||
self.driver = driver | ||
self.link = link | ||
|
||
def open(self): | ||
self.driver.get(self.link) | ||
|
||
def find_element(self, locator): | ||
return self.driver.find_element(*locator) | ||
|
||
def check_element_visibility(self, locator): | ||
element = self.find_element(locator) | ||
assert element.is_displayed() | ||
|
||
def check_element_clickability(self, locator): | ||
element = self.find_element(locator) | ||
assert element.is_enabled() | ||
|
||
def find_element_and_click(self, locator): | ||
self.find_element(locator).click() | ||
|
||
def switch_to_new_window(self): | ||
self.driver.switch_to.window(self.driver.window_handles[-1]) | ||
|
||
|
||
def assert_current_url(self, expected_url): | ||
current_url = self.driver.current_url | ||
assert current_url == expected_url, f"URL does not match. Actual page is: {current_url}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from pages.base_page import BasePage | ||
from locators.main_page_locators import MainPageLocators | ||
# from data.urls import LINKEDIN_PAGE, GITHUB_PAGE, MAIN_PAGE, MAIN_PAGE_TEST | ||
from data.urls import Urls | ||
|
||
|
||
class MainPage(BasePage): | ||
|
||
def __init__(self, driver): | ||
super().__init__(driver, Urls.MAIN_PAGE_TEST) | ||
|
||
def logo_visibility(self): | ||
self.check_element_visibility(MainPageLocators.LOGO) | ||
|
||
def check_linkedin_redirection(self): | ||
self.find_element_and_click(MainPageLocators.LINKEDIN_LINK) | ||
self.switch_to_new_window() | ||
self.assert_current_url(Urls.LINKEDIN_PAGE) | ||
|
||
def check_github_redirection(self): | ||
self.find_element_and_click(MainPageLocators.GITHUB_LINK) | ||
self.assert_current_url(Urls.GITHUB_PAGE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
from locators.main_page_locators import MainPageLocators | ||
from pages.main_page import MainPage | ||
|
||
|
||
# Header tests | ||
def test_check_logo_visibility(driver): | ||
page = MainPage(driver) | ||
page.open() | ||
page.logo_visibility() | ||
|
||
|
||
@pytest.mark.parametrize('button', MainPageLocators.HEADER_BUTTONS) | ||
def test_check_header_buttons_clickability(driver, button): | ||
page = MainPage(driver) | ||
page.open() | ||
page.check_element_clickability(button) | ||
|
||
# Footer tests | ||
@pytest.mark.xfail | ||
def test_linkedin_redirection(driver): | ||
page = MainPage(driver) | ||
page.open() | ||
page.check_linkedin_redirection() | ||
|
||
|
||
def test_github_redirection(driver): | ||
page = MainPage(driver) | ||
page.open() | ||
page.check_github_redirection() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Так как это проверка, лучше назвать метод
check_logo_is_visible