-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63f82d5
commit d1ec644
Showing
2 changed files
with
23 additions
and
18 deletions.
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
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,59 +1,62 @@ | ||
"""Module to test login page.""" | ||
import time | ||
from pages.login import login | ||
import pytest | ||
from selenium import webdriver | ||
import pytest | ||
from pages.login import Login | ||
from utils.base import BASEURL | ||
|
||
|
||
@pytest.fixture | ||
def driver1(): | ||
@pytest.fixture(name="driver1") | ||
def driver1_fixture(): | ||
"""Function to save driver fixture.""" | ||
driver = webdriver.Edge() | ||
driver.get("https://cshr.gent01.dev.grid.tf") | ||
driver.get(BASEURL) | ||
yield driver | ||
driver.quit() | ||
|
||
|
||
def test_user_login(driver1): | ||
login_instance = login() | ||
"""test for login.""" | ||
# Enter email | ||
email_input = driver1.find_element(*login_instance.email) | ||
email_input = driver1.find_element(*Login.email) | ||
email_input.send_keys("[email protected]") | ||
# Enter password | ||
password_input = driver1.find_element(*login_instance.password) | ||
password_input = driver1.find_element(*Login.password) | ||
password_input.send_keys("123456789") | ||
# Click on Login button | ||
login_button = driver1.find_element(*login_instance.login_button) | ||
login_button = driver1.find_element(*Login.login_button) | ||
login_button.click() | ||
|
||
time.sleep(2) | ||
# Get the profile | ||
profile = driver1.find_element(*login_instance.profile) | ||
profile = driver1.find_element(*Login.profile) | ||
# Assert that the element includes the text "AW" | ||
assert "aw" in profile.text.lower() | ||
|
||
|
||
def test_invalid_login(driver1): | ||
login_instance = login() | ||
"""test for invalid login.""" | ||
# Enter email invalid email | ||
email_input = driver1.find_element(*login_instance.email) | ||
email_input = driver1.find_element(*Login.email) | ||
email_input.send_keys("[email protected]") | ||
# Enter invalid password | ||
password_input = driver1.find_element(*login_instance.password) | ||
password_input = driver1.find_element(*Login.password) | ||
password_input.send_keys("123456789") | ||
# Click on Login button | ||
login_button = driver1.find_element(*login_instance.login_button) | ||
login_button = driver1.find_element(*Login.login_button) | ||
try: | ||
login_button.click() | ||
except ImportError: | ||
assert True | ||
|
||
|
||
def test_email_validation(driver1): | ||
login_instance = login() | ||
"""test for email validation.""" | ||
# Enter email invalid email | ||
email_input = driver1.find_element(*login_instance.email) | ||
email_input = driver1.find_element(*Login.email) | ||
email_input.send_keys("[email protected]") | ||
# get the error message | ||
undefined_message = driver1.find_element(*login_instance.undefined_message) | ||
undefined_message = driver1.find_element(*Login.undefined_message) | ||
actual_text = undefined_message.text | ||
expected_text = "undefined" | ||
assert actual_text == expected_text |