class LoginTest(unittest.TestCase): @pytest.fixture(autouse=True) def class_setup(self, one_time_setUp): self.log_in_page = LoginPage(self.driver) self.ts = ErrorStatus(self.driver) # @pytest.mark.run(order=2) def test_valid_login(self): # self.driver.get('https://learn.letskodeit.com/') self.log_in_page.login('*****@*****.**', 'abcabc') result_1 = self.log_in_page.verify_title() # time.sleep(20) self.ts.mark(result_1, " Title is Incorrect") result_2 = self.log_in_page.verify_login_successfull() self.ts.mark_final("Test Valid Login", result_2, "Loggin Failed") time.sleep(2) # @pytest.mark.run(order=1) def test_failed_login(self): self.log_in_page.logout() self.log_in_page.login('*****@*****.**', 'abcabcxyz') result = self.log_in_page.verify_login_failed() # self.ts.mark(result, "Failed Login test is Unsuccessful") assert result is True time.sleep(2)
def one_time_setUp(browser, request): print('Running One time Set Up') wdf = WebDriverFactory(browser) driver = wdf.get_webdriver_instance() lp = LoginPage(driver) lp.login(user_name="*****@*****.**", password="******") if request.cls is not None: request.cls.driver = driver yield driver driver.quit() print('Running One time Teardown')
class LoginTests(unittest.TestCase): # log = cl.customLogger(logging.DEBUG) # log = cl.customLogger(logging.DEBUG, file_name="automation_test_suite") @pytest.fixture(autouse=True) def class_level_setup(self): self.login_page_obj = LoginPage(self.driver) self.test_status = TestStatus(self.driver) self.nav = NavigationPage(self.driver) @pytest.mark.run(order=4) def test_for_valid_login(self): self.nav.navigateToHomePage() self.login_page_obj.login("*****@*****.**", "abcabc") login_result1 = self.login_page_obj.verify_title() self.test_status.mark(login_result1, "Title Verification") login_result2 = self.login_page_obj.check_login_successful() self.test_status.markFinal("(Test for Valid Login)", login_result2, "<<<< Checked whether Login is Successful >>>>") self.nav.navigateToAllCourses() time.sleep(2) @pytest.mark.run(order=3) def test_for_invalid_login(self): self.login_page_obj.login() login_result = self.login_page_obj.check_login_failed() self.test_status.markFinal("(Test for In-Valid Login)", login_result, "<<<< Checked whether Login is Un-Successful >>>>") @pytest.mark.run(order=5) def test_for_logout(self): self.login_page_obj.logout() logout_result = self.login_page_obj.verify_logout_successful() self.test_status.markFinal("(Test for Logout)", logout_result, "<<<< Checked whether Logout is Successful >>>>")
def objectSetup(self, oneTimeSetUp): self.dp = DiscountsPage(self.driver) self.lp = LoginPage(self.driver) self.ts = TestStatus(self.driver) self.nav = NavigationPage(self.driver)
def __init__(self, driver): super().__init__(driver) self.driver = driver self.nav = NavigationPage(self.driver) self.lp = LoginPage(self.driver) self.cp = CartPage(self.driver)
class CheckoutPage(BasePage): log = cl.customLogger(logging.DEBUG) def __init__(self, driver): super().__init__(driver) self.driver = driver self.nav = NavigationPage(self.driver) self.lp = LoginPage(self.driver) self.cp = CartPage(self.driver) #Loctors _go_to_fulfill_the_order_button = "//div[@class='modal-content']//a" # byxpath _proceed_to_order_completion = "PRZEJDŹ DO REALIZACJI ZAMÓWIENIA" #bylink _checkout_form = "checkout-personal-information-step" #byid # for visitor client _gender = "//div[@class='col-md-6 form-control-valign']/label[1]//input[@name='id_gender']"#byxpath gender = men _address_checkout_form = "//div[@class='js-address-form'][1]" #byxpath _firstname = "firstname" #byname _lastname = "lastname" #byname _email = "//input[@name='email'][1]" #byxpath _password = "******" #byxpath _submit_first_form = "//button[@name='continue'][1]" #byxpath _wrong_email_info = "//form[@id='customer-form']//ul/li[@class='alert alert-danger']" #byxpath _address = "address1" #byname _postcode = "postcode" #byname _city = "city" #byname _phone = "phone" #byname _confirm_addresses = "confirm-addresses" #byname _alert_inf_address = "//div[@id='delivery-address']//ul/li[@class='alert alert-danger']" #byxpath _delivery_option2 = "delivery_option_2" #byid _delivery_message = "delivery_message" #byid _confirm_delivery_option = "confirmDeliveryOption" #byname _payment_option2 = "payment-option-2" #byid _conditions_acceptance = "conditions_to_approve[terms-and-conditions]" #byid _payment_confirmation = "//div[@id='payment-confirmation']//button[@type='submit']" #byxpath #for logged in client _personal_inf = "//section[@id='checkout-personal-information-step']/h1" #byxpath _user_name = "//a[@href='http://localhost/prestashop/dane-osobiste']" #byxpath _address2 = "//div[@class='address'][1]" #byxpath _add_new_address = "//a[@href='http://localhost/prestashop/zamówienie?newAddress=delivery']" #byxpath def goToCheckout(self): self.cp.getProductToCartFiona(quantity=1) self.elementClick(locator=self._go_to_fulfill_the_order_button, locatorType="xpath") self.waitForElement(locator="cart-detailed-totals", locatorType="class") self.elementClick(locator=self._proceed_to_order_completion, locatorType="link") self.waitForElement(locator=self._checkout_form) def checkoutGuestFormPersonalInformation(self,firstname, lastname, email, password): self.goToCheckout() time.sleep(2) self.elementClick(locator=self._gender, locatorType="xpath") self.sendKeys(firstname, locator=self._firstname, locatorType="name") self.sendKeys(lastname, locator=self._lastname, locatorType="name") self.sendKeys(email, locator=self._email, locatorType="xpath") self.sendKeys(password, locator=self._password, locatorType="xpath") self.elementClick(locator=self._submit_first_form, locatorType="xpath") def checkoutGuestFormPersonalInformationSuccessful(self, firstname, lastname,email,password): self.checkoutGuestFormPersonalInformation(firstname, lastname, email, password) self.waitForElement(locator=self._address_checkout_form, locatorType="xpath") result = self.isElementPresent(locator=self._address_checkout_form, locatorType="xpath") return result def checkoutGuestFormPersonalInformationFailed(self,firstname, lastname, email, password): # providing a wrong email address self.checkoutGuestFormPersonalInformation(firstname, lastname, email, password) self.waitForElement(locator=self._wrong_email_info, locatorType="class") result = self.isElementPresent(locator=self._wrong_email_info, locatorType="xpath") return result def addressForm(self, firstname, lastname, email, password, address, postcode, city, phone): self.checkoutGuestFormPersonalInformation(firstname,lastname,email,password) self.waitForElement(locator=self._address_checkout_form, locatorType="xpath") self.sendKeys(address, locator=self._address, locatorType="name") self.sendKeys(postcode, locator=self._postcode, locatorType="name") self.sendKeys(city, locator=self._city, locatorType="name") self.sendKeys(phone, locator=self._phone, locatorType="name") self.elementClick(locator=self._confirm_addresses, locatorType="name") def addressFormSuccessful(self, firstname, lastname, email, password, address, postcode, city, phone): self.addressForm( firstname, lastname, email, password, address, postcode, city, phone) self.waitForElement(locator="checkout-delivery-step") result = self.isElementPresent(locator="checkout-delivery-step") return result def addressFormFailed(self, firstname, lastname, email, password, address, postcode, city, phone): self.addressForm(firstname, lastname, email, password, address, postcode, city, phone) self.waitForElement(locator=self._alert_inf_address, locatorType="class") result = self.isElementPresent(locator=self._alert_inf_address, locatorType="xpath") return result def delivery(self, firstname, lastname, email, password, address, postcode, city, phone): self.addressForm(firstname, lastname, email, password, address, postcode, city, phone) self.waitForElement(locator="checkout-delivery-step") self.elementClick(locator=self._delivery_option2) self.elementClick(locator=self._confirm_delivery_option, locatorType="name") def deliverySuccessed(self,firstname, lastname, email, password, address, postcode, city, phone): self.delivery(firstname, lastname, email, password, address, postcode, city, phone) self.waitForElement(locator=self._payment_option2) result = self.isElementPresent(locator=self._payment_option2) return result def payment(self,firstname, lastname, email, password, address, postcode, city, phone): self.delivery(firstname, lastname, email, password, address, postcode, city, phone) self.waitForElement(locator=self._payment_option2) self.elementClick(locator=self._payment_option2) def paymentConditionsAcceptanceVerification(self, firstname, lastname, email, password, address, postcode, city, phone): self.payment(firstname, lastname, email, password, address, postcode, city, phone) self.waitForElement(locator=self._payment_confirmation, locatorType="xpath") self.elementClick(locator=self._payment_confirmation, locatorType="xpath") element = self.getElement(locator=self._payment_confirmation, locatorType="xpath") result = element.is_enabled() if result == False: return True return False def paymentSuccessed(self, firstname, lastname, email, password, address, postcode, city, phone): self.payment( firstname, lastname, email, password, address, postcode, city, phone) self.waitForElement(locator=self._conditions_acceptance) self.elementClick(locator=self._conditions_acceptance) self.elementClick(locator=self._payment_confirmation, locatorType="xpath") self.waitForElement(locator="order-confirmation-table", locatorType="class") result = self.isElementPresent(locator="order-confirmation-table", locatorType="class") return result def checkoutLoggedInClient(self, email, password): self.lp.login(email,password) self.goToCheckout() def personalInfVerificationLoggedInClient(self, username, email, password): self.checkoutLoggedInClient(email, password) self.waitForElement(locator=self._personal_inf, locatorType="xpath") self.elementClick(locator=self._personal_inf, locatorType="xpath") self.waitForElement(locator=self._user_name, locatorType="xpath") username1 = self.getElement(locator=self._user_name, locatorType="xpath").text if username == username1: result = True else: result = False return result def addressVerificationLoggedInClient(self, address, email, password): #w tescie zrób go to main page i wyloguj najpierw self.checkoutLoggedInClient(email,password) self.waitForElement(locator=self._address2, locatorType="class") element = self.getElement(locator=self._address2, locatorType="xpath") address1 = element.text if address1 == address: result = True else: result = False return result def addNewAddressLoggedinClient(self, email, password, address, postcode, city, phone): self.checkoutLoggedInClient(email, password) self.waitForElement(locator=self._address2, locatorType="class") self.elementClick(locator=self._add_new_address, locatorType="xpath") self.sendKeys(address, locator=self._address, locatorType="name") self.sendKeys(postcode, locator=self._postcode, locatorType="name") self.sendKeys(city, locator=self._city, locatorType="name") self.sendKeys(phone, locator=self._phone, locatorType="name") self.elementClick(locator=self._confirm_addresses, locatorType="name") self.waitForElement(locator="checkout-delivery-step") result = self.isElementPresent(locator="checkout-delivery-step") return result
def objectSetup(self, oneTimeSetUp): self.lp = LoginPage(self.driver) self.ts = TestStatus(self.driver)
class LoginTests(unittest.TestCase): log = cl.customLogger(logging.DEBUG) @pytest.fixture(autouse=True) def objectSetup(self, oneTimeSetUp): self.lp = LoginPage(self.driver) self.ts = TestStatus(self.driver) @pytest.mark.run(order=1) @data(*getCSVData("invalidLogin.csv")) @unpack def test_invalidPasswordLogin(self, email, password): self.log.info("Test invalid login") self.lp.login(email, password) result = self.lp.verifyLoginFailed() assert result == True @pytest.mark.run(order=2) def test_emailInputValidationFailed(self): # Check email input element validation based on the pattern self.log.info("Test email input validation") result = self.lp.emailValidation(email='testtest.com', password='******') assert result == False @pytest.mark.run(order=3) def test_emailInputValidationSuccessed(self): # Check email input element validation based on the pattern self.log.info("Test email input validation failed") result = self.lp.emailValidation(email='*****@*****.**', password='******') assert result == True @pytest.mark.run(order=4) def test_passwordInputValidationFailed(self): # Check password input element validation based on the pattern self.log.info("Test password input validation failed") result = self.lp.passwordValidation(email='*****@*****.**', password='******') assert result == False @pytest.mark.run(order=5) def test_passwordInputValidationSuccessed(self): # Check password input element validation based on the pattern self.log.info("Test password input validation successed") result = self.lp.passwordValidation(email='*****@*****.**', password='******') assert result == True @pytest.mark.run(order=6) def test_deactivatedCustomerAccountLogin(self): result = self.lp.deactivatedCustomerAccountLogin(email="*****@*****.**", password="******") assert result == True @pytest.mark.run(order=7) def test_successfulLogin(self): self.log.info("Test successful login") self.lp.login("*****@*****.**", "abcabc123") result = self.lp.verifyLoginSuccessful() assert result == True self.ts.markFinal("test_successfulLogin", result, "Login verification SUCCESSED")
class DiscountsPage(BasePage): log = cl.customLogger(logging.DEBUG) def __init__(self, driver): super().__init__(driver) self.driver = driver self.nav = NavigationPage(driver) self.lp = LoginPage(driver) #Loctors _discount_info_clothes_page = "//div[@class='products row']//span[@class='discount-percentage discount-product']" #byXpath _panda_tshirt = "//div[@id='js-product-list']/div[@class='products row']//a[contains(text(),'T-shirt Panda')]" #byXpath _discount_info_element = "//div[@class='product-prices']//span[@class='discount discount-percentage']" _panda_tshirt_current_price = "//section[@id='main']//div[@class='product-prices']/div[2]//span[1]" _panda_tshirt_regular_price = "//div[@class='product-prices']//span[@class='regular-price']" def priceCheck(self, discountnum): currentPrice = self.driver.find_element( By.XPATH, self._panda_tshirt_current_price).get_attribute("content") currentPrice = currentPrice.replace(",", ".") regularPrice = self.driver.find_element( By.XPATH, self._panda_tshirt_regular_price).text regularPrice = regularPrice.replace("zł", "") regularPrice = regularPrice.replace(",", ".") discount = float(regularPrice) * float(discountnum) if (float(regularPrice) - float(discount)) == float(currentPrice): return True return False def discountForLoggedInClientSuccessful(self, email, password, discountnum): self.lp.login(email, password) self.nav.goToClothesPage() self.waitForElement(locator=self._panda_tshirt, locatorType='xpath') self.elementClick(locator=self._panda_tshirt, locatorType='xpath') discountInfo = self.isElementPresent( locator=self._discount_info_element, locatorType='xpath') if discountInfo and self.priceCheck(discountnum): result = True else: result = False self.lp.logout() return result def discountForLoggedInClientFailed(self): self.nav.goToClothesPage() self.waitForElement(locator=self._panda_tshirt, locatorType='xpath') self.elementClick(locator=self._panda_tshirt, locatorType='xpath') result = self.isElementPresent(locator=self._discount_info_element, locatorType='xpath') return result def discountInfoOnClothesPageElements(self, email, password, elementNum): self.lp.login(email, password) self.nav.goToClothesPage() self.waitForElement( locator= "//div[@id='js-product-list']/div[@class='products row']/article[1]", locatorType='xpath') discountInfo = self.driver.find_elements( By.XPATH, self._discount_info_clothes_page) if len(discountInfo) == elementNum: result = True else: result = False self.lp.logout() return result
def objectSetup(self, oneTimeSetUp): self.cp = CartPage(self.driver) self.lp = LoginPage(self.driver) self.ts = TestStatus(self.driver) self.nav = NavigationPage(self.driver) self.sd = SeleniumDriver(self.driver)
def class_setup(self, one_time_setUp): self.log_in_page = LoginPage(self.driver) self.ts = ErrorStatus(self.driver)
class CheckoutTests(unittest.TestCase): log = cl.customLogger(logging.DEBUG) @pytest.fixture(autouse=True) def objectSetup(self, oneTimeSetUp): self.chp = CheckoutPage(self.driver) self.lp = LoginPage(self.driver) self.ts = TestStatus(self.driver) self.nav = NavigationPage(self.driver) self.sd = SeleniumDriver(self.driver) @pytest.mark.run(order=1) def test_checkoutGuestFormPersonalInformationSuccessful(self): self.log.info("Personal Information form for guest client successed") email = email = "test" + str(round(time.time() * 1000)) + "@test.com" result = self.chp.checkoutGuestFormPersonalInformationSuccessful( firstname="Adam", lastname="Kowalski", email=email, password="******") assert result == True @pytest.mark.run(order=2) def test_checkoutGuestFormPersonalInformationFailed(self): self.log.info( "Personal Information form for guest client failed due to wrong email" ) self.nav.clearCartAndGoToMainPage() self.lp.logOut() result = self.chp.checkoutGuestFormPersonalInformationFailed( firstname="Adam", lastname="Kowalski", email="*****@*****.**", password="******") assert result == True @pytest.mark.run(order=3) def test_addressFormSuccessful(self): self.log.info("Address form for guest client successful") self.nav.clearCartAndGoToMainPage() self.lp.logOut() email = email = "test" + str(round(time.time() * 1000)) + "@test.com" result = self.chp.addressFormSuccessful(firstname="Adam", lastname="Kowalski", email=email, password="******", address="Testowa 1/2", postcode="00-000", city="Warszawa", phone="500500500") assert result == True @pytest.mark.run(order=4) def test_addressFormFailed(self): self.log.info( "Address form for guest client failed due to wrong postcode") self.nav.clearCartAndGoToMainPage() self.lp.logOut() email = email = "test" + str(round(time.time() * 1000)) + "@test.com" result = self.chp.addressFormFailed(firstname="Adam", lastname="Kowalski", email=email, password="******", address="Testowa 1/2", postcode="00", city="Warszawa", phone="500500500") assert result == True @pytest.mark.run(order=5) def test_addressFormFailed2(self): self.log.info( "Address form for guest client failed due to wrong phone number") self.nav.clearCartAndGoToMainPage() self.lp.logOut() email = email = "test" + str(round(time.time() * 1000)) + "@test.com" result = self.chp.addressFormFailed(firstname="Adam", lastname="Kowalski", email=email, password="******", address="Testowa 1/2", postcode="00-000", city="Warszawa", phone="abc") assert result == True @pytest.mark.run(order=6) def test_deliverySuccessed(self): self.log.info("Delivery form successed") self.nav.clearCartAndGoToMainPage() self.lp.logOut() email = email = "test" + str(round(time.time() * 1000)) + "@test.com" result = self.chp.deliverySuccessed(firstname="Adam", lastname="Kowalski", email=email, password="******", address="Testowa 1/2", postcode="00-000", city="Warszawa", phone="500500500") assert result == True @pytest.mark.run(order=7) def test_paymentConditionsAcceptanceVerification(self): self.log.info("Payment conditions acceptance verification successful") self.nav.clearCartAndGoToMainPage() self.lp.logOut() email = email = "test" + str(round(time.time() * 1000)) + "@test.com" result = self.chp.paymentConditionsAcceptanceVerification( firstname="Adam", lastname="Kowalski", email=email, password="******", address="Testowa 1/2", postcode="00-000", city="Warszawa", phone="500500500") assert result == True @pytest.mark.run(order=8) def test_paymentSuccessed(self): self.log.info("Address form for guest client successful") self.nav.clearCartAndGoToMainPage() self.lp.logOut() email = email = "test" + str(round(time.time() * 1000)) + "@test.com" result = self.chp.paymentSuccessed(firstname="Adam", lastname="Kowalski", email=email, password="******", address="Testowa 1/2", postcode="00-000", city="Warszawa", phone="500500500") assert result == True @pytest.mark.run(order=9) def test_personalInfVerificationLoggedInClient(self): self.log.info( "Personal information form for logged in client verification successful" ) self.nav.clearCartAndGoToMainPage() self.lp.logOut() result = self.chp.personalInfVerificationLoggedInClient( username="******", email="*****@*****.**", password="******") assert result == True @pytest.mark.run(order=10) def test_addressVerificationLoggedInClient(self): self.log.info("Address form for logged in client successful") self.nav.backToHomePage() self.lp.logOut() address = "Ewa Kowalska\nul. Testowa\n00-000 Warszawa\nPolska\n600600600" result = self.chp.addressVerificationLoggedInClient( address=address, email="*****@*****.**", password="******") assert result == True @pytest.mark.run(order=10) def test_addNewAddressLoggedInClient(self): self.log.info("Add address form for logged in client successful") self.nav.backToHomePage() self.lp.logOut() address = "Testowa" + str(round(time.time() * 1000)) + "/2" result = self.chp.addNewAddressLoggedinClient(email="*****@*****.**", password="******", address=address, postcode="00-000", city="Warszawa", phone="600600600") assert result == True self.ts.markFinal( "test_addNewAddressLoggedinClient", result, "Add address form for logged in client successful" "verification SUCCESSED")
def class_level_setup(self): self.login_page_obj = LoginPage(self.driver) self.test_status = TestStatus(self.driver) self.nav = NavigationPage(self.driver)