def test_login(self): # Login with invalid email and validating the browser title hasnt changed main_page = page.MainPage(self.driver) assert main_page.is_title_matches( "indee."), "indee. title doesn't match." main_page.click_login_button() main_page.search_text_element_username = "******" main_page.search_text_element_password = "******" main_page.click_login() assert main_page.is_title_matches( "Login | Indee"), "Login | Indee title doesnt match" text = main_page.get_Error_Message assert text == "Enter a valid email." # Login with incorrect password and validating the browser title hasnt changed main_page = page.MainPage(self.driver) assert main_page.is_title_matches( "Login | Indee"), "Login | Indee title doesn't match." main_page.search_text_element_username = "******" main_page.search_text_element_password = "******" main_page.click_login() assert main_page.is_title_matches( "Login | Indee"), "Login | Indee title doesnt match" # Login with correct credentials and validating the projects page is displayed main_page.search_text_element_username = "******" main_page.search_text_element_password = "******" main_page.click_login() time.sleep(5) assert main_page.is_title_matches( "Projects | Indee"), "Projects | Indee title doesnt match" text = main_page.get_pageTitle_Text assert text == "Projects"
def main(driver): driver.get('https://www.aliexpress.com/') page.AnyPage(driver).do_escape() page.AnyPage(driver).go_to_globalsite() time.sleep(2) page.MainPage(driver).click_login() time.sleep(2) login_page = page.LoginPage(driver) login_page.goto_login_iframe() login_page.enter_credits_and_login(env('ALI_USER'), env('ALI_PASS')) time.sleep(3) page.AnyPage(driver).do_escape() mainpage = page.MainPage(driver) mainpage.click_change_ship_curency() mainpage.search('Boys Bicycle') time.sleep(3) search_results = page.SearchResults(driver) search_results.click_first() search_results.switch_tab(1) time.sleep(1) driver.save_screenshot('test.png') time.sleep(10) driver.quit()
def test_login(self): mainPage = page.MainPage(self.driver) self.driver.implicitly_wait(5) mainPage.click_signin() self.driver.implicitly_wait(5) signInPage = page.SignInPage(self.driver) signInPage.email_text_element = loginInfo.email signInPage.click_continue_button() self.driver.implicitly_wait(5) signInPage.password_text_element = loginInfo.password signInPage.click_signin_button() main_Page = page.MainPage(self.driver) self.driver.implicitly_wait(5) self.assertTrue(main_Page.is_title_matches_MainPage())
def test_select_2(self, open_page): """ Tests select Option 2. This test verifies that the User can select Option 2. """ # Load the main page. # In this case the home page of the-internet.herokuapp.com main_page = page.MainPage(self.browser) # Checks if the word "The Internet" is in title assert main_page.is_title_matches(), \ "the-internet.herokuapp.com title doesn't match." # open page 'Dropdown List' main_page.click_by_link_dropdown() wait = WebDriverWait(self.browser, 15) wait.until(lambda _: not main_page.is_main_page()) # Verifies that page is correct dropdown_page = page.DropdownPage(self.browser) assert dropdown_page.is_dropdow_page(), "It's not Dropdown page." # Select 2 options dropdown_page.choose_option2() assert not dropdown_page.is_option_active( 'Option 1'), 'Option 1 is select' assert dropdown_page.is_option_active('Option 2'), \ 'Option 2 is not select'
def test_login_in_google_window(self): self.driver.implicitly_wait(15) winHandleBefore = self.driver.current_window_handle main = page.MainPage(self.driver) main.click_button() main.click_button() wait = WebDriverWait(self.driver, 10) wait.until(EC.number_of_windows_to_be(2)) for handle in self.driver.window_handles: self.driver.switch_to.window(handle) google = page.GooglePage(self.driver) login = self.driver.find_element_by_id("identifierId") login.send_keys("*****@*****.**") google.click_next() password = self.driver.find_element_by_name("password") password.send_keys("Nwta1234!") google.click_next2() wait = WebDriverWait(self.driver, 10) wait.until(EC.number_of_windows_to_be(1)) self.driver.switch_to.window(winHandleBefore) main.click_button() assert "Log out" not in self.driver.page_source
def test_search_python(self): mainPage = page.MainPage(self.driver) assert mainPage.is_title_matches() mainPage.search_text_element = "pycon" mainPage.click_go_button() search_result_page = page.SearchResultPage(self.driver) assert search_result_page.is_result_found()
def test_add_new_record_and_delete_it(self): self.test_login_page() # login to addressbook add_new_lnk = page.PageNavi(self.driver) add_new_lnk.add_lnk() #click on add new link page_add_new = page.AddNew(self.driver) # filling Address on second page on Add new page addr = random_test_data.random_letters(5) page_add_new.fill_address(addr) self.assertIn(addr, addr) # fill the address field page_add_new.click_next # navigate to next page # Filling user data page_add_new.fill_user_name(self.f_name, self.m_name, self.l_name) self.assertIs(self.f_name, self.f_name) or self.assertIs( self.m_name, self.m_name) or self.assertIs(self.l_name, self.l_name) page_add_new.set_email(self.e_mail) self.assertIs(self.e_mail, self.e_mail) page_add_new.set_phone('+' + self.phone_number) self.assertIs(self.phone_number, self.phone_number) page_add_new.click_enter() self.driver.implicitly_wait(10) # Search on the main page main_page = page.MainPage(self.driver) main_page.search_element(self.phone_number) self.assertIs(self.phone_number, self.phone_number) self.driver.implicitly_wait(10) main_page.select_element() main_page.delete_bttn() main_page.accept_alert()
def uitvoering_start(self): ''' Check of schip KTV-KAT03 in de aanbodlijst staat van de brug (rechts) Klik op het plusje op een nieuwe brugplanning aan te maken Klik op schip KTV-KAT03 en sleep dit schip naar de brugplanning (rechterhelft) Ga naar ingedeeld (zelfde kant als schip is ingedeeld in de brugplanning (rechts) Check: schip staat in de lijst ingedeeld Klik op aanbod (rechterkant) Check: schip staat niet meer op de aanbodslijst Check: schip staat in de brugplanning Druk op het witte rondje om het stoplicht op groen te zetten Druk op het witte rondje om het stoplicht op rood te zetten Selecteer 'ja'om de brugplaning te realiseren Check: Schip staat weer in de aanbodlijst (rechts) Check: Brugplanning is verdwenen Klik op (naam account bv Bert Pril ) Selecteer uitloggen ''' data_specifiek = self.config['INITdata_BP_UI_01'] boot = data_specifiek['test_boot'] eni_nummer = data_specifiek['eni_nummer'] ivs_page = uitvoering_UI_BP_1.uitvoering_UI_BP_1(self.driver) ivs_page.new_brugplanning(boot, eni_nummer) ivs_page.sleur_en_pleur(boot, eni_nummer) ivs_page.check(boot, eni_nummer) ivs_page.uitvoeren_brugplanning(boot, eni_nummer) main_page = page.MainPage(self.driver) main_page.logout()
def test_register_user(self): driver = self.driver driver.get('http://39.107.96.138:3000/signup') #实例化一个Mainpage对象 main_page = page.MainPage(self.driver) username = "******" pwd = '123456' email = '*****@*****.**' #输入注册用户名 main_page.input_register_name(username) #输入密码 main_page.input_password(pwd) #输入确认密码 main_page.input_repass_name(pwd) #输入邮箱 main_page.input_email(email) #点击注册按钮 main_page.click_register_button() #验证页面是否显示"欢迎加入 Nodeclub!我们已给您的注册邮箱发送了一封邮件,请点击里面的链接来激活您的帐号" search_results_page = page.SearchResultsPage(self.driver) text = '我们已给您的注册邮箱发送了一封邮件' #Verifies that the results page is not empty assert search_results_page.is_results_found(text), "No results found." self.driver.delete_all_cookies()
def test_search_in_python_org(self): """ Tests the ability to login to Dexcom Home page from https://clarity.dexcom.com """ print("Title: ", self.driver.title) # Define the main page and login page from Dexcom.com. main_page = page.MainPage(self.driver) login_page = page.LoginPage(self.driver) time.sleep(1) # Checks if the word "Dexcom" is in title assert main_page.is_title_matches(), "Dexcom title doesn't match." # Choos the button to login to Home page main_page.click_home_button() time.sleep(1) # Enter the provided Username and Password login_page.enter_username(config_username) login_page.enter_password(config_password) login_page.click_submit() time.sleep(1) #Verifies that the results page is not empty search_results_page = page.SearchResultsPage(self.driver) assert search_results_page.is_results_found(), "No results found."
def test_Register(self): #open Category Page main_page = page.MainPage(self.driver) assert main_page.is_title_matches(), "eyerim title doesn't match." main_page.chooseCategory() #open Product Page category_page = page.CategoryPage(self.driver) category_page.chooseProduct() #add to cart product_page = page.ProductPage(self.driver) product_page.addProductTocart() #go to checkout cart_page = page.Cart(self.driver) cart_page.goToCheckout() #go to payment method addressStep_page = page.AddressStep(self.driver) addressStep_page.fillForm() #go to summary paymentStep_page = page.PaymentStep(self.driver) paymentStep_page.goToSummary() #finalize order summary_page = page.SummaryStep(self.driver) summary_page.finalizeOrder() self.test_result = 'pass' self.driver.quit()
def tests(self): """ - Recherche article Renard - Recherche lien coussin - Click sur le lien article - Affichage du détail de l'article - Ajout au panier avec une quantité de 2 - Affiche du panier """ main_page = page.MainPage(self.driver) WebDriverWait(self.driver, 20).until(expected_conditions.title_contains('DFTG')) assert main_page.is_title_matches(), "Title DFTG not found ..." main_page.search_text_element = "renard" main_page.click_search() WebDriverWait(self.driver, 20).until( expected_conditions.title_contains('Rechercher')) main_page.link_article() WebDriverWait(self.driver, 20).until(expected_conditions.title_contains('Coussin')) main_page.put_art_qty() main_page.add_to_cart() main_page.get( 'http://192.168.34.30:8002/prestashop/fr/panier?action=show') WebDriverWait(self.driver, 20).until(expected_conditions.title_contains('Panier')) assert main_page.check_article_cart(), "Article name not match ..." assert main_page.check_article_qty_cart( ), "Article quantity not match ..."
def test_show_price(self): # load main and result page main_page = page.MainPage(self.driver) results_page = page.ResultPage(self.driver) # choose first city from the menu below main_page.chose_city() # checking the opening of the hotel listing page assert results_page.is_hotels_open(), 'No hotels found.' # check opening calendar assert results_page.is_calendar_open(), 'Calendar is not opened.' # check on the contain of the reservation price or reservation status assert results_page.check_status(), 'Page contains the reservation price or reservation status.' # Click "show prices" button for first hotel main_page.click_show_price() # check opening calendar assert results_page.is_calendar_open(), 'Calendar is not opened.' # set dates in main_page.set_check_in() # Submit search form main_page.search() # checking result assert (not results_page.check_status()), 'Page contains the reservation price or reservation status.'
def test_1_order(self): mainPage = page.MainPage(self.driver) assert mainPage.is_title_matches() mainPage.click_article1() articlePage = page.ArticlePage(self.driver) articlePage.click_cart_button() shoppingCartPage = page.ShoppingCartPage(self.driver) shoppingCartPage.click_checkout_button() checkoutPage = page.CheckoutPage(self.driver) checkoutPage.phone_element = '040123321' checkoutPage.first_name_Element = 'Janez' checkoutPage.last_name_Element = 'Vajkard Valvasor' time.sleep(2) checkoutPage.click_placeorder_button() time.sleep(2) assert checkoutPage.is_error_found() checkoutPage.email_element = '*****@*****.**' checkoutPage.address_element = 'Slavčeva 5' checkoutPage.post_code_element = '4000' time.sleep(3) checkoutPage.click_placeorder_button() orderCompletePage = page.OrderCompletePage(self.driver) assert orderCompletePage.is_order_complete() time.sleep(3)
def test_login_UI(self): # Test the login UI login_page = page.MainPage(self.driver) login_page.click_link(self) assert login_page.page_title_displayed() assert login_page.username_field_displayed() assert login_page.password_field_displayed() assert login_page.login_button_displayed()
def test_weightwatchers(self): main_page = page.MainPage(self.driver) #2. Verify loaded page title matches “WW (Weight Watchers): Weight Loss & Wellness Help” assert main_page.title_matches( ), "Weight Loss & Wellness Help, does not match" #3. On the right corner of the page, click on “Find a Studio” main_page.click_find_workshop() #4. Verify loaded page title contains “Find WW Studios & Meetings Near You | WW USA” searchworkshoppage = page.SearchWorkshopPage(self.driver) assert searchworkshoppage.title_matches, "Find WW Studios & Meetings Near You | WW USA" self.driver.implicitly_wait(3) #5. In the search field, search for meetings for zip code: 10011 searchworkshoppage.type_seach_term("10001") searchworkshoppage.click_on_search() # 6. Print the title of the first result and the distance (located on the right of location title/name) search_results_page = page.SearchResultsPage(self.driver) #7. Click on the first search result and then, verify displayed location name/title matches with the name of the first searched result that was clicked. location_on_search_result = search_results_page.return_location_name() search_results_page.click_on_first_location() location_details_page = page.LocationDetailsPage(self.driver) location_details_locationname = location_details_page.assert_location_is_same( ) assert (location_on_search_result == location_details_locationname) # 8. From this location page, print TODAY’s hours of operation (located towards the bottom of the page) - This is missing in page right now #9. Create a method to print the number of meeting the each person(under the scheduled time) has a particular day of the week print("test") day = raw_input("Enter the Day: Mon Tue Wed Thur Fri Sat Sun ") location_details_page.printmeetings(day)
def test_search_in_python_org(self): main_page = page.MainPage(self.driver) assert main_page.is_title_matches(), "python.org title doesn;t match." main_page.search_text_element = "pycon" main_page.click_go_button() search_results_page = page.SearchResultsPage(self.driver) assert search_results_page.is_results_cound(), "No results found."
def test3_search_stupid(self): mainPage = page.MainPage(self.driver) mainPage.search_text_element = '$%^&*(()_&*(' mainPage.click_search_button() time.sleep(2) search_result_page = page.SearchResultPage(self.driver) assert search_result_page.no_results_found()
def test_title(self): main_page = page.MainPage(self.driver) assert main_page.is_title_matches() main_page.search_text_element = 'pycon' main_page.click_go_button() search_result_page = page.SearchResultsPage(self.driver) assert search_result_page.is_results_found()
def test5_testimonialsPage(self): NAME = "Johnny Bravo" DESC = "Johnny Bravo tranformation" FILE_PATH = r"C:\Users\jania\Desktop\Repositories\B2A_Selenium\johnny.PNG" main_page = page.MainPage(self.driver) assert main_page.mainPageCheck(), "Main Page title did not match" main_page.panel_goto_testimonials_button.click() test_page = page.TestimonialsPage(self.driver) assert test_page.testimonialsPageCheck( ), "Testimonials page did not match" test_page.add_test.click() test_page.input_name = NAME test_page.input_desc = DESC test_page.input_file = FILE_PATH test_page.test_submit_button.click() assert NAME in test_page.get_column_data( test_page.rowgroup, 2)[0], "User testimonial was not created properly" assert DESC in test_page.get_column_data( test_page.rowgroup, 3)[0], "User description was not set properly" test_page.test_delete_button.click() assert NAME not in test_page.get_column_data( test_page.rowgroup, 2)[0], "User testimonial was not deleted properly"
def voorbereiding_start(self): ''' Ga naar de 'Sas van Gent brug' Zoek het schip KTV-KAT03 op in de zoekfunctie Selecteer het schip Check of de status op actueel staat Wanneer status op beeindigd staat, zet de status op actueel en klik op publiceer reis Klik op het icoon (potloodje) om huidige positie te wijzigen Selecteer afvarend Selecteer publiceer positie Klik op het kruisje om de vaartuig detailbrowser af te sluiten Druk op refresh rechtsonder in beeld (GUI) ''' main_page = page.MainPage(self.driver) data_algemeen = self.config['INITdata_algemeen'] data_specifiek = self.config['INITdata_BP_UI_01'] username = data_algemeen['loginnaam'] password = data_algemeen['password'] main_page.login(username, password) ivs_page = voorbereiding_UI_BP_1.IVSPage(self.driver) brug = data_specifiek['object'] ivs_page.navigate(brug) boot = data_specifiek['test_boot'] eni_nummer = data_specifiek['eni_nummer'] vaarrichting = data_specifiek['vaarrichting'] ivs_page.voorbereiding_brugplanning(boot, eni_nummer, vaarrichting)
def dis_test2_ClientsSearchBarVerification(self): USER = '******' EMAIL = '*****@*****.**' ACTIVE_STATUS = 'Active' INACTIVE_STATUS = 'Inactive' GYM = 'Frankfield' main_page = page.MainPage(self.driver) assert main_page.mainPageCheck(), "Main Page title did not match" main_page.searchbar_name = USER assert USER in main_page.get_column_data( main_page.rowgroup, 2)[0], "User did not match with searched user" assert EMAIL.upper() in main_page.get_column_data( main_page.rowgroup, 3)[0].upper(), "Email did not match with searched user" assert ACTIVE_STATUS in main_page.get_column_data( main_page.rowgroup, 8)[0], "Email did not match with searched user" main_page.clear_searchbar_button.click() main_page.searchbar_status = INACTIVE_STATUS active_column = main_page.get_column_data(main_page.rowgroup, 8) assert all(element == INACTIVE_STATUS for element in active_column), "Search did not filter status properly" main_page.clear_searchbar_button.click() main_page.searchbar_gym = GYM gym_column = main_page.get_column_data(main_page.rowgroup, 5) assert all( element == GYM for element in gym_column), "Search did not filter gym properly"
def test_video_list(self): mainPage = page.MainPage(self.driver) assert mainPage.is_title_match() mainPage.search_text = "nct 127" mainPage.click_search_btn() searchResultPage = page.SearchResultsPage(self.driver) assert searchResultPage.is_video_found()
def test_login(self): """ 登录操作,验证url及用户名出现 """ #打开登录网页 self.driver.get("http://39.107.96.138:3000/signin") #Load the main page. In this case the home page of cnode. #实例化一个Mainpage对象 main_page = page.MainPage(self.driver) username = "******" pwd = '123456' #输入用户名 main_page.input_username(username) #输入密码 main_page.input_password(pwd) #点击登录按钮 main_page.click_login_button() #Checks if the word "Node" is in title assert main_page.is_title_matches(), "cNode title doesn't match." #验证页面是否显示username search_results_page = page.SearchResultsPage(self.driver) #Verifies that the results page is not empty assert search_results_page.is_results_found( username), "No results found."
def dis_test1_AddUser(self): main_page = page.MainPage(self.driver) assert main_page.mainPageCheck(), "Main Page title did not match" USER = '******' EMAIL = '*****@*****.**' PHONE = '445676777' GYM = 'Frankfield' CALORIES = '2300' ''' main_page.add_client_button.click() main_page.active_button.click() main_page.add_user_name = user main_page.add_user_email = email main_page.add_user_phone = phone main_page.add_user_gym = gym main_page.add_user_calories = calories main_page.submit_button.click() ''' assert USER in main_page.get_column_data( main_page.rowgroup, 2)[0], "User Name was not set properly" assert EMAIL.upper() in main_page.get_column_data( main_page.rowgroup, 3)[0].upper(), "User Email was not set properly" assert PHONE in main_page.get_column_data( main_page.rowgroup, 4)[0], "User Phone was not set properly" assert GYM in main_page.get_column_data( main_page.rowgroup, 5)[0], "User Gym was not set properly" assert "Active" in main_page.get_column_data( main_page.rowgroup, 8)[0], "User status was not set properly"
def test_search_in_rozetka(self): """ Tests rozetka search feature. Searches for the word "----" then verified that some results show up. Note that it does not look for any particular text in search results page. This test verifies that the results were not empty. """ #Load the main page. In this case the home page of Python.org. main_page = page.MainPage(self.driver) #Checks if the word "rozetka" is in title assert main_page.is_title_matches(), "rozetka,com.ua title doesn't match." #Sets the text of search textbox to "----" main_page.search_text_element = "диван" main_page.click_go_button() search_results_page = page.SearchResultsPage(self.driver) #Verifies that the results page is not empty assert search_results_page.is_results_found(), "No results found." search_results_page.filter_min="100" search_results_page.filter_max="7000" search_results_page.apply_filters() search_results_page.filter_country="Украина" item_page = page.ItemPage(self.driver) price = item_page.get_result() assert (price<7000), "Invalid price" cart_page = page.CartPage(self.driver) cart_page.to_checkout() assert cart_page.is_price_valid(price), "Invalid price" checkout_page = page.CheckoutPage(self.driver) checkout_page.name = "Иван Иванофф" checkout_page.mail = "*****@*****.**" checkout_page.phone = "+380446666666" #self.driver.find_element_by_xpath('//div[@class=\"check-f-i-field\"]/span/button').click() checkout_page.checkout()
def save(self): self.driver = webdriver.Chrome() self.driver.get(self.web_page) main = page.MainPage(self.driver) main.career_catalog_data() with open(self.file, mode='w', encoding='utf-8', newline='') as fd: writer = csv.writer(fd, delimiter=',', dialect='excel', lineterminator='\n') writer.writerow([ 'career_name_en', 'career_code', 'faculty_name', 'link_to_career_curriculum' ]) #Head of the file for i, f in enumerate(main.faculty, start=0): size = len(main.c_names[i]) for j in range(0, size): writer.writerow([ main.c_names[i][j], main.c_codes[i][j], f, main.c_curriculum[i][j] ]) fd.close() self.driver.close() print("File " + self.file + " created successfully!")
def test_search_jumia(self): main_page = page.MainPage(self.driver) assert main_page.is_title_matches() main_page.search_text_element = "jacket" main_page.click_search_button() search_result_page = page.SearchResultPage(self.driver) assert search_result_page.is_result_found()
def test_in_sub_navbar(self): print('test 3: for subnav links') message = "nav bar link is not working" main_page = page.MainPage(self.driver) main_page.hover_over_sub_navbar() self.assertTrue(main_page.is_subnav_link_workings(), message) self.driver.back()
def test_invalid_search_rik_ee(self): #Kontrollime, et kirjutades otsingumootorisse '$$$' ei tule vasteid main_page = page.MainPage(self.driver) main_page.search_text_element = "$$$" main_page.click_search_button() search_results_page = page.SearchResultsPage(self.driver) assert not search_results_page.is_results_found()