Skip to content

Commit eda8489

Browse files
committed
add tests to fix to have a better cov
1 parent 010d3b0 commit eda8489

File tree

4 files changed

+11
-23
lines changed

4 files changed

+11
-23
lines changed

pages/Login_Page.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,32 @@
11
from selenium.webdriver.support import expected_conditions as EC
22
from pages.Base_Page import BasePage
33
from config.locators import LOGIN
4-
5-
64
class LoginPage (BasePage) :
7-
85
def open_page ( self ) :
96
self.go_to ("https://www.saucedemo.com/")
107
self.wait.until (EC.visibility_of_element_located (LOGIN["LOGIN_BUTTON"]))
118
self.logger.info ("Login page opened successfully")
12-
139
def login ( self , username: str , password: str ) -> bool :
1410
try :
1511
self.fill (LOGIN["USERNAME_INPUT"] , username)
1612
self.fill (LOGIN["PASSWORD_INPUT"] , password)
1713
self.click (LOGIN["LOGIN_BUTTON"])
18-
1914
self.logger.info (f"Login attempted with user: {username}")
2015
return True
2116
except Exception as e :
2217
self.logger.error (f"Login failed for user {username}: {e}")
2318
return False
24-
2519
def get_error_message ( self ) -> str :
2620
try :
2721
return self.get_text (LOGIN["ERROR_MESSAGE"])
2822
except Exception :
2923
return ""
30-
3124
def is_error_message_visible ( self ) -> bool :
3225
return self.is_visible (LOGIN["ERROR_MESSAGE"])
33-
34-
def logout ( self ) -> bool :
35-
try :
36-
self.click (LOGIN["MENU_BUTTON"])
37-
self.click (LOGIN["LOGOUT_BUTTON"])
26+
def logout ( self ) -> None :
27+
self.click (LOGIN["BURGER_MENU_BUTTON"])
28+
self.click (LOGIN["LOGOUT_LINK"])
3829
self.wait.until (EC.visibility_of_element_located (LOGIN["LOGIN_BUTTON"]))
39-
40-
self.logger.info ("Logout completed successfully")
41-
return True
42-
except Exception as e :
43-
self.logger.error (f"Logout failed: {e}")
44-
return False
45-
4630
def is_login_button_visible ( self ) -> bool :
4731
return self.is_visible (LOGIN["LOGIN_BUTTON"])
4832

test/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def browser_driver(request):
3333

3434
if browser_name == "firefox":
3535
options = FirefoxOptions ()
36-
options.add_argument ("--headless")
36+
options.add_argument ("--headed")
3737
options.add_argument ("--disable-notifications")
3838
options.add_argument ("--disable-gpu")
3939
options.page_load_strategy = "normal"

test/test_cart.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ def test_full_e2e_checkout(cart_page_with_items, first_name, last_name, postal_c
9090
with allure.step("Finalizar la compra"):
9191
assert checkout.complete_checkout() == True
9292
assert "checkout-complete.html" in checkout.driver.current_url
93-
assert "Thank you for your order!" in checkout.driver.page_source
93+
assert "Thank you for your order!" in checkout.get_complete_header_text()
94+
assert checkout.is_complete_header_visible() == True
9495
print(f"E2E complete with user {first_name} {last_name}, final URL: {checkout.driver.current_url}")
9596

9697
allure.attach(cart_page_with_items.driver.get_screenshot_as_png(), name="Checkout Complete",

test/test_login.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ def login_page(browser_driver, request):
1111
return login_page
1212

1313

14-
def test_successful_login(login_page):
14+
def test_successful_login_and_logout(login_page):
1515
with allure.step("Abrir página de login"):
1616
login_page.open_page()
17-
17+
with allure.step("Verificar que esta en la pagina de login"):
18+
assert login_page.get_current_url() == "https://www.saucedemo.com/"
1819
with allure.step("Login con username válido (standard_user)"):
1920
login_page.login(config_for_login_page.CREDENTIALS["standard_user"]["username"], config_for_login_page.CREDENTIALS["standard_user"]["password"])
2021

@@ -23,6 +24,8 @@ def test_successful_login(login_page):
2324

2425
with allure.step("Cerrar sesión para limpieza del test"):
2526
login_page.logout()
27+
with allure.step("Verificar que el logout a traves del boton de login"):
28+
assert login_page.is_login_button_visible() == True
2629

2730

2831
def test_locked_out_user(login_page):

0 commit comments

Comments
 (0)