class Test_itemCount(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.lp = LoginPage(self.driver) self.pdp = ProductDetailsPage(self.driver) self.sp = ShoppingCartPage(self.driver) self.cp = CartPage(self.driver) @pytest.mark.run(order=1) def test_goToPDP(self): self.hp.goToLogin() credentials = json.loads(open('loginCredential.json').read()) username = credentials.get('username') password = credentials.get('password') # l = [i for i in credentials.values()] self.lp.loginAmazon(username,password) self.hp.goToAmazonEcho() self.pdp.addToCart() self.sp.goToCart() before=self.cp.getTheQuantity() self.driver.back() self.driver.back() self.pdp.addToCart() self.sp.goToCart() after=self.cp.getTheQuantity() assert before<after,"Quantity is not incremented"
class Test_productDetails(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.lp = LoginPage(self.driver) self.pdp = ProductDetailsPage(self.driver) self.sp = ShoppingCartPage(self.driver) self.cp = CartPage(self.driver) self.dap = DeliveryAddressPage(self.driver) self.sop = ShippingOptionPage(self.driver) self.pp = PaymentPage(self.driver) @pytest.mark.run(order=1) def test_goToPDP(self): self.hp.goToLogin() credentials = json.loads(open('loginCredential.json').read()) username = credentials.get('username') password = credentials.get('password') self.lp.loginAmazon(username, password) self.hp.goToAmazonEcho() self.pdp.addToCart() self.sp.goToCart() self.cp.proceedToCheckout() self.dap.goToAdress() self.sop.continueCheckout() self.pp.paymentDetails()
def searchProd(request): hp = HomePage(request.cls.driver) plp = ProductListPage(request.cls.driver) prodname = hp.getDataFromJsonFile("ReadProductName.json", "bang") hp.search_product(prodname) yield assert prodname in plp.check_search_box(), "Search not working" print("Searchbox validated")
def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.lp = LoginPage(self.driver) self.pdp = ProductDetailsPage(self.driver) self.sp = ShoppingCartPage(self.driver) self.cp = CartPage(self.driver) self.dap = DeliveryAddressPage(self.driver) self.sop = ShippingOptionPage(self.driver) self.pp = PaymentPage(self.driver)
class Test_login(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp, loginSetup): self.hp = HomePage(self.driver) print("Logging in") @pytest.mark.run(order=1) def test_validLogin(self): self.hp.verifyLogin()
def search(request): key = "alexa" hp = HomePage(request.cls.driver) alp = AlexaListingPage(request.cls.driver) hp.searchProduct(key) yield print("Searching validated") assert key in alp.verifyResultKeyName( ), "Result products are not matched with the search key" print("Result products are matched with the search key")
def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.plp = ProductListPage(self.driver) self.pdp = PDP_Page(self.driver) self.cartpage = CartPage(self.driver) self.sign_up = SignUpPage(self.driver) self.address = DeliveryAddressPage(self.driver) self.shipment = ShipmentPage(self.driver) self.payment = PaymentMethodPage(self.driver) self.order = PlaceOrderPage(self.driver)
class Test_login(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp, loginLogout): self.hp = HomePage(self.driver) @pytest.mark.run(order=1) def test_validLogin(self): self.hp.verifyLoggedinUser() self.hp.goToCart() print("I am in cart")
class Test_productDetails(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.pdp = ProductDetailsPage(self.driver) @pytest.mark.run(order=1) def test_goToPDP(self): self.hp.goToAmazonEcho() actual = self.pdp.getAvailibilityAlexa() assert "In stock" in actual, "Product is not in stock"
class Test_StockAvailabilty(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.plp = ProductListPage(self.driver) self.pdp = PDP_Page(self.driver) @pytest.mark.run(order=1) def test_stock_availability(self): self.hp.select_category("Beauty") self.plp.select_product() assert "InStock" in self.pdp.verifystock(), "Product not available" print("Product in stock")
class Test_CartItemCount(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.plp = ProductListPage(self.driver) @pytest.mark.run(order=1) def test_sort_asc(self): self.hp.search_product("laptop") sortprices = self.plp.verify_sort_prod_in_asc() print("Prices after sort:",sortprices)
class Test_productDetails(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.mlp = MobilesAccessoriesListingPage(self.driver) self.rlp = RedmiListingPage(self.driver) @pytest.mark.run(order=1) def test_goToPDP(self): self.hp.goToMobilePhones() self.mlp.goToRedmiY2() print("Total: ", self.rlp.totalResultExpected()) self.rlp.resultActual()
class Test_productDetails(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.wlp = WomenWesternWearListingPage(self.driver) self.wwlp = WinterWearListingPage(self.driver) self.pdp = ProductDetailsPage(self.driver) @pytest.mark.run(order=1) def test_goToPDP(self): self.hp.goToWesternWear() self.wlp.goToWinterWear() self.wwlp.goTo1stProduct()
class Test_productListing(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.mlp = MobilesAccessoriesListingPage(self.driver) @pytest.mark.run(order=1) def test_goToPDP(self): self.hp.goToMobilePhones() self.mlp.filterByBrand() expected = self.mlp.getTotalResultText() actual = self.mlp.getTotalResult() print(expected,actual)
class Test_productDetails(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.mlp = MobilesAccessoriesListingPage(self.driver) self.rlp = RedmiListingPage(self.driver) @pytest.mark.run(order=1) def test_goToPDP(self): self.hp.goToMobilePhones() self.mlp.goToRedmiY2() self.rlp.filterByOSColor() self.rlp.navigateToMultipage()
class Test_productDetails(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.pdp = ProductDetailsPage(self.driver) @pytest.mark.run(order=1) def test_goToPDP(self): self.hp.goToAmazonEcho() actual=self.pdp.getAvailibilityAlexa() assert "In stock" in actual,"Product is not in stock" time.sleep(5) print("The total count of review: ",self.pdp.getReviewCount()) print("The Review Summary: ") self.pdp.getReviews()
class Test_SearchBox(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.plp = ProductListPage(self.driver) @pytest.mark.run(order=1) def test_verify_searchField(self): # prod_name = json.loads(open("ReadProductName.json").read()) # pname = prod_name["product_name"] pname = self.hp.getDataFromJsonFile("ReadProductName.json", "product_name") self.hp.search_product(pname) actual_prod_text = self.plp.check_search_box() assert pname in actual_prod_text, "Search not working" print("Search box passed")
class Test_BrandFilter(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.plp = ProductListPage(self.driver) @pytest.mark.run(order=1) def test_verify_brand(self): self.hp.search_product("power bank") brands = self.plp.filter_verify_brand_name() print(brands) brand_name = self.plp.get_brand_name() #print(bname) for brand in brands: assert brand_name == brand, "Brand does not match" print("Brand filter validated")
class Test_MenusInHomePage(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) @pytest.mark.run(order=1) def test_All_Menu_Names(self): self.hp.mouseOverOnCategory() menunames = self.hp.get_all_menus() print(menunames) # for menu in menunames: # assert menu in self.hp.all_menu_names,"Menus not matching as expected " # print("All menu names validated") for i in range(len(menunames)): assert self.hp.getDataFromFile( "E:/Automation/Selenium_Automation1/framework/MenusList.txt" ) in menunames, "Menus not matching as expected" print("All menus are validated")
class Test_ReviewFilter(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.plp = ProductListPage(self.driver) @pytest.mark.run(order=1) def test_verify_avg_review_filter(self): self.hp.search_product( self.hp.getDataFromJsonFile("ReadProductName.json", "Hp")) self.plp.filter_by_Customer_Review() review_stars = self.plp.get_All_Filtered_Reviews() print(review_stars) expected_review_stars = [ '4', '4.1', '4.2', '4.3', '4.4', '4.4', '4.5', '4.6', '4.7', '4.8', '4.9', '5' ] for star in review_stars: assert star in expected_review_stars, "Products are not filtered by stars " print("Product displayed according to Avg review filtered")
class Test_PageNavigation(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.plp = ProductListPage(self.driver) @pytest.mark.run(order=1) def test_nextpage_option(self): self.hp.select_category("Automotive") self.plp.select_subshopByCategory() page_num_before = self.plp.get_current_page_number() time.sleep(2) print(page_num_before) self.plp.goToNextPage() time.sleep(5) page_num_after = self.plp.get_current_page_number() print(page_num_after) time.sleep(5) assert page_num_after == str(int(page_num_before) + 1), "Page is not navigated to next page" print("Page Navigation is working")
class Test_productDetails(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.lp = LoginPage(self.driver) self.pdp = ProductDetailsPage(self.driver) self.sp = ShoppingCartPage(self.driver) self.cp = CartPage(self.driver) @pytest.mark.run(order=1) def test_goToPDP(self): self.hp.goToLogin() credentials = json.loads(open('loginCredential.json').read()) username = credentials.get('username') password = credentials.get('password') self.lp.loginAmazon(username, password) self.hp.goToAmazonEcho() self.pdp.addToCart() self.sp.goToCart() before = self.cp.getTheTotalAmount() self.driver.close()
class Test_CartChangeQuantity(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.plp = ProductListPage(self.driver) self.pdp = PDP_Page(self.driver) self.cartpage = CartPage(self.driver) @pytest.mark.run(order=1) def test_cart_changeqty_priceupdate(self): self.hp.search_product("bangles") self.plp.select_product() self.pdp.clickAddToCart() self.hp.click_cart_icon() subtotal1 = float(self.cartpage.get_subtotal()) print("Subtotal price before qty update:", subtotal1) cartcount1 = self.hp.get_cart_count() print("Cart Count Before:", cartcount1) price = self.cartpage.get_prod_price() price_of_prod = price[0] self.cartpage.change_Quantity("2") time.sleep(3) subtotal2 = float(self.cartpage.get_subtotal()) print("SubTotal price After quantity update:", subtotal2) cartcount2 = self.hp.get_cart_count() print("Cart Count After:", cartcount2) assert cartcount2 == str(int(cartcount1) + 1), "cart count not incremented" print("Cart count is incremented by one") assert subtotal2 == price_of_prod * 2, "Subtotal price not updated" print("Subtotal price in cart page is updated")
class Test_CartRemoveItem(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.plp = ProductListPage(self.driver) self.pdp = PDP_Page(self.driver) self.cartpage = CartPage(self.driver) @pytest.mark.run(order=1) def test_cart_removeitem_priceupdate(self): self.hp.search_product("bangles") self.plp.select_product() self.pdp.clickAddToCart() self.hp.select_category() self.plp.select_product() self.pdp.clickAddToCart() self.hp.click_cart_icon() totalprice_before = self.cartpage.get_subtotal() print(totalprice_before) remove_price=self.cartpage.get_remove_prod_price() self.cartpage.remove_product() time.sleep(2) totalprice_after = self.cartpage.get_subtotal() print(totalprice_after) result_price = str(float(totalprice_before) - float(remove_price)) assert totalprice_after in result_price,"Subtotal price not updated" print("Subtotal price is updated after removing the product from the cart")
class Test_CartItemCount(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.plp = ProductListPage(self.driver) self.pdp = PDP_Page(self.driver) @pytest.mark.run(order=1) def test_cart_ItemCount(self): self.hp.search_product("bags") self.plp.select_product() self.pdp.clickAddToCart() cartcount1 = int(self.hp.get_cart_count()) print("BeforeCount:",cartcount1) self.hp.select_category() self.plp.select_product() self.pdp.clickAddToCart() #time.sleep(2) cartcount2 = int(self.hp.get_cart_count()) print("AfterCount:",cartcount2) cartcount1=cartcount1+ 1 assert cartcount2==cartcount1,"Cart count not incrementing" print("Cart Count incremented by one")
def loginSetup(request): hp = HomePage(request.cls.driver) hp.goTologinPage() sp = SignUpPage(request.cls.driver) sp.login("*****@*****.**", "MithunaAmazon@123") yield hp.logout() print("Logout Successful")
def loginLogout(request): hp = HomePage(request.cls.driver) lp = LoginPage(request.cls.driver) credentials = hp.fetchJSONData('loginCredential.json') username = credentials.get('username') password = credentials.get('password') hp.goToLogin() lp.loginAmazon(username, password) print("Successfully login") yield hp.logout() print("Successfully logout")
def classSetup(self, oneTimeSetUp, loginSetup): self.hp = HomePage(self.driver) print("Logging in")
def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.alp = AlexaListingPage(self.driver)
def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.plp = ProductListPage(self.driver)