def test_end2end(self): print(self.driver.title) print(self.driver.current_url) time.sleep(5) homePage = HomePage(self.driver) homePage.shopItems().click() # Click shop button: checkOutPage = CheckOutPage(self.driver) products = checkOutPage.productsTitles() # Identify all 4 products on the page: # Scroll to top of the page: self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") # scroll from 0 to highest time.sleep(3) # Perform for loop to add product to basket: for product in products: print(product.find_element_by_xpath("div/h4/a").text) productName = product.find_element_by_xpath("div/h4/a").text productName = productName if productName == "Blackberry": product.find_element_by_xpath("div/button").click() # This Clicks add button of item with name Blackberry time.sleep(3) # Scroll to top of the page self.driver.execute_script("window.scrollTo(document.body.scrollHeight, 0);") # scroll from highest to 0 time.sleep(3) # Click first CheckOut button: checkOutPage.clickCheckOutA().click() time.sleep(3) # Assert that product on page 1 is present in page 2 -> Check Out page: assert productName == productName print(productName) # Click final CheckOut button: checkOutPage.finalProductCheckOut().click() time.sleep(2) # Insert country of destination: checkOutPage.enterCountryName().send_keys("Nigeria") time.sleep(5) # select checkbox: checkOutPage.selectCheckBox().click() # Click Purchase button: checkOutPage.clickPurchaseButton().click() # Get transaction success text and print to console: successText = checkOutPage.displayMessage().text print(successText) # Assertion true: assert "Success! Thank you! Your order will be delivered in next few weeks :-)." in successText # Capture screenshot of success page: self.driver.get_screenshot_as_file("EndToEnd_screenshot.png")
def test_e2e(self): log = self.getLogger() homePage = HomePage(self.driver) checkOutPage = homePage.shopItems() log.info("getting all the card titles") cards = checkOutPage.getCardTitles() for product in cards: productName = product.find_element_by_xpath("div/h4/a").text log.info(productName) if productName == "Blackberry": product.find_element_by_xpath("div/button").click() checkOutPage.clickCheckOutBtn().click() confirmPage = checkOutPage.clickSuccessBtn() log.info("Entering country name as ind") confirmPage.clickCountry().send_keys("ind") self.verifyLinkTest("India") confirmPage.clickInd().click() confirmPage.tickCheckBox().click() confirmPage.buyitem().click() message = confirmPage.getmessage().text log.info("Test from application " + message) assert "Success!" in message self.driver.get_screenshot_as_file("sereen.png") print("add by gitDemo first time") print("add by gitDemo second time") print("add 3rd time") print("This is done by GitX") print("this is done by GitDemo in develop ") print("this is by gitx devlop 1st time") print("this is last by gitx master")
def test_e2e(self, setup): log = self.getLogger() log.debug("starting test") home_page = HomePage(self.driver) checkout_page = home_page.shop_items() cards = checkout_page.get_card_title() i = -1 for card in cards: i = i + 1 cardText = card.text if cardText == "Blackberry": checkout_page.get_card_footer()[i].click() self.driver.find_element_by_css_selector( "a[class*='btn-primary']").click() confirm_page = checkout_page.checkout_items() confirm_page.type_country("ind") self.verify_link_presence("India") confirm_page.select_country("India") confirm_page.i_agree() confirm_page.submit() textMatch = confirm_page.success_alert() assert ("Success! Thank you!" in textMatch)
def test_end2end(self): log = self.getLogger() homePage = HomePage(self.driver) checkOutPage = homePage.shopItems() log.info("getting all the card titles") cards = checkOutPage.getCardTitles() i = -1 for card in cards: i = i + 1 cardText = card.text log.info(cardText) print(cardText) if cardText == "Blackberry": checkOutPage.getCardFooter()[i].click() checkOutPage.getPurchaseButton().click() checkOutPage.checkOutItems() log.info("Entering country name as ind") checkOutPage.getCountry().send_keys("ind") # time.sleep(5) self.verifyLinkPresence("India") self.driver.find_element_by_link_text("India").click() checkOutPage.click_checkBox() checkOutPage.click_Submit() textMatch = checkOutPage.getSuccessMessage() log.info("Text Recieved from application is " + textMatch) assert ("Success! Thank you!" in textMatch)
def test_goto_tips(self): log = self.getLogger() homepage = HomePage(self.driver) tip_page = homepage.goto_TipsAndAdvice() log.info("Navigate to Tips & Advice Page") tip_content = tip_page.check_tipsSubscription() log.info("Smoke Test Subscription") assert tip_content is not None
def test_goto_pricing(self): log = self.getLogger() homepage = HomePage(self.driver) price_page = homepage.goto_Pricing() log.info("Navigate to Pricing Page") price_content = price_page.check_pricingContent() log.info("Smoke Test Main Price Content Section") assert price_content is not None
def test_goto_apps(self): log = self.getLogger() homepage = HomePage(self.driver) apps_page = homepage.goto_Apps() log.info("Navigate to Apps Page") apps_content = apps_page.check_mainContent() log.info("Smoke Test Apps Main Content Section") assert apps_content is not None
def test_goto_explore(self): log = self.getLogger() homepage = HomePage(self.driver) explore_page = homepage.goto_Explore() log.info("Navigate to Explore Page") explore_content = explore_page.check_popularArticles() log.info("Smoke Test Popular Articles") assert explore_content is not None
def test_e2e(self): log = self.getLogger() # self.driver.find_element_by_xpath("//a[normalize-space()='Shop']").click() homePage = HomePage(self.driver) checkoutPage = homePage.shopItems() log.info('getting all the product titles') products = self.driver.find_elements_by_xpath( "//div[@class='card h-100']") # checkoutPage = CheckoutPage(self.driver) for product in products: productName = product.text print(productName) # log.info(productName) if productName == 'Blackberry': # product.find_element_by_xpath('div[2]/button').click() checkoutPage.productNameButton().click() # self.driver.find_element_by_css_selector("a[class*='btn-primary']").click() # self.driver.find_element_by_xpath("//button[@class='btn btn-success']").click() checkoutPage.checkOutItems().click() confirmPage = checkoutPage.checkOutItems2() log.info('Entering country name as ind') self.driver.find_element_by_id('country').send_keys('ind') # wait = WebDriverWait(self.driver, 7) # wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, 'India'))) self.verifyLinkPresence('India') # self.driver.find_element_by_link_text('India').click() # self.driver.find_element_by_xpath("//div[@class='checkbox checkbox-primary']").click() # self.driver.find_element_by_xpath("//input[@value='Purchase']").click() confirmPage.dropdownMenu().click() confirmPage.checkBox().click() confirmPage.purchaseButton().click() successText = self.driver.find_element_by_class_name( "alert-success").text log.info('Text received from application is ' + successText) assert 'Success! Thank you!' in successText self.driver.get_screenshot_as_file('screen.png')
def test_E2E( self ): # don't want to give the fixture name in the function if you are inheriting the parent class # if you want to access a class variable inside your method use self.class variable homepage = HomePage(self.driver) self.driver.find_element_by_link_text("Shop").click() products = self.driver.find_elements_by_xpath( "//app-card-list[@class='row']/app-card") print(len(products)) # will give the product count # "//app-card-list[@class='row']/app-card/div/div/h4/a" will give the product names # "//app-card-list[@class='row']/app-card/div/div/h5" will give the prices # "//app-card-list[@class='row']/app-card/div/div[2]/button" will gve the add buttons for product in products: productname = product.find_element_by_xpath( "div/div/h4/a") # will iterate and give each product name print(productname.text) productprice = product.find_element_by_xpath( "div/div/h5") # will iterate and will give each product price print(productprice.text) addtocart = product.find_element_by_xpath( "div/div[2]/button" ) # will iterate through and will give the add to cart button print(addtocart.text) if productname.text == "Blackberry": addtocart.click() # if you want to add all items in the cart below is the code # for product in products: productname = product.find_element_by_xpath("div/div/h4/a") # will iterate and give each # product name print(productname.text) productprice = product.find_element_by_xpath("div/div/h5") # will iterate and # will give each product price print(productprice.text) addtocart = product.find_element_by_xpath("div/div[ # 2]/button") # will iterate through and will give the add to cart button print(addtocart.text) addtocart.click() self.driver.find_element_by_xpath( "//a[@class='nav-link btn btn-primary']").click( ) # will click on the checkout(1)button self.driver.find_element_by_xpath( "//button[@class='btn btn-success']").click( ) # will click on the chekout button self.driver.find_element_by_id("country").send_keys( "ind") # inspecting the country box # adding explicit wait wait = WebDriverWait(self.driver, 7) wait.until( expected_conditions.presence_of_element_located( (By.LINK_TEXT, "India"))) # waiting till the element is # located self.driver.find_element_by_link_text( "India").click() # will click the country name India self.driver.find_element_by_xpath( "//input[@class='btn btn-success btn-lg']").click( ) # will click the purchase button # print(driver.find_element_by_xpath("//div[@class='alert alert-success alert-dismissible']").text) # will print the # message successtext = self.driver.find_element_by_xpath( "//div[@class='alert alert-success alert-dismissible']").text assert "Success! Thank you!" in successtext
def test_e2e(self): log = self.getlogger() homepage = HomePage(self.driver) checkoutpage = homepage.shopitems() log.info("loading products page") products = checkoutpage.getproductstitle() #products = self.driver.find_elements_by_xpath("//div[@class='card h-100']") # //div[@class='card h-100']/div/h4/a # product =//div[@class='card h-100'] i = -1 for product in products: i += 1 productname = product.text log.info(productname) if productname == "Blackberry": # Add item into cart log.info("Item Matched") checkoutpage.getaddtocart()[i].click() log.info("Item added to cart") checkoutpage.getcheckoutinshop().click() confirmpage = checkoutpage.getcheckoutincart() confirmpage.getlocation().send_keys("ind") self.objectpresence("India") confirmpage.getselectloc().click() log.info("Country selected") confirmpage.gettermsandcond().click() confirmpage.getsubmit().click() successtext = confirmpage.getsubmitmessage().text #successtext = self.driver.find_element_by_class_name("alert-success").text assert "Success! Thank you!" in successtext log.info("Purchase successful with messaage " + successtext) try: self.driver.get_screenshot_as_file("screen.png") except AttributeError: log.error("Taking screenshot failed")
def test_e2e(self): log = self.get_logger() home_page = HomePage(self.driver) time.sleep(5) #home_page.shop_items().click() # self.driver.find_element_by_css_selector("a[href*='shop']").click() # check_out_page = CheckOutPage(self.driver) check_out_page = home_page.shop_items() cards = check_out_page.get_card_title() log.info("getting all the card titles.") i = -1 for card in cards: i = i + 1 card_text = card.text log.info(card_text) if card_text == "Blackberry": check_out_page.get_card_footer()[i].click() self.driver.find_element_by_css_selector( "a[class*='btn-primary']").click() confirm_page = check_out_page.get_check_out_items() self.driver.find_element_by_id("country").send_keys("ind") log.info("Entered country name as ind") ''' element = WebDriverWait(self.driver, 10).until( EC.presence_of_element_located(By.LINK_TEXT, "India")) ''' self.is_link_presence("India") time.sleep(3) self.driver.find_element_by_link_text("India").click() self.driver.find_element_by_xpath( "//div[@class='checkbox checkbox-primary']").click() self.driver.find_element_by_xpath("//input[@value='Purchase']").click() text_match = self.driver.find_element_by_css_selector( "[class*='alert-success']").text log.info("Text received from application is" + text_match) assert ("Success! Fail for test Thank you!" in text_match)
def test_e2e(self): homePage = HomePage(self.driver) itemList1 = [] itemList2 = [] homePage.SearchBar().send_keys("ber") time.sleep(3) ItemsFound = homePage.AddToCartItem() print(len(ItemsFound)) for item in ItemsFound: # ItemName = item.find_element_by_xpath("parent::div/parent::div/h4").text ItemName = item.find_element_by_xpath("../../h4").text itemList1.append(ItemName) item.click() print(itemList1) # Add to cart homePage.CartIcon().click() homePage.ProceedToCheckOut().click() self.PresenseOfElement("//*[@class='promoBtn']") CartItem = self.driver.find_elements_by_xpath("//*[@class='product-name']") print(len(CartItem)) for cartI in CartItem: CItem = cartI.text print(CItem) itemList2.append(CItem) print(itemList2) assert itemList1 == itemList2 print("This is GIT demo testing") print("We will push this code to the repository") print("We will push this code to the repository") print("This is GIT demo testing") print("We will push this code to the repository") print("We will push this code to the repository") print("This is GIT demo testing") print("We will push this code to the repository") print("We will push this code to the repository")
def test_logo(self): log = self.getLogger() homepage = HomePage(self.driver) log.info("Checking Logo is Present") img_source = homepage.get_logo().get_attribute("src") assert "https://cdn.zapier.com/ssr/1a57f1f796c1fd66a1380ee168dfb612ce7e21f1/_next/static/images/zapier-small-orange-logo.png" in img_source
def test_form_submission_with_dict_data_driven(self, get_dict_data): home_page = HomePage(self.driver) home_page.get_name().clear() home_page.get_name().send_keys(get_dict_data["fname"]) home_page.get_email().clear() home_page.get_email().send_keys(get_dict_data["email"]) home_page.get_checkbox().click() self.select_option_by_text(home_page.get_gender(), get_dict_data["gender"]) home_page.submit_form().click() success_msg = home_page.get_alert_text().text assert ("Success" in success_msg)
def test_search_bar(self): log = self.getLogger() homepage = HomePage(self.driver) log.info("Checking Search bar is present") search_bar = homepage.get_searchBar() assert search_bar is not None
def test_formSubmittion(self, getData): log = self.getLogger() homePage = HomePage(self.driver) homePage.enterName().send_keys(getData["firstname"]) log.info("firstname" + getData["firstname"]) homePage.enteremail().send_keys(getData["email"]) # Select class provided some method to handle dropdown self.selectOptionByText(homePage.mOrF(), getData["gender"]) homePage.clickTick().click() homePage.submitBtn().click() message = homePage.getMsz().text assert "success" in message self.driver.refresh()
def test_form_submission(self): home_page = HomePage(self.driver) home_page.get_name().send_keys("Russel") home_page.get_email().send_keys("*****@*****.**") home_page.get_checkbox().click() #sel = Select(home_page.get_gender()) #sel.select_by_visible_text("Male") self.select_option_by_text(home_page.get_gender(), "Male") home_page.submit_form().click() success_msg = home_page.get_alert_text().text assert ("Success" in success_msg)
def test_form_submission(self, getData): log = self.getLogger() log.debug("starting test") homepage = HomePage(self.driver) m = getData["firstname"] homepage.get_name().send_keys(getData["firstname"]) homepage.get_email().send_keys(getData["lastname"]) homepage.get_checkbox().click() self.select_option_by_text(homepage.get_gender(), getData["gender"]) homepage.submit_form().click() alertText = homepage.get_success_message().text assert ("Success" in alertText) self.driver.refresh()
def test_formSubmission(self, getData): # driver = webdriver.Chrome(executable_path='C:\\chromedriver.exe') # driver.get('https://rahulshettyacademy.com/angularpractice/') log = self.getLogger() homepage = HomePage(self.driver) # driver.find_element_by_name('name').send_keys('Rahul') # driver.find_element_by_id('exampleCheck1').click() # driver.find_element_by_css_selector('Input[name = "name"]').send_keys('Rahul') # driver.find_element_by_name('email').send_keys('Shetty') # driver.find_element_by_xpath('//input[@type="submit"]').click() log.info('first name is ' + getData['firstname']) homepage.getName().send_keys(getData['firstname']) homepage.getEmail().send_keys(getData['lastname']) homepage.getCheckBox().click() # sel = Select(homepage.getGender()) # sel.select_by_visible_text('Male') self.selectOptionByText(homepage.getGender(), getData['gender']) homepage.submitButton().click() alertText = homepage.getSuccessMSG().text assert ('success' in alertText) self.driver.refresh()
def test_formsubmission(self,getData): log = self.getlogger() homepage = HomePage(self.driver) homepage.getname().clear() homepage.getname().send_keys(getData["firstName"]) homepage.getemail().clear() homepage.getemail().send_keys(getData["email"]) homepage.getpassword().send_keys("password") homepage.getcheckbox().click() self.selectoption(homepage.getsex(),getData["gender"]) homepage.getsubmit().click() messaage = homepage.getsubmitmsg().text assert 'Success!' in messaage log.info("profile created for" +getData["firstName"])
def test_formSubmission(self, getData): log = self.getLogger() homePage = HomePage(self.driver) log.info("first name is " + getData["firstname"]) homePage.getName().send_keys(getData["firstname"]) homePage.getEmail().send_keys(getData["email"]) homePage.zgetCheckbox().click() self.selectOptionByText(homePage.getGender(), getData["gender"]) homePage.submitForm().click() alertText = homePage.getSuccessMessage().text assert ("Success" in alertText) self.driver.refresh()