def test_e2e(self): log = self.getLogger() homePage = HomePage(self.driver) CheckoutPage = homePage.shopItems() log.info("getting all the card titles") item_titles = CheckoutPage.getItemTitles() c = -1 for item_title in item_titles: c += 1 if item_title.text == 'Blackberry': CheckoutPage.getItemButtons()[c].click() CheckoutPage.getCheckoutButton().click() ConfirmPage = CheckoutPage.getCheckoutButtonFinal() log.info("Entering country name as India") ConfirmPage.getCountryField().send_keys("India") # time.sleep(10) self.verifyLinkPresence("India") ConfirmPage.getCountrySuggestion().click() ConfirmPage.getCheckBox().click() ConfirmPage.getSubmitButton().click() successText = ConfirmPage.getSuccessText().text log.info("Text received from Appliction is" + successText) assert "Success! Thank you!" in successText self.driver.get_screenshot_as_file("screen.png")
def test_e2e(self): log = self.getLogger() self.driver.implicitly_wait(10) homepage = HomePage(self.driver) checkout = homepage.shopItems() #homepage.shopItems().click() checkout.selectProduct().click() checkout.checkoutButton().click() productName = checkout.checkProdName().text total_amt = checkout.totalAmt().text print(total_amt) #log.info("Total amount is " + total_amt) log.info("product name is " + productName) checkout.successButton().click() checkout.clickCountry().click() log.info("Sending country name as Ind") checkout.clickCountry().send_keys("Ind") checkout.selectCountry().click() checkout.termsConditions().click() checkout.closeButton().click() #checkout.purchaseButton().click() confirmpage = checkout.purchaseButton() succmsg = confirmpage.successMessage().text log.info("success msg is " + succmsg) assert "Success" in succmsg assert "Blackberry" in productName finalAmt = total_amt[2:len(total_amt)] log.info("Final amount of " + productName + " is " + finalAmt) assert 0 < int(finalAmt)
def test_e2e(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) if cardText == "Blackberry": log.info("adding item to the cart") checkOutPage.getCardFooter()[i].click() checkOutPage.checkOutItems().click() confirmpage = checkOutPage.getCheckOutButton() log.info("entering country name as ind") self.driver.find_element_by_id("country").send_keys("ind") self.verifyLinkPresence("India") confirmpage.getCountryName().click() confirmpage.getCheckbox().click() confirmpage.getPurchaseButton().click() successMsg = confirmpage.getSuccessMsg().text log.info(successMsg) assert "Success! ghgg Thank you!" in successMsg self.driver.save_screenshot("test.png")
def test_home(self, getData): homepage = HomePage(self.driver) # driver.find_element_by_css_selector("input[name='name']").send_keys("Vinod Pawar") homepage.set_name().send_keys(getData["FirstName"]) # driver.find_element_by_css_selector("input[name='email']").send_keys("*****@*****.**") homepage.set_email().send_keys(getData["E-mail"]) # driver.find_element_by_css_selector("#exampleInputPassword1").send_keys("vinodpawar") homepage.set_password().send_keys(getData["LastName"]) # driver.find_element_by_css_selector("#exampleCheck1").click() homepage.set_check_boxes().click() # dropdown = Select(homepage.set_dropdown()) # dropdown.select_by_visible_text("Male") self.selectdropdown(homepage.set_dropdown(), getData["Gender"]) # driver.find_element_by_css_selector("#inlineRadio2").click() homepage.set_password().click() # driver.find_element_by_css_selector("input[name='bday']").send_keys("09091995") homepage.set_DOB().send_keys(getData["DOB"]) # driver.find_element_by_css_selector("input[value='Submit']").click() homepage.set_submit().click() # text = self.driver.find_element_by_css_selector("[class*= 'alert-success']").text text = homepage.get_text().text assert ("Success" in text) self.driver.refresh()
def test_formSubmission(self, getData): log = self.getLogger() homePage = HomePage(self.driver) #homePage.getName().send_keys(getData[0]) log.info("first name is " + getData["firstname"]) homePage.getName().send_keys(getData["firstname"]) #driver.find_element_by_css_selector("input[name='name']").send_keys("Suchithra") #driver.find_element_by_name("email").send_keys("*****@*****.**") homePage.getEmail().send_keys(getData["email"]) homePage.getPwdCheck().click() #driver.find_element_by_id("exampleCheck1").click() self.selectOptionByText(homePage.getGender(), getData["gender"]) homePage.getSubmit().click() #driver.find_element_by_xpath("//input[@type='submit']").click() # txt = driver.find_element_by_css_selector("[class*='alert-success']").text # txt = driver.find_element_by_class_name("alert-success").text #txt = driver.find_element_by_xpath("//*[contains(@class,'alert-success')]").text txt = homePage.getSuccess().text print(txt) assert "Success!" in txt self.driver.refresh()
def test_MMF(self): homepage = HomePage(self.driver) homepage.getLogin().click() homepage.GetScreen() homepage.GetUsername().send_keys("Vladimeer") homepage.GetPass().send_keys("myfact456") homepage.GetSubmit().click() checkout = Checkout(self.driver) checkout.GetSearch().send_keys("Test") checkout.GetFind().click() checkout.AddItem().click() checkout.Proceed().click() iframe = checkout.GetFrame() self.driver.switch_to.frame(iframe) checkout.DismissAds().click() self.driver.switch_to.default_content() action = ActionChains(self.driver) action.move_to_element(checkout.Perform()).perform() action.move_to_element(checkout.MyLibrary()).click().perform() confirm = Confirm(self.driver) confirm.SaveforLater().click() # time.sleep(10) wait = WebDriverWait(self.driver, 10) wait.until(expected_conditions.presence_of_element_located( (By.XPATH, "//button[@id='delete-object']"))) confirm.DeleteItem().click() alert = self.driver.switch_to.alert alert.accept()
def test_e2e(self): log = self.getLogger() homePage = HomePage(self.driver) self.driver.implicitly_wait(2) checkOutPage = homePage.getshopItems() log.info("getting all the card titles") # checkOutPage = CheckOutPage(self.driver) products = checkOutPage.getCardTitles() for product in products: ProductName = product.find_element_by_xpath("div/h4/a").text if ProductName == "Blackberry": product.find_element_by_xpath("div/button").click() checkOutPage.getCheckOutButton().click() confirmPage = checkOutPage.getFinalCheckout() log.info("Entering the location as India") confirmPage.getEnterLocation().send_keys("ind") self.verifyLinkPresence("India") confirmPage.getSelectIndia().click() # driver.find_element_by_xpath("//a[contains(text(),'India')]").click() confirmPage.getCheckBox().click() confirmPage.getPurchaseButton().click() SuccessAlertText = confirmPage.getPrintSuccessText().text log.info("Success alert text received which is " + SuccessAlertText) print(confirmPage.getPrintSuccessText().text) SuccessAlert = confirmPage.getPrintSuccessText().text assert "Your order will be" in SuccessAlert
def test_Testcases1(self, getData): log = self.get_logger() Searchbar = HomePage(self.driver) Searchbar.Enter_searchbar().send_keys(getData["Productname"]) log.info("Text entered " + getData["Productname"]) Searchbar.Click_searchbutton().click() log.info("Clicked on search button'")
def test_e2e(self): log = self.getLogger() homePage = HomePage(self.driver) checkOutPage = homePage.shopItems() log.info("getting all the card titles") cards = checkOutPage.getCardTitle() i = -1 for card in cards: i = i + 1 card_text = card.text log.info(card_text) if card_text == "Blackberry": checkOutPage.getCardFooter()[i].click() self.driver.find_element_by_css_selector( "a[class*='btn-primary']").click() confirmPage = checkOutPage.checkOutItems() log.info("Entering country name as unit") self.driver.find_element_by_id("country").send_keys("unit") # time.sleep(5) self.verifyLinkPresence("United States of America") self.driver.find_element_by_link_text( "United States of America").click() self.driver.find_element_by_xpath( "//div[@class='checkbox checkbox-primary']").click() self.driver.find_element_by_css_selector("[type='submit']").click() success_text = self.driver.find_element_by_class_name( "alert-success").text log.info("Text received from app is " + success_text) assert "Success! Thank you!" in success_text
def test_endToEnd(self, setup): 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) if cardText == "Blackberry": checkoutPage.getCardFooter()[i].click() checkoutPage.getInitialCheckOut().click() confirmPage = checkoutPage.getCheckOut() log.info("Entering to search for country name") confirmPage.getFindCountry().send_keys("united") self.verifyLinkPresence("United States of America") confirmPage.getConfirmCountry().click() confirmPage.getCheckBox().click() confirmPage.getSubmit().click() textMatch = confirmPage.getSuccessText() log.info("Screen Text received is " + textMatch) assert ("Success! Thank you!" in textMatch)
def test_e2e(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) if cardText == "Blackberry": checkOutPage.getCardFooter()[i].click() self.driver.find_element_by_css_selector( "a[class*='btn-primary']").click() confirmpage = checkOutPage.checkOutItems() log.info("Entering country name") self.driver.find_element_by_id("country").send_keys("gre") self.verifyLinkPresense("Greece") self.driver.find_element_by_link_text("Greece").click() self.driver.find_element_by_xpath( "//div[@class='checkbox checkbox-primary']").click() self.driver.find_element_by_css_selector("[value='Purchase']").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_homepage(self, get_multiple_data): homepage = HomePage(self.driver) self.driver.refresh() homepage.enter_name().send_keys(get_multiple_data[0]) homepage.enter_email().send_keys(get_multiple_data[1]) self.select_text(homepage.enter_gender(), get_multiple_data[2]) homepage.submit_button().click() assert "Success!" in homepage.get_success().text
def test_e2eTest(self): log = self.getLogger() homePage = HomePage(self.driver) #self.driver.find_element_by_css_selector("a[href*='shop']").click() #products = self.driver.find_elements_by_xpath("//div[@class='card h-100']") checkOutPage = homePage.shopItems() cards = checkOutPage.getCardTitles() #chkout = self.driver.find_element_by_css_selector("a[class*='btn-primary']").text chkout = checkOutPage.getchkBtn().text words = chkout.split(" ") count1 = int(words[2]) log.info("count1 = " + str(count1)) i = -1 for card in cards: #blkBerr = product.find_element_by_xpath("div/h4/a") i = i + 1 cardText = card.text log.info("card Text " + cardText) if (cardText) == "Blackberry": #product.find_element_by_xpath("div/button").click() checkOutPage.getcardFooter()[i].click() #chkout = self.driver.find_element_by_css_selector("a[class*='btn-primary']").text chkout = checkOutPage.getchkBtn().text words = chkout.split(" ") count2 = int(words[2]) log.info("count2 = " + str(count2)) assert (count1 + 1) == count2 #self.driver.find_element_by_css_selector("a[class*='btn-primary']").click() checkOutPage.getchkBtn().click() #self.driver.find_element_by_css_selector("button[class*='btn-success']").click() #self.driver.find_element_by_xpath("//*[contains(@class,'checkbox-primary')]").click() confirmPage = checkOutPage.CheckoutItems() log.info("entering country info") confirmPage.getText().send_keys("ind") # self.driver.find_element_by_id("country").send_keys("ind") self.verifyLinkPresence("India") confirmPage.getCountry().click() confirmPage.chkBoxAgree().click() #self.driver.find_element_by_css_selector("[type='submit']").click() confirmPage.purchase().click() # assert driver.find_element_by_xpath("//div[contains(@class,'alert-success')]").text == "Success! Thank you! Your order will be delivered in next few weeks :-)." #successText = self.driver.find_element_by_xpath("//div[contains(@class,'alert-success')]").text successText = confirmPage.message().text log.info("Text received " + successText) assert "Success! Thank you!" in successText
def test_currency_signs(self): """ Checks if all the items currency signs matches with the currency sign in the header """ home_page = HomePage(self.browser) result = home_page.check_items_currency() assert result[0] == result[1] home_page.make_dollar() home_page.search_dress()
def test_e2e(self, getData): log = self.getlogger() # Putting Objects into PageObjects package and retriving from that location homepage = HomePage(self.driver) # self.driver.find_element_by_xpath("//a[contains(text(), 'Shop')]").click() checkoutpage = homepage.shop_items() log.info(checkoutpage) # products = self.driver.find_elements_by_xpath("//div[@class = 'card h-100']") # checkoutpage = CheckOutPage(self.driver) products = checkoutpage.getCardTitles() i = -1 for product in products: i = i + 1 productname = product.text if productname == "Blackberry": checkoutpage.getCardFooter().click() # self.driver.find_element_by_xpath("//a[contains(text(), 'Checkout')]").click() checkoutpage.getcheckout().click() log.info("Checkout has been initiated") # products_in_cart = self.driver.find_elements_by_xpath("media-heading") checkoutpage.getproducts_from_cart() # assert productName == products_in_cart # self.driver.find_element_by_xpath("//button[contains(text(), 'Checkout' )]").click() confirmpage = checkoutpage.getcheckoutbutton() # confirmpage = ConfirmPage(self.driver) # self.driver.find_element_by_id("country").send_keys("ind") confirmpage.set_country_code().send_keys(getData["Country"]) log.info("Sending country as : IND") # wait = WebDriverWait(self.driver, 7) # wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, 'India'))) self.verify_presence('India') # self.driver.find_element_by_link_text("India").click() confirmpage.set_country_selection().click() # self.driver.find_element_by_xpath("//div[@class = 'checkbox checkbox-primary']").click() confirmpage.set_terms_condition().click() # self.driver.find_element_by_css_selector("input[value = 'Purchase']").click() confirmpage.set_purchasable().click() success_msg = self.driver.find_element_by_class_name("alert-success").text log.info(success_msg) assert "Success! Thank you!" in success_msg # self.driver.get_screenshot_as_file("success.png") self.screen_capture()
def test_01_search_product(self): driver = self.driver login = LoginPage(driver) login.skip_sign_in() home_page = HomePage(driver) home_page.search_item(TestData.search_item_text) home_page.select_item(Locators.item_xpath) home_page.use_pin_code() home_page.enter_pin_code(TestData.pin_code) home_page.apply_pin_code()
def test_01_login(self): driver = self.driver login = LoginPage(driver) login.enter_username(TestData.Username) login.enter_password(TestData.Password) login.click_login() time.sleep(2) home = HomePage(driver) home.click_welcome() home.click_logout()
def login_with_guest(): driver = DriverFactory.get_driver('Edge') driver.get(HomePage.get_home_url()) sleep(1) home_page = HomePage(driver) home_page.header.click_sign_in_link() sleep(1) login_page = LoginPage(driver) login_page.login('guest', 'guest') sleep(1) driver.close()
def test_homePage(self, getData): log = self.getLogger() self.driver.implicitly_wait(2) homepage = HomePage(self.driver) log.info("first name is " + getData["FirstName"]) homepage.getName().send_keys(getData["FirstName"]) homepage.getEmail().send_keys(getData["LastName"]) homepage.getPassword().send_keys("Test@123") homepage.getCheckbox().click() self.SelectGender(homepage.getGender(), getData["Gender"]) homepage.getSubmitButton().click() self.driver.refresh()
def test_cwd_starts(self,data_provider): homepageobj = HomePage(self.driver) homepageobj.get_name().send_keys(data_provider["name"]) homepageobj.get_email().send_keys(data_provider["email"]) homepageobj.get_password().send_keys("xxxxxx") self.selectoption_By_visible_text(homepageobj.get_gender(), data_provider["Gender"]) homepageobj.get_status().click() homepageobj.get_bday().send_keys("30/11/1989") homepageobj.get_submit().click() alert_msg = homepageobj.get_success_message().text assert ("Success" in alert_msg) self.driver.get_screenshot_as_file("result.png")
def addContact(driver, contactPersonName, contactPersonMail, isStarContact, contactPersonPhone, contactPersonComment): hp = HomePage(driver) hp.homePageObj().click() ac = AddContactPage(driver) ac.addContactBtn().click() ac.contactPersonName().send_keys(contactPersonName) ac.contactPersonMail().send_keys(contactPersonMail) if isStarContact == "是": ac.starContact().click() ac.contactPersonPhone().send_keys(contactPersonPhone) ac.contactPersonComment().send_keys(contactPersonComment) ac.saveContactPeron().click()
def test_formSubmission(self, getData): homepage = HomePage(self.driver) homepage.getNameField().send_keys(getData["firstname"]) homepage.getEmailField().send_keys(getData["email"]) homepage.getCheckMe().click() self.selectOptionByText(homepage.getGender(), getData["gender"]) homepage.getSubmitButton().click() alertText = homepage.displaySuccessMessage() assert "Success" in alertText self.driver.refresh()
def test_02_currency(self): self.logger = self.get_logger() self.logger.info('******** test_02_currency*****') self.logger.info('******** verifying default currency*****') self.home_page = HomePage(self.driver) default_currency = self.home_page.get_default_currency() print(default_currency) if default_currency == 'US Dollar': self.logger.info('***************verifying default currency successful*******') assert True else: self.logger.error('***********verifying default currency failed *************') self.driver.save_screenshot('../Reports/test_defaultCurrency.png') assert False
def test_formSubmission(self, getData): homePage = HomePage(self.driver) log.info("Full Name : " + getData["fullname"]) homePage.getName().send_keys(getData["fullname"]) homePage.getEmail().send_keys(getData["email"]) homePage.getExampleCheck().click() self.selectOptionsByText(homePage.getGender(), getData["gender"]) homePage.submitForm().click() alertText = homePage.getSuccess().text assert ("Success" in alertText) self.driver.refresh()
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.getLastName().send_keys(getData["lastname"]) homepage.getCheckBox().click() self.selectOptionBYText(homepage.getGender(), getData["gender"]) homepage.submitForm().click() alertText = homepage.getSuccesMessage().text assert ("Success" in alertText) self.driver.refresh()
def admin_members(): driver = DriverFactory.get_driver('Edge') driver.get(HomePage.get_home_url()) sleep(1) home_page = HomePage(driver) home_page.header.click_admin_link() sleep(1) login_page = LoginPage(driver) login_page.login('admin', 'admin') sleep(1) admin_page = AdminPage(driver) admin_page.click_on_members_link() sleep(2) driver.close()
def test_e2e(self): homepage = HomePage(self.driver) checkout_page = homepage.shop_items( ) # Smart way of optimizing as this will return an object of CheckoutPage Class products = checkout_page.get_product_titles() confirmpage = ConfirmPage(self.driver) for product in products: name = product.find_element_by_xpath("div/div/h4/a").text print(name) if name == "iphone X": product.find_element_by_xpath("div/div/button").click() # Clicking Checkout button checkout_page.checkout().click() selected_product = confirmpage.select_product().text assert selected_product == "iphone X" confirmpage.success().click() confirmpage.country().send_keys("ind") wait = WebDriverWait(self.driver, 7) wait.until( expected_conditions.presence_of_element_located( (By.LINK_TEXT, "India"))) self.driver.find_element_by_link_text("India").click() checkbox = self.driver.find_element_by_xpath( "//div[@class='checkbox checkbox-primary']") checkbox.click() # assert checkbox.is_selected() self.driver.find_element_by_xpath("//input[@value='Purchase']").click() var = self.driver.find_element_by_class_name("alert-success") end_text = var.text print(end_text) assert "Success" in end_text self.driver.save_screenshot("screen.png")
def test_01_page_title(self): self.logger = self.get_logger() self.logger.info('*************** TestHomePage *******') self.logger.info('*************** test_01_page_title *******') self.logger.info('*************** verifying page title ***********') self.home_page = HomePage(self.driver) actual_title = self.home_page.get_title(TestData.PAGE_TITLE) print(actual_title) if actual_title == 'nopCommerce demo store': self.logger.info('**********title verified successfully ********') assert True else: self.logger.error('******verifying title failed *********') self.driver.save_screenshot('../Reports/test_homePageTitle.png') assert False
def test_cwd_starts(self, setup): log = self.get_logger() homepageobj = HomePage(self.driver) log.info("homepageobj created") confirmPageObj = None checkOutPageObj = homepageobj.shop_element() log.info("checkOutPageObj created") products = checkOutPageObj.get_product_elements() log.info(products) for product in products: if product.find_element_by_xpath( checkOutPageObj.get_product_name()).text == "Blackberry": product.find_element_by_xpath( checkOutPageObj.Button_name).click() log.info("Blackberry selected") break checkOutPageObj.get_checkout_button().click() log.info("checkout clicked") checked_out_products = checkOutPageObj.get_products_final() for checked_out_product in checked_out_products: assert (checked_out_product.text == "Blackberry") confirmPageObj = checkOutPageObj.get_final_checkout_button() break confirmPageObj.get_country_textbox().send_keys("ind") self.wait_until_link_text("India") log.info("india selected") confirmPageObj.get_confirm_checkbox().click() log.info("checkbox clicked") confirmPageObj.get_purchase_button().click() text_message = self.driver.find_element_by_class_name( "alert-success").text log.info(text_message) assert ("Success" in text_message) log.info("assert passed") self.driver.get_screenshot_as_file("result.png") log.info("screen shot created")
def add_book(): driver = DriverFactory.get_driver('Edge') driver.get('http://10.1.23.10/bookstore') sleep(1) home_page = HomePage(driver) home_page.click_on_admin_link() sleep(1) login_page = LoginPage(driver) login_page.login('admin', 'admin') sleep(1) admin_page = AdminPage(driver) admin_page.click_on_books_link() sleep(1) books_page = BooksPage(driver) books_page.click_on_add_new() sleep(2) driver.close()