class Application: def __init__(self): import os self.driver = webdriver.Chrome(os.path.join(os.path.dirname(os.path.realpath(__file__)), "chromedriver.exe")) self.landing_page = LandingPage(self.driver) self.search_results_page = SearchResultsPage(self.driver) def quit(self): self.driver.quit() def search_toster(self): self.landing_page.open() assert self.landing_page.logo.is_displayed() try: self.landing_page.accept_terms.click() except TimeoutError: pass self.landing_page.search_box.send_keys("toster") self.landing_page.button_search.click() assert self.search_results_page.searching_phrase_label.text.lower().__contains__("toster") articles = self.search_results_page.articles for article in articles: article_title = article.text.lower() assert article_title.__contains__("toster"), f"Article '{article_title}' does not contain word 'toster'"
def step_impl(context): context.driver = make_browser() context.driver.get( "https://www.cpap.com/cpap-machines/travel-sized-cpap-machine") context.driver.implicitly_wait(10) context.driver.maximize_window() landingpage = LandingPage(context.driver) landingpage.go_to_shopping_cart()
def setUp(self): self.driver = webdriver.Chrome('chromedriver') self.driver.maximize_window() self.driver.get('http://www.ck12.org') time.sleep(2) # Signin button self.landingpage = LandingPage(self.driver) signin_modal = self.landingpage.signInWindow(self.driver) signin_modal.signInAction( "*****@*****.**", "Shopana@123") time.sleep(4)
def test_addtocart(self): driver = self.driver driver.get("http://demo.automationtesting.in/") titleoflandingPage = driver.title print(titleoflandingPage) land = LandingPage(driver) land.skipsignin() registerpage = driver.title print(registerpage) self.assertNotEqual(titleoflandingPage,registerpage,"page didnt change") time.sleep(5) practice = RegistrationPage(driver) practice.click_practicetest() time.sleep(5) practicesite =driver.title print(practicesite) self.assertEqual("Automation Practice Site",practicesite,"Both title matches") x= Homepage(driver) x.select_seleniumruby() y =Productpage(driver) y.click_add() driver.get_screenshot_as_file("/Users/sumit/Desktop/CACC Barsha/DemoautomationtestingRegistration/screenshots/addtocart.png") c =Productpage(driver) c.click_cart() co =CheckoutPage(driver) co.click_checkout() b =BillingPage(driver) b.enter_firstname("Brish") b.enter_lastname("Cool") b.enter_Email("*****@*****.**") b.enter_phoneno("6758972345") b.enter_country("Canada") b.enter_streetname("167 luella cres") b.enter_townname("Brampton") b.select_province("Ontario") #driver.find_element_by_xpath("//span[@id='select2-chosen-2']").click() b.enter_postalcode("l7a3h9") b.select_casondelivery() time.sleep(5) b.place_order() time.sleep(10) driver.get_screenshot_as_file("/Users/sumit/Desktop/CACC Barsha/DemoautomationtestingRegistration/screenshots/Orderplaced.png")
def test_register(self): driver = self.driver driver.get("http://demo.automationtesting.in/") titleoflandingPage = driver.title print(titleoflandingPage) land = LandingPage(driver) land.enter_email("*****@*****.**") land.enter() time.sleep(10) register = RegistrationPage(driver) register.enter_firstname("Barsha") register.enter_lasttname("Mishra") register.enter_address("135 Luella cres, Brampton") register.enter_emailaddress("*****@*****.**") register.enter_phonenumber("6472893375") register.select_gender() register.select_hobby() register.select_country() register.select_year() register.select_month() register.select_day() register.enter_password("Abcd1234") register.enter_second_password("Abcd1234") register.enter_submit() time.sleep(3) driver.get_screenshot_as_file("/Users/sumit/Desktop/CACC Barsha/DemoautomationtestingRegistration/screenshots/regisgister.png")
def test_register(self): driver = self.driver driver.get("http://demo.automationtesting.in/") titleoflandingPage = driver.title print(titleoflandingPage) land = LandingPage(driver) land.enter_email("*****@*****.**") land.enter() time.sleep(10) register = RegistrationPage(driver) register.enter_firstname("Barsha") register.enter_lasttname("Mishra") register.enter_address("135 Luella cres, Brampton") register.enter_emailaddress("*****@*****.**") register.enter_phonenumber("6472893375") register.select_gender() register.select_hobby() #register.click_language() #driver.find_element_by_xpath("//div[@id='msdd']").click() #time.sleep(10) #driver.find_element_by_xpath("//a[contains(text(),'English')]").click() #register.click_language() #driver.find_element_by_xpath("//div[@class='container center']//div[contains(@class,'row')]").click() #register.click_skills() register.select_country() register.select_year() register.select_month() register.select_day() register.enter_password("Abcd1234") register.enter_second_password("Abcd1234") register.enter_submit() time.sleep(3) driver.get_screenshot_as_file( "/Users/sumit/Desktop/CACC Barsha/DemoautomationtestingRegistration/screenshots/regisgister.png" )
class TestFlexBook1Assert(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome('chromedriver') self.driver.maximize_window() self.driver.get('http://www.ck12.org') time.sleep(2) # Signin button self.landingpage = LandingPage(self.driver) signin_modal = self.landingpage.signInWindow(self.driver) signin_modal.signInAction( "*****@*****.**", "Shopana@123") time.sleep(4) def test_user_name(self): driver = self.driver # check for user name in home page find_user_name = driver.find_element_by_xpath( "//span[@class='sc-csuQGl hrnDev']") print(find_user_name.text) assert "SHOPANA" in find_user_name.text def test_pageText(self): self.driver.get("https://www.ck12.org/fbbrowse/") text_present = FlexPage(self.driver) actual_txt = text_present.check_text() expected_txt = FlexbookPageLocators.TEXT_AVAILABLE for each in actual_txt: self.assertIn(each, expected_txt) def test_optionText(self): self.driver.get("https://www.ck12.org/fbbrowse/") text_present = FlexPage(self.driver) actual_txt = text_present.check_textInOptions() expected_txt = FlexbookPageLocators.OPTIONS_TXT for each in actual_txt: self.assertIn(each, expected_txt) def test_image(self): self.driver.get("https://www.ck12.org/fbbrowse/") image_present = FlexPage(self.driver) actual_img_src = image_present.check_image() expected_img_src = FlexbookPageLocators.IMAGE_SRC for each in actual_img_src: self.assertIn(each, expected_img_src) def test_flexbook_page(self): # Selecting flexbook from explore explore = BasePage(self.driver) explore.selectItem(FlexbookPageLocators.FB_EXPLORE_MENU, FlexbookPageLocators.FB_FLEXBOOK_OPTION) title = explore.el_get_title("FlexBooks® | CK-12 Foundation") print(title) @parameterized.expand([ ("English", "Algebra", "Middle School", "Algebra Flexbooks® for Middle School in English | CK-12 Foundation"), ("English", "Math", "Middle School", "Math Flexbooks® for Middle School in English | CK-12 Foundation"), ("English", "Arithmetic", "Middle School", "Arithmetic Flexbooks® for Middle School in English | CK-12 Foundation"), ("English", "Algebra", "High School", "Algebra Flexbooks® for High School in English | CK-12 Foundation") ]) def test_flexbook_selectOptions(self, lang, sub, grade, title): # Selecting the dropdown - Language, Subject, Grade and check for the items are present in Title self.driver.get( "https://www.ck12.org/fbbrowse/") fbselect = FlexPage(self.driver) words = fbselect.selectOptions(lang, sub, grade) newTitle = fbselect.el_get_title(title) print(newTitle) items = [lang, sub, grade] for i in items: self.assertIn(i, newTitle, msg="I am not true") def test_fb_select(self): # #choose 8th grade Algebra from the flexbooks self.driver.get( "https://www.ck12.org/fbbrowse/list/?Subject=Algebra&Language=English&Grade=Middle%20School") book = FbBrowseListPage(self.driver) assert book.checkMatch() def test_customizeBookTitle(self): # Change the tiltle of the flexbook self.driver.get( "https://www.ck12.org/book/CK-12-Middle-School-Math-Concepts-Grade-8/") custom = CustomizePage(self.driver) assert custom.checkTitle("Sho:Algebra") assert custom.checkCreator("SHOPANA") def test_customizeChapterTitle(self): self.driver.get( "https://www.ck12.org/editor/book/CK-12-Algebra-Basic/r32/") custom = CustomizePage(self.driver) assert custom.customChapTitle("Sho:Real Number Properties") def test_chapDragDrop(self): self.driver.get( "https://www.ck12.org/editor/book/CK-12-Algebra-Basic/r32/") dragDrop = CustomizePage(self.driver) assert dragDrop.checkDragDrop() def test_addNewChap(self): self.driver.get( "https://www.ck12.org/editor/book/CK-12-Algebra-Basic/r32/") addNew = CustomizePage(self.driver) assert addNew.addChapter("New Chapter of Algebra") def test_deleteChap1(self): self.driver.get( "https://www.ck12.org/editor/book/CK-12-Algebra-Basic/r32/") deleteChap = CustomizePage(self.driver) assert deleteChap.removeChapter() def test_toggleExpand(self): self.driver.get( "https://www.ck12.org/editor/book/CK-12-Algebra-Basic/r32/") time.sleep(3) expand = CustomizePage(self.driver) expand.expandToggle() print("Expanded the section") def test_readDragDrop(self): self.driver.get( "https://www.ck12.org/editor/book/CK-12-Algebra-Basic/r32/") time.sleep(3) dragdrop = CustomizePage(self.driver) assert dragdrop.checkReadDragDrop() def test_addNewRead(self): self.driver.get( "https://www.ck12.org/editor/book/CK-12-Algebra-Basic/r32/") time.sleep(3) newRead = CustomizePage(self.driver) assert newRead.addRead("Real Numbers problems") def test_removeRead(self): self.driver.get( "https://www.ck12.org/editor/book/CK-12-Algebra-Basic/r32/") time.sleep(3) newRead = CustomizePage(self.driver) assert newRead.removeRead() def test_renameRead(self): self.driver.get( "https://www.ck12.org/editor/book/CK-12-Algebra-Basic/r32/") time.sleep(3) renameRead = CustomizePage(self.driver) assert renameRead.renameRead("Sho:Variable Expressions") def test_move_read_diff_chap(self): self.driver.get( "https://www.ck12.org/editor/book/CK-12-Algebra-Basic/r32/") time.sleep(3) mv_read = CustomizePage(self.driver) assert mv_read.move_read_diff_chap() def test_moveTo_dropDown_1to5(self): self.driver.get( "https://www.ck12.org/editor/book/CK-12-Algebra-Basic/r32/") time.sleep(3) mv_read = CustomizePage(self.driver) assert mv_read.move_to_dropDown() def tearDown(self): self.driver.quit()
def __init__(self): import os self.driver = webdriver.Chrome(os.path.join(os.path.dirname(os.path.realpath(__file__)), "chromedriver.exe")) self.landing_page = LandingPage(self.driver) self.search_results_page = SearchResultsPage(self.driver)