class FindWorkshopTests(unittest.TestCase): @pytest.fixture(autouse=True) def class_setup(self, module_setup_to_test_class): self.find_workshop_page = FindWorkshopPage(self.driver) self.home_page = HomePage(self.driver) def test_find_workshops_page(self): print("step 3") self.home_page.navigate_to_workshops_page() print("step 4") result = self.find_workshop_page.verify_find_workshop_page_title() assert result is True time.sleep(1) print("step 5") result = self.find_workshop_page.search_studio_by_location() assert result is True time.sleep(1) print("step 6") studio_search_result = self.find_workshop_page.get_studio_name_text_for_10011( ) assert studio_search_result == "WW Studio Flatiron" time.sleep(1) self.find_workshop_page.print_distance_to_studio() time.sleep(1) print("step7") self.find_workshop_page.go_to_studio_page() studio_name_on_studio_page = self.find_workshop_page.get_studio_name_on_studio_page( ) assert studio_name_on_studio_page == studio_search_result print("step 8") self.find_workshop_page.print_todays_business_hours() print("step 9") self.find_workshop_page.print_schedule_in_person() self.find_workshop_page.print_schedule_virtual()
class AddressTests(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self): self.lp = LoginPage(self.driver) self.ts = TestStatus(self.driver) self.hp = HomePage(self.driver) self.ad = AddressPage(self.driver) # @pytest.mark.run(order=1) # # @data(*getCSVData("/Users/aravindanathdm/Documents/Simple_Pom_py_fw/testdata.csv")) # @data("*****@*****.**","auto2018","aravinda") # @unpack # def test_addAddress(self,email,password,fullname): # self.lp.login(email, password) # # Online Shopping site in India: Shop Online for Mobiles, Books, Watches, Shoes and More - Amazon.in # # title = self.lp.verifyTitle("Online Shopping site in India: Shop Online for Mobiles, Books, Watches, Shoes and More - Amazon.in") # # self.ts.mark(title, "Title mismatch!") # # result = self.lp.verifyLoginSuccessful() # # self.ts.markFinal("test_addAddress",result,"Login was not successful") # self.ad.addNewAddress(fullname) @pytest.mark.run(order=1) # * -- means mutiple args @data(*getCSVData("/Users/aravindanathdm/Documents/Simple_Pom_py_fw/testdata.csv")) @unpack def test_addAddress(self,email,password,search): self.lp.login(email, password) # Online Shopping site in India: Shop Online for Mobiles, Books, Watches, Shoes and More - Amazon.in self.hp.search(search)
class HomeTest(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.lp = LoginPage(self.driver) self.ts = TestStatus(self.driver) self.hp = HomePage(self.driver) # @pytest.mark.run(order=1) # @data(("*****@*****.**", "amazonapps", "iphone 7")) # @unpack # def test_validLogin(self,email,password,search): # self.lp.login(email, password) # # Online Shopping site in India: Shop Online for Mobiles, Books, Watches, Shoes and More - Amazon.in # title = self.lp.verifyTitle("Online Shopping site in India: Shop Online for Mobiles, Books, Watches, Shoes and More - Amazon.in") # self.ts.mark(title, "Title mismatch!") # result = self.lp.verifyLoginSuccessful() # self.ts.markFinal("test_validLogin",result,"Login was not successful") # self.hp.search(search) @pytest.mark.run(order=1) # * -- means mutiple args @data(*getCSVData( "/Users/aravindanathdm/Documents/Simple_Pom_py_fw/testdata.csv")) @unpack def test_validLogin(self, email, password, search): self.lp.login(email, password) # Online Shopping site in India: Shop Online for Mobiles, Books, Watches, Shoes and More - Amazon.in title = self.lp.verifyTitle( "Online Shopping site in India: Shop Online for Mobiles, Books, Watches, Shoes and More - Amazon.in" ) self.ts.mark(title, "Title mismatch!") result = self.lp.verifyLoginSuccessful() self.ts.markFinal("test_validLogin", result, "Login was not successful") self.hp.search(search)
def test_valid_login(self): url = "https://courses.letskodeit.com" driver = webdriver.Chrome() driver.maximize_window() driver.get(url=url) lp = HomePage(driver) lp.login("*****@*****.**", "brownwindow*03") # sign_in_link = driver.find_element(By.XPATH, "//a[text()='Sign In']") # sign_in_link.click() # # email_id = driver.find_element(By.ID, "email") # email_id.send_keys("*****@*****.**") # # password = driver.find_element(By.ID, "password") # password.send_keys("brownwindow*03") # # login_button = driver.find_element(By.XPATH, "//input[@value='Login']") # login_button.click() image_home = driver.find_element(By.XPATH, "//img[@class='img-fluid']") if image_home is not None: print("test successful") else: print("test failed")
class TestAddToCart(unittest.TestCase): @pytest.fixture(autouse=True) def class_setup(self, one_time_setup): self.add_first_product_from_woman_tops = HomePage(self.driver) @pytest.mark.run(order=1) def add_to_cart(self): self.add_first_product_from_woman_tops.test_1()
class SanityTestPage1(BasePage): def __init__(self, driver): super().__init__(driver) self.driver = driver self.home_page = HomePage(driver) def reach_woman_dresses(self): self.home_page.click_woman_dresses()
def test_validHomePage(self): baseURL = "https://jonathanopperman.info/" driver = webdriver.Chrome() driver.maximize_window() driver.implicitly_wait(3) driver.get(baseURL) hp = HomePage(driver) hp.clickTwitterSocialLink()
class LoginPage(SeleniumDriver): """Page class for www.x-kom.pl login page""" _username = "******" _password = "******" _login_button = "//button[@type='submit']" _empty_username_info = "login-error" _empty_password_info = "password-error" _register_button = "//a[@href='/rejestracja/']" _incorrect_credentials_info = "//div[contains(@class,'alert-dismissible') and contains(@class, 'alert-warning')]" def __init__(self, driver): self.driver = driver super().__init__(driver) self.hp = HomePage(driver) def click_on_register_buton(self): self.element_click(self._register_button, locator_type='xpath') def enter_username(self, username): self.element_send_keys(username, self._username, locator_type='name') def enter_password(self, password): self.element_send_keys(password, self._password, locator_type='name') def click_on_login_button(self): self.element_click(self._login_button, locator_type='xpath') def verify_empty_username_info(self): user_icon_present = self.is_element_present(self._empty_username_info, locator_type='id') assert user_icon_present == True def verify_empty_password_info(self): user_icon_present = self.is_element_present(self._empty_password_info, locator_type='id') assert user_icon_present == True, 'Cannot locate user icon' def verify_empty_credentials_info(self): self.verify_empty_username_info() self.verify_empty_password_info() def verify_incorrect_credentials_info(self): incorrect_credentials_info_present = self.is_element_present( self._incorrect_credentials_info, locator_type='xpath') assert incorrect_credentials_info_present == True def login(self, username='', password=''): self.hp.hover_to_login_icon() self.hp.click_on_login_link() self.enter_username(username) self.enter_password(password) self.click_on_login_button()
class HomePageTests(unittest.TestCase): @pytest.fixture(autouse=True) def class_setup(self): self.home_page = HomePage(self.driver) def test_home_page(self): print("step 1") print("step 2") result = self.home_page.verify_home_page_title() assert result is True time.sleep(1) result = self.home_page.verify_redirected_to_workshops_page() assert result is True time.sleep(1)
def one_time_setup(request, browser): print('Running one time setup') wdf = WebDriverFactory(browser) driver = wdf.get_webdriver_instance() home = HomePage(driver) home.log_in() if request.cls is not None: request.cls.driver = driver yield driver driver.quit() print('Running One time Teardown')
class ProductListingPage(BasePage): def __init__(self, driver): super().__init__(driver) self.driver = driver self.home = HomePage(driver) # Locators _plp_add_to_cart = 'a[title="Add to cart"]' # CSS _list_view_type = 'a[title="List"]' # CSS _grid_view_type = 'a[title="Grid"]' _color_click_path = '//ul[contains(@class, "product_list ")]/li[{0}]//ul[contains(@class, "color_to_pick_list ")]//li[{1}]/a' _color_click = _color_click_path.format('2', '1') # first is number of the product div; second is color # _product_containers = '//ul[contains(@class, "product_list")]' # Xpath # _color_container = '//ul[contains(@class, "color_to_pick_list ")]' _close_cart_icon = 'span[title="Close window"]' # XPATH def switch_view(self, view_type): if view_type == 'List': self.click_element(self._list_view_type, By.CSS_SELECTOR) elif view_type == 'Grid': self.click_element(self._grid_view_type, By.CSS_SELECTOR) else: self.logger.error("Wrong View Type. It Should be either List or View") def nth_product_add_to_cart(self, i): self.click_element_from_list_number(self._plp_add_to_cart, By.CSS_SELECTOR, i) def close_modal_cart(self): self.wait_for_element(self._close_cart_icon, By.XPATH) self.home.close_cart_window() def click_container_color(self): self.click_element(self._color_click, By.XPATH) def plp_test_1(self, i): self.wait_for_element(self._list_view_type, By.CSS_SELECTOR, timeout=5) self.switch_view('List') self.nth_product_add_to_cart(i) def plp_test_2(self): self.close_modal_cart() time.sleep(2) self.click_container_color() time.sleep(2)
class LoginTests(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.lp = LoginPage(self.driver) self.ts = TestStatus(self.driver) self.hp = HomePage(self.driver) # self.ap = AddressPage(self.driver) @pytest.mark.run(order=1) def test_validLogin(self): self.lp.login("*****@*****.**", "amazonapps") # Online Shopping site in India: Shop Online for Mobiles, Books, Watches, Shoes and More - Amazon.in title = self.lp.verifyTitle("Online Shopping site in India: Shop Online for Mobiles, Books, Watches, Shoes and More - Amazon.in") self.ts.mark(title, "Title mismatch!") result = self.lp.verifyLoginSuccessful() self.ts.markFinal("test_validLogin",result,"Login was not successful") self.hp.search("iphone 7")
def set_up(request, username, password): df = DriverFactory("Chrome") driver = df.launch_browser() if request.cls is not None: request.cls.driver = driver request.cls.bp = BasePage(driver) request.cls.lp = LoginPage(driver) request.cls.hp = HomePage(driver) request.cls.username = username request.cls.password = password yield driver driver.quit()
class TestLogin(unittest.TestCase): @pytest.fixture(autouse=True) def class_setup(self, one_time_set_up): self.hp = HomePage(self.driver) @pytest.mark.run(order=2) # @pytest.mark.skip def test_valid_login(self): # Home page self.hp.login('*****@*****.**', 'coding*016') # verify title # title_result = self.hp.verify_title() # assert title_result == True # verify success login login_result = self.hp.verify_login_success() assert login_result == True @pytest.mark.run(order=1) def test_invalid_login(self): self.hp.login('*****@*****.**', 'testtest') result = self.hp.verify_login_fail() assert result == True
def test_validLogin(self): baseUrl = "https://twitter.com/login" driver = webdriver.Chrome("/usr/local/bin/chromedriver") driver.maximize_window() driver.implicitly_wait(3) driver.get(baseUrl) lp = LoginPage(driver) lp.login("*****@*****.**", "108stoosiem108") signupLink = driver.find_element(By.XPATH, "//*[@id='user-dropdown-toggle']") if signupLink is not None: print("Login Good") else: print("Login Bad") hp = HomePage(driver) hp.clicking() ap = LogAgain(driver) ap.againLogin("*****@*****.**", "dupa8")
class TestLoginPage(unittest.TestCase): @pytest.fixture(autouse=True) def custom_setup(self): self.lp = LoginPage(self.driver) self.hp = HomePage(self.driver) @pytest.mark.run(order=1) def test_valid_login(self): self.lp.login(username='******', password='******') self.hp.verify_user_icon_presence() self.hp.logout() @pytest.mark.run(order=5) def test_invalid_login(self): self.lp.login(username='******', password='******') self.lp.verify_incorrect_credentials_info() self.lp.go_to_previous_page() @pytest.mark.run(order=2) def test_empty_login_credentials(self): self.lp.login() self.lp.verify_empty_credentials_info() self.lp.go_to_previous_page() @pytest.mark.run(order=3) def test_empty_username_login(self): self.lp.login(password='******') self.lp.verify_empty_username_info() self.lp.go_to_previous_page() @pytest.mark.run(order=4) def test_empty_password_login(self): self.lp.login(username='******') self.lp.verify_empty_password_info() self.lp.go_to_previous_page()
class LoginTests(unittest.TestCase): log = cl.customLogger(logging.DEBUG) @pytest.fixture(autouse=True) def login(self, oneTimeSetUp): self.home = HomePage(self.driver) self.login = LoginPage(self.driver) self.login.acceptEula() self.login.loginWith("blablaUser") @pytest.mark.run(order=1) def test_sequenceInTheGrid(self): wordsToClick = ["are", "is"] writtenText = self.home.writeInTheTextAreaByClickingOnTheGrid( wordsToClick) assert writtenText == wordsToClick
def player(context): player_name = "Bernie Kosar" hp = HomePage(context.driver) hp.player_search(player_name)
def class_setup(self, module_setup_to_test_class): self.find_workshop_page = FindWorkshopPage(self.driver) self.home_page = HomePage(self.driver)
def __init__(self, driver): super().__init__(driver) self.driver = driver self.home_page = HomePage(driver)
def classSetup(self): self.lp = LoginPage(self.driver) self.ts = TestStatus(self.driver) self.hp = HomePage(self.driver) self.ad = AddressPage(self.driver)
class TestMyAcc(unittest.TestCase): @pytest.fixture(autouse=True) def class_set_up(self, one_time_setup): self.home = HomePage(self.driver) self.errors = ErrorStatus(self.driver) self.account = MyAccount(self.driver) # def test_my_addresses(self): # # # ADD FIRST ADDRESS # self.account.add_address() # # result = self.home.verify_no_addresses() # if result is True: # result = False # else: # result = True # self.errors.mark(result, 'Checking if address is added') # # # UPDATE ADDRESS # self.account.update_address() # # result = self.account.verify_updated_state() # self.errors.mark(result, 'Editing address') # # # DELETE ADDRESS # self.home.address_delete() # # result = self.home.verify_no_addresses() # self.errors.mark_final('Addresses test', result, 'Deleting address') # # # LOGOUT # self.home.log_out() # # def test_a_order_history(self): # self.home.go_to_homepage() # self.home.log_in() # # ORDER HISTORY # self.account.go_to_history() # # result = self.account.verify_checkout_btn() # self.errors.mark_final('My account test', result, "My Order History") # # self.home.log_out() def test_wishlist(self): self.home.log_in() self.home.go_to_homepage() self.home.adding_2_products_wishlist() self.account.test_wishlist() result_deleting_item = self.account.verify_item_delete() self.errors.mark(result_deleting_item, 'Deleting item') self.account.qty_manipulation() result_qty = self.account.verify_product_qty() self.errors.mark(result_qty, 'Qty manipulation inside wishlist') self.account.create_new_wishlist() result_new_wishlist = self.account.verify_new_wishlist() self.errors.mark(result_new_wishlist, 'Adding new wishlist') self.account.delete_wishlists() result_delete_wishlists = self.account.verify_wishlist_removed() self.errors.mark_final('Wish List tests', result_delete_wishlists, 'Deleting wishlists')
def classSetup(self, oneTimeSetUp): self.lp = LoginPage(self.driver) self.ts = TestStatus(self.driver) self.hp = HomePage(self.driver)
def class_set_up(self, one_time_setup): self.home = HomePage(self.driver) self.errors = ErrorStatus(self.driver) self.account = MyAccount(self.driver)
class SanityTest1(unittest.TestCase): @pytest.fixture(autouse=True) def class_setup(self, one_time_setup): self.home_page = HomePage(self.driver) self.errors = ErrorStatus(self.driver) self.plp = ProductListingPage(self.driver) self.pdp = PDP(self.driver) self.checkout = CheckoutPage(self.driver) # @pytest.mark.run(order=1) def test_a_reach_woman_dresses(self): self.home_page.click_woman_dresses() time.sleep(1) result = self.home_page.verify_woman_dresses_title( "Dresses - My Store") self.errors.mark_final( "Reach woman dress", result, 'Reach woman dresses Failed - Title doesnt match') # @pytest.mark.run(order=2) def test_b_plp_actions(self): self.plp.plp_test_1(0) time.sleep(1) add_result = self.pdp.test_qty_of_items_added(1) self.errors.mark_final("Test items in cart", add_result, "Failed to add 1 item from PLP") self.plp.plp_test_2() # @pytest.mark.run(order=3) def test_c_pdp_actions(self): self.pdp.test_pdp1() self.pdp.continue_to_checkout() result = self.pdp.products_in_cart(3) self.errors.mark_final("Cart qty check", result, "Qty in cart is not correct") # @pytest.mark.run(order=4) def test_d_cart_actions(self): self.checkout.cart_actions(1, 0) result = self.pdp.products_in_cart(2) self.errors.mark_final("Cart qty check", result, "Qty in cart is not correct") # @pytest.mark.run(order=5) def test_e_login_actions(self): self.checkout.click_proceed_to_checkout() self.checkout.login('*****@*****.**', '123') result = self.checkout.verify_invalid_login() self.errors.mark(result, 'Invalid Login Test') time.sleep(1) self.checkout.login('*****@*****.**', 'Zarko321') result = self.checkout.verify_valid_login() self.errors.mark_final('Login Actions', result, 'Valid Login Test') # @pytest.mark.run(order=6) def test_f_address_actions(self): self.checkout.add_new_address_btn() self.checkout.address_handling('Zarko', 'Test', '565 W Orchard st', 'Milwaukee', '53204', "Wisconsin", '2345678902') time.sleep(1) result = self.checkout.verify_address_submit_success() self.errors.mark(result, 'Adding Address') # select address from dropdown self.checkout.select_shipping_address_dropdown() self.checkout.add_billing_address() self.checkout.address_handling('Zarko', 'Test', '123 Santa Monica Blvd', 'Santa Monica', '90401', 'California', '2349030994') result_billing = self.checkout.verify_address_submit_success() self.errors.mark_final('Handling SHipping and billing address', result_billing, 'Billing Address Add') # @pytest.mark.run(order=7) def test_g_carrier_actions(self): self.checkout.handling_4th_step() bank_present = self.checkout.verify_payment_method_wire() self.errors.mark(bank_present, "Bank Payment Method present") check_present = self.checkout.verify_payment_check() self.errors.mark_final('Payment methods present', check_present, 'Check Payment Method present') # @pytest.mark.run(order=8) def test_h_place_order(self): self.checkout.place_order_wire() # @pytest.mark.run(order=9) def test_i_remove_addresses(self): self.home_page.address_delete() result = self.home_page.verify_no_addresses() self.errors.mark(result, "Removing addresses") self.home_page.log_out() result_2 = self.home_page.verify_log_out() self.errors.mark_final('Teardown', result_2, 'Log out') time.sleep(1)
def login(self, oneTimeSetUp): self.home = HomePage(self.driver) self.login = LoginPage(self.driver) self.login.acceptEula() self.login.loginWith("blablaUser")
class HomePageTests(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.ty = ThankYou(self.driver) self.ts = TestStatus(self.driver) @pytest.mark.run(order=1) def test_Empty(self): self.hp.clickSend() nameResult = self.hp.verifyNameError() self.ts.mark(nameResult, "Name error appears") phoneResult = self.hp.verifyPhoneError() self.ts.mark(phoneResult, "Phone error appears") emailResult = self.hp.verifyEmailError() self.ts.markFinal("Test empty fields", emailResult, "All error message appears") @pytest.mark.run(order=2) def test_NameOnly(self): self.hp.enterName('Daniel') self.hp.clickSend() phoneResult = self.hp.verifyPhoneError() self.ts.mark(phoneResult, "Phone error appears") emailResult = self.hp.verifyEmailError() self.ts.markFinal("Test only name", emailResult, "Phone and Email error message appears") @pytest.mark.run(order=3) def test_PhoneOnly(self): self.hp.enterPhone('0548040629') self.hp.clearName() self.hp.clickSend() nameResult = self.hp.verifyNameError() self.ts.mark(nameResult, "Name error appears") emailResult = self.hp.verifyEmailError() self.ts.markFinal("Test only Phone", emailResult, "Name and Email error message appears") @pytest.mark.run(order=4) def test_EmailOnly(self): self.hp.enterEmail('*****@*****.**') self.hp.clearPhone() self.hp.clickSend() phoneResult = self.hp.verifyPhoneError() self.ts.mark(phoneResult, "Name error appears") nameResult = self.hp.verifyNameError() self.ts.markFinal("Test only Email ", nameResult, "Name and Phone error message appears") @pytest.mark.run(order=5) def test_All(self): self.hp.clearName() self.hp.enterName('Daniel') self.hp.clearPhone() self.hp.enterPhone('0548040629') self.hp.clearEmail() self.hp.enterEmail('*****@*****.**') self.hp.clickSend() time.sleep(3) thankYouResult = self.ty.verifyCompleteSend() self.ts.markFinal("Test all", thankYouResult, "Thank page loaded")
def class_setup(self): self.home_page = HomePage(self.driver)
def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.ty = ThankYou(self.driver) self.ts = TestStatus(self.driver)
def class_setup(self, one_time_setup): self.home_page = HomePage(self.driver) self.errors = ErrorStatus(self.driver) self.plp = ProductListingPage(self.driver) self.pdp = PDP(self.driver) self.checkout = CheckoutPage(self.driver)