def pick_this_time(self, time): wait(lambda: len(self.available_time_list) > 0) for item in self.available_time_list: label = item.available_time.text if label.startswith(time): item.button.click() break
def enter_cc_info(self, card_number, card_date, card_cvc, card_zip): Select(self.credit_card_list).select_by_visible_text("New Card") wait(lambda: self.stripe.is_enabled()) self._driver.switch_to.frame(self.stripe) wait(lambda: self.card_number_input.is_enabled()) attempts = 50 card_number_size = 16 for attempt in range(0, attempts): for number in range(0, card_number_size): self.card_number_input.send_keys(Keys.BACK_SPACE) self.card_number_input.send_keys(card_number) self.card_date_input.send_keys(card_date) actual_value_card = self.card_number_input.get_attribute('value') actual_value_card = actual_value_card.replace(" ", "") actual_value_date = self.card_date_input.get_attribute('value') actual_value_date = actual_value_date.replace(" / ", "") if actual_value_card == card_number and actual_value_date == card_date: break else: print( "%s attempt failed. Entered: %s and %s but expected: %s and %s" % (attempt, actual_value_card, actual_value_date, card_number, card_date)) else: print("Correct value hasn't been entered.") exit() self.card_cvc_input.send_keys(card_cvc) if card_zip is not None: self.card_zip_input.send_keys(card_zip) self._driver.switch_to.default_content()
def select_date(self, year, month, day): wait(lambda: len(self.available_days) > 0, timeout_seconds=10, waiting_for="Waiting for available days appears.") self._driver.execute_script( "$('#datepicker_1').datepicker('setDate', new Date(%s, %s-1, %s));" % (year, month, day))
def test_add_to_cart1(webdriver): #Lesson choose url = "http://brainacad.demo.site/" lesson = 1 if lesson != 0: url = url + 'lesson_' + str(lesson) #Open site http://brainacad.demo.site/ visit(url) page = MadisonPage(driver = driver.browser) wait(lambda: page.is_element_present('account')) #Go to ACCESSORIES -> Jewerly page.go_to_menuitem(driver.browser,2,12) page = GoodsList(driver = driver.browser) #Add to cart 1 item 1 qty page.items[0].add_to_cart.click() page = ShoppingCart(driver = driver.browser) price = float(page.items[0].price.text[1:]) qty = int(page.items[0].qty.get_attribute('value')) subtotal = float(page.items[0].subtotal.text[1:]) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert subtotal == price * qty, "Subtotal price wrong"
def test_search(self): page = MainPage() page.open() page.button() page.search.text_input.send_keys(u"Собянин") result_page = page.get_result() wait(lambda: result_page.is_element_present('widget'), timeout_seconds=2)
def navigate_to(self): wait(lambda: self.navigation_bar.main_tab is not None, timeout_seconds=20) self.navigation_bar.main_tab.click() self.navigation_bar.people.click() wait(lambda: self.navigation_bar.expanded_list) self.navigation_bar.people_hub.click()
def no_such_guest(self, order): list_of_guests = [] wait(lambda: len(self.event_manifest.guests_list) > 0) for guest in self.event_manifest.guests_list: list_of_guests.append(guest.name.text) expected_name = order.first_name + " " + order.last_name assert expected_name not in list_of_guests
def test_add_to_cart2(webdriver): #Lesson choose url = "http://brainacad.demo.site/" lesson = 1 if lesson != 0: url = url + 'lesson_' + str(lesson) #Open site http://brainacad.demo.site/ visit(url) page = MadisonPage(driver = driver.browser) wait(lambda: page.is_element_present('account')) #Go to ACCESSORIES -> Jewerly page.go_to_menuitem(driver.browser,2,13) page = GoodsList(driver = driver.browser) #Open product details page.items[0].link.click() page = ProductDetals(driver = driver.browser) #Add to cart 1 item 5 qty set_value(page.qty, '5') page.add_button.click() page = ShoppingCart(driver = driver.browser) qty = int(page.items[0].qty.get_attribute('value')) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert qty == 5, "Items Qty Wrong"
def verify_url(self, url): LOGGER.info("Verify url") wait(self.compare_actions.compare_page_title.is_displayed) assert url in self.driver.current_url, "Test compare products failed. " \ f"Expected url: {url}, " \ f"Actual url: {self.driver.current_url}"
def verify_table(self, order): self.navigate_to() wait(lambda: self.rain_checks_page.page_title.text == "Rain Checks") assert order.activity == self.rain_checks_page.event_name.text assert order.first_name + " " + order.last_name == self.rain_checks_page.guest.text assert order.email == self.rain_checks_page.email.text assert order.phone == self.rain_checks_page.phone.text
def test_addteacher(webdriver): user="******" passw = "123123" name = fake.first_name() uname = fake.user_name() passwt = fake.password() email = fake.email() print email visit(url) page = BasiliskPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.login(user, passw) wait(lambda: page.is_element_present('log_menu')) page.users.click() page = TeachersListPage(driver = driver.browser) wait(lambda: page.is_element_present('add_teacher')) page.add_teacher.click() page = TeacherPage(driver = driver.browser) wait(lambda: page.is_element_present('save')) page.add_teacher(name, uname, email, passwt, passwt) page = TeachersListPage(driver = driver.browser) wait(lambda: page.is_element_present('add_teacher')) #time.sleep(3) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert page.teachers_list[-1].text == email
def enter_index_pattern(self, pattern): self.index_pattern_field.clear() if self.is_element_present('submit_button'): wait(lambda: not self.submit_button.is_enabled()) if self.is_element_present('next_button'): wait(lambda: not self.next_button.is_enabled()) self.index_pattern_field.send_keys(pattern)
def edit_guide_activity(self, activity): self.people_hub_page.edit.click() wait(lambda: len(self.add_guide_page.username.text) > 0) self.add_guide_page.select(self.add_guide_page.trained_activity, activity) self.add_guide_page.save_button.click() self.add_guide_page.wait_redirection()
def verify_guides_details(self, guides): self.people_hub_page.edit.click() wait(lambda: len(self.add_guide_page.username.text) > 0) assert guides.username == self.add_guide_page.username.text assert guides.first_name == self.add_guide_page.first_name.text assert guides.last_name == self.add_guide_page.last_name.text assert guides.email == self.add_guide_page.email.text assert guides.timezone == self.add_guide_page.get_selected_value( self.add_guide_page.timezone) assert guides.phone_number == self.add_guide_page.phone_number.text if guides.secondary_phone_number is not None: assert guides.secondary_phone_number == self.add_guide_page.secondary_phone_number.text if guides.emergency_contact is not None: assert guides.emergency_contact == self.add_guide_page.emergency_contact.text if guides.hire_date is not None: assert guides.hire_date == self.add_guide_page.hire_date.text if guides.end_date is not None: assert guides.end_date == self.add_guide_page.end_date.text if guides.bank_name is not None: assert guides.bank_name == self.add_guide_page.bank_name.text if guides.account_type is not None: assert guides.account_type == self.add_guide_page.account_type.text if guides.bank_routing_number is not None: assert guides.bank_routing_number == self.add_guide_page.bank_routing_number.text if guides.account_number is not None: assert guides.account_number == self.add_guide_page.account_number.text assert guides.pay_rate_type == self.add_guide_page.get_selected_value( self.add_guide_page.pay_rate_type) if guides.trained_activities is not None: assert guides.trained_activities == self.add_guide_page.trained_activity.text
def verify_time_list(self, time): wait(lambda: len(self.booking_page.get_time_list()) > 1) time_list = self.booking_page.get_time_list() time_options = [] for time in time_list: time_options.append(time.text) assert time not in time_options, time_options
def select_event(self, tickets): self.navigate_to() self.booking_page.select_activity(tickets.activity) self.select_tickets(tickets) self.booking_page.select_date(tickets.year, tickets.month, tickets.day) self.booking_page.select_time(tickets.time) wait(lambda: self.booking_page.order_cart.is_displayed())
def cancel_event(self): self.event_manifest.actions_button.click() self.event_manifest.cancel_event.click() wait(lambda: self.event_manifest.pop_up.is_displayed()) expected_notification = "Are you sure you would like to cancel this event? Once you do, your guests will be " \ "automatically notified of the cancellation." assert expected_notification == self.event_manifest.pop_up.text self.event_manifest.pop_up_ok_button.click()
def verify_payment_info(self, cert): if cert.certificate_type == "Activity Tickets": assert cert.initial_amount == self.certificate.initial_amount.text assert cert.cert_booking_fee == self.certificate.booking_fee.text assert cert.cert_total_amount == self.certificate.total_amount.text wait(lambda: self.certificate.next_step_button.is_enabled()) self.certificate.next_step_button.click() assert cert.cert_total_amount == self.certificate.full_charge.text
def wait_for_loading_indicator(self, timeout=5): try: wait(lambda: self.is_element_present('loading_indicator') is True, waiting_for='Loading indicator is displayed', timeout_seconds=timeout) except: pass wait(lambda: self.is_element_present('loading_indicator') is False, waiting_for='Loading indicator is not displayed', timeout_seconds=timeout)
def click_catalog_section(self, section_name): LOGGER.info("Hover computers section") for section in self.navigation_catalog_actions.sections: if section.text == section_name: section.click() wait(lambda: len(self.navigation_catalog_actions.subsections) > 0) break
def add_guide_with_invalid_username(self, guides): self.add_guide_form() self.add_guide_page.username.send_keys(guides.username) self.add_guide_page.empty_space.click() wait(lambda: len(self.add_guide_page.bootstrap_alert.text) > 0) print(self.add_guide_page.bootstrap_alert.text) assert "Username ({}) not valid.".format( guides.username) == self.add_guide_page.bootstrap_alert.text
def submit_declined_card(self, tickets): self.booking_page.select_payment_type(tickets.payment_type) self.booking_page.enter_cc_info(tickets.declined_card_number, tickets.card_date, tickets.card_cvc, tickets.card_zip) self.booking_page.submit_booking_button.click() wait(lambda: self.booking_page.final_alert.is_displayed(), timeout_seconds=100) assert "Credit card declined: please try again." == self.booking_page.final_alert.text self.booking_page.final_alert_ok_button.click()
def close_event(self): self.event_manifest.actions_button.click() self.event_manifest.close_bookings.click() wait(lambda: self.event_manifest.pop_up.is_displayed(), timeout_seconds=25) expected_notification = "Are you sure you would like to close this event? This will disallow any further " \ "bookings unless it is re-opened." assert expected_notification == self.event_manifest.pop_up.text self.event_manifest.pop_up_ok_button.click()
def re_open_event(self): self.event_manifest.actions_button.click() self.event_manifest.re_open_bookings.click() wait(lambda: self.event_manifest.pop_up.is_displayed(), timeout_seconds=25) expected_notification = "Are you sure you would like to re-open this event? This will open up the event to " \ "more bookings." assert expected_notification == self.event_manifest.pop_up.text self.event_manifest.pop_up_ok_button.click()
def add_type(self, addons): self.activity_addons.edit_button.click() wait( lambda: not self.navigation_bar.page_loader_wrapper.is_displayed(), timeout_seconds=20) self.fill_type_form(addons) save_type_button = self.addon_page.save_type save_type_button.click() wait(lambda: self.addon_page.add_type_button.is_displayed())
def navigate_to(self): if "/giftcertificate.aspx" not in self.app.current_url(): wait( lambda: self.navigation_bar.main_actions_drop_down is not None, timeout_seconds=20) self.navigation_bar.main_actions_drop_down.click() self.navigation_bar.sell_gift_certificates.click() elif self.certificate_page.certificate_pop_up() is True: self.certificate_page.click_cancel_button()
def select_addon(self, order): self.booking_page.addons_link.click() wait(lambda: len(self.booking_page.addons_list) > 0) for addon in self.booking_page.addons_list: if addon.name.text.startswith(order.addon_name): addon.checkbox.click() self.booking_page.select(addon.type_list, order.addon_type) self.booking_page.add_to_cart.click() break
def fill_type_form(self, addons): self.addon_page.add_type_button.click() wait(lambda: self.addon_page.save_type.is_displayed()) sleep(2) self.addon_page.select(self.addon_page.addon_select, addons.addon_name) self.addon_page.type_name.send_keys(addons.type_name) self.addon_page.type_price.send_keys(addons.type_price) if addons.type_status == "Active": self.addon_page.type_status.click()
def kibana_login_as_elastic_user(request): if config.testing.xpack: login_page = LoginPage() login_page.login(config.elasticsearch.username, config.elasticsearch.password) sidebar = Sidebar() sidebar.loaded() wait(lambda: sidebar.is_link_visible(config.elasticsearch.username) is True)
def delete_addon_cancel(self, addons): self.find_addon(addons) self.activity_addons.delete_button.click() wait(lambda: self.activity_addons.pop_up.is_displayed()) expected_notification = "Are you sure you want to delete {}?".format( addons.addon_name) assert expected_notification == self.activity_addons.pop_up.text self.activity_addons.pop_up_cancel_button.click() wait(lambda: not self.activity_addons.pop_up.is_displayed()) sleep(2)
def get_result_list(self, text): """ :param text: :return: """ wait(lambda: self.result_list, waiting_for='until search results are loaded') return list( filter(lambda element: text in element.__getattribute__('text'), self.result_list))
def find_and_delete_type(self, addons): wait( lambda: len(self.addon_page.addon_name.get_attribute('value')) > 0) for item in self.addon_page.addon_types_table: if item.name.text == addons.type_name: item.delete.click() break wait(lambda: self.addon_page.pop_up.is_displayed()) expected_notification = "Are you sure you want to remove this add-on type?" assert expected_notification == self.addon_page.pop_up.text
def get_hits(self, pattern): self.open() self.wait_for_loading_indicator() self.click_pattern(pattern) self.wait_for_loading_indicator() try: wait(lambda: int(self.get_query_hits()) > 0, timeout_seconds=7) except: pass return int(self.get_query_hits())
def test_media(webdriver): visit(url) driver.browser.maximize_window() page = BasiliskPage(driver = driver.browser) page.create_quiz.click() page = CreateQuizPage(driver = driver.browser) #time.sleep(1) wait(lambda: page.is_element_present('publish')) #page.media_image.click() #page.media_image.clear() page.media.send_keys(r"d:\barsik.jpg")
def test_login_valid(webdriver, superadmin): #user="******" #passw = "123123" visit(url) driver.browser.maximize_window() page = BasiliskPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.login(superadmin[0], superadmin[1]) wait(lambda: page.is_element_present('log_menu')) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert page.is_element_present('log_menu')
def test_login_invalid(webdriver): user= "******" passw = "123124" visit(url) page = BasiliskPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.login(user, passw) wait(lambda: page.is_element_present('login_link')) time.sleep(1) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert page.is_element_present('log_menu')
def test_login(webdriver): visit(url) driver.browser.maximize_window() page = MyRozPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('login_btn')) page.login(user, passw) time.sleep(3) visit('http://myroz.com/add-flight') time.sleep(3) page.dron_id.click() page.search.send_keys('test') page.search.send_keys(Keys.ENTER)
def test_sort_by_price(webdriver): #Lesson choose url = "http://brainacad.demo.site/" lesson = 3 if lesson != 0: url = url + 'lesson_' + str(lesson) #Open site http://brainacad.demo.site/ visit(url) page = MadisonPage(driver = driver.browser) wait(lambda: page.is_element_present('account')) #Go to MEN -> Shirts page.go_to_menuitem(driver.browser, 1, 7) goods = GoodsList(driver = driver.browser) wait(lambda: goods.is_element_present('sort_by'), waiting_for = 'Wait for element SortBy') #Choose Select By Price Select(goods.sort_by).select_by_index(2) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert Select(goods.sort_by).first_selected_option.text == "Price"
def test_checkout(webdriver): lesson = 0 url = "http://brainacad.demo.site/" if lesson != 0: url = url + 'lesson_' + str(lesson) #Open site http://brainacad.demo.site/ visit(url) page = MadisonPage(driver = driver.browser) wait(lambda: page.is_element_present('account')) #Go to ACCOUNT -> Login page.account.click() page.log_in.click() page = LoginPage(driver = driver.browser) wait(lambda: page.is_element_present('log_btn')) #Enter email, password and submit page.login(email, passw) #Go to ACCESSORIES -> Eyewear page.go_to_menuitem(driver.browser,2,12) page = GoodsList(driver = driver.browser) #Add 1 item to cart product = page.items[0].link.text page.items[0].add_to_cart.click() page = ShoppingCart(driver = driver.browser) #Go to checkout page.checkout[0].click() page.continu1.click() page.free.click() page.continu2.click() page.continu3.click() page.terms_agree.click() page.place_order.click() allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) #Order verification page.order.click() assert product == page.product_name.text
def test_registration1(webdriver): #Lesson choose url = "http://brainacad.demo.site/" lesson = 0 if lesson != 0: url = url + 'lesson_' + str(lesson) #Open site http://brainacad.demo.site/ visit(url) page = MadisonPage(driver = driver.browser) wait(lambda: page.is_element_present('account')) #Choose ACCOUNT -> Register page.account.click() page.register.click() #Fill in Registration form page = RegistrationPage(driver = driver.browser) wait(lambda: page.is_element_present('button_reg')) #Submit page.register(fname, lname, email, passw, passw) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert page.is_element_present('success_msg')
def test_search(webdriver): #Lesson choose url = "http://brainacad.demo.site/" lesson = 0 if lesson != 0: url = url + 'lesson_' + str(lesson) # Search text text = "pants" #Open site http://brainacad.demo.site/ visit(url) page = MadisonPage(driver = driver.browser) wait(lambda: page.is_element_present('search')) #Enter search text set_value(page.search, text) page.search.submit() #Search results page = GoodsList(driver = driver.browser) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert text == page.search.get_attribute('value'), "Wrong text search" assert len(page.items) > 0, "Number of Result items should be > 0"
def test_login1(webdriver): email = "*****@*****.**" passw = "miha12" #Lesson choose lesson = 0 url = "http://brainacad.demo.site/" if lesson != 0: url = url + 'lesson_' + str(lesson) #Open site http://brainacad.demo.site/ visit(url) page = MadisonPage(driver = driver.browser) wait(lambda: page.is_element_present('account')) #Go to ACCOUNT -> Login page.account.click() page.log_in.click() page = LoginPage(driver = driver.browser) wait(lambda: page.is_element_present('log_btn')) #Enter email, password and submit page.login(email, passw) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert page.is_element_present('welcom_msg')
def test_create_quiz_1(webdriver): user="******" passw = "789789" visit(url) driver.browser.maximize_window() page = BasiliskPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.login(user, passw) wait(lambda: page.is_element_present('log_menu')) page.create_quiz.click() page = CreateQuizPage(driver = driver.browser) wait(lambda: page.is_element_present('publish')) page.create_quiz(50, 2) page.publish.click() page = PublishQuizPage(driver = driver.browser) wait(lambda: page.is_element_present('name')) page.publish("Quiz_50 " + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")), 'Create Quiz', "c1", '5') page.publish_btn.click() allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) time.sleep(1) assert page.is_element_present('success_msg')
def test_create_quiz(webdriver): user="******" passw = "789789" visit(url) driver.browser.maximize_window() page = BasiliskPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.login(user, passw) wait(lambda: page.is_element_present('log_menu')) page.create_quiz.click() page = CreateQuizPage(driver = driver.browser) #time.sleep(1) wait(lambda: page.is_element_present('publish')) page.create_quiz(25, 0) '''page.publish.click()
def test_reg_valid(webdriver): visit(url) driver.browser.maximize_window() page = BasiliskPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.reg_link.click() page = RegistrationPage(driver = driver.browser) wait(lambda: page.is_element_present('button_reg')) page.register(fname, lname, login, passw, passw, email, promo, univer) wait(lambda: page.is_element_present('success_msg')) f = open("users_all.txt", 'a') f.write('\n' + login + ' ' + passw) f.close() allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert page.is_element_present('success_msg')
def is_element_present(self, element_name, just_in_dom=False, timeout=0): def _get_driver(): driver = getattr(self, '_driver', None) if driver: return driver return get_driver() _get_driver().implicitly_wait(timeout) try: def is_displayed(): element = getattr(self, element_name, None) if not element: raise WebiumException('No element "%s" within container %s' % (element_name, self)) return element.is_displayed() is_displayed() if just_in_dom else wait(lambda: is_displayed(), timeout_seconds=timeout) return True except WebDriverException: return False except TimeoutExpired: return False finally: _get_driver().implicitly_wait(webium.settings.implicit_timeout)
def test_search2(webdriver): user="******" passw = "123123" text = "Mcerwreqwr" visit(url) page = BasiliskPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.login(user, passw) wait(lambda: page.is_element_present('log_menu')) page.university.click() page = UniversityListPage(driver = driver.browser) wait(lambda: page.is_element_present('search_field')) page.search(text) time.sleep(1) page = UniversityListPage(driver = driver.browser) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert len(page.univer_list) == 0
def test_smoke(webdriver): #Lesson choose lesson = 0 url = "http://brainacad.demo.site/" if lesson != 0: url = url + 'lesson_' + str(lesson) #Open site http://brainacad.demo.site/ visit(url) page = MadisonPage(driver = driver.browser) wait(lambda: page.is_element_present('account')) #Enter search text text = "pants" set_value(page.search, text) page.search.submit() #Search results page = GoodsList(driver = driver.browser) assert text == page.search.get_attribute('value'), "Wrong text search" assert len(page.items) > 0, "Number of Result items should be > 0" #Choose ACCOUNT -> Register page.account.click() page.register.click() page = RegistrationPage(driver = driver.browser) #Fill in Registration form page.register(fname, lname, email, passw, passw) page = AccountPage(driver = driver.browser) #Manage Addreess click page.manage_addr.click() page = AddNewAddress(driver = driver.browser) #Fill in address page.add_address(country, tel, street, city, index) #Go to MEN -> Shirts page.go_to_menuitem(driver.browser, 1, 7) goods = GoodsList(driver = driver.browser) wait(lambda: goods.is_element_present('sort_by'), waiting_for = 'Wait for element SortBy') #Choose Select By Price Select(goods.sort_by).select_by_index(2) assert Select(goods.sort_by).first_selected_option.text == "Price" #Go to ACCESSORIES -> Eyewear page.go_to_menuitem(driver.browser,2,12) page = GoodsList(driver = driver.browser) #Add 1 item to cart product = page.items[0].link.text page.items[0].add_to_cart.click() page = ShoppingCart(driver = driver.browser) #Go to checkout page.checkout[0].click() page.continu1.click() page.free.click() page.continu2.click() page.continu3.click() page.terms_agree.click() page.place_order.click() allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) #Order verification page.order.click() assert product == page.product_name.text
def test_switch_univer(webdriver): visit(url) page = BasiliskPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.login(user, passw) wait(lambda: page.is_element_present('university')) page.university.click() page = UniversityListPage(driver = driver.browser) wait(lambda: page.is_element_present('univer_add')) page.univer_links[0].click() page = UniverPage(driver = driver.browser) wait(lambda: page.is_element_present('add_admin')) if page.status.get_attribute('checked'): test = "on" page.on.click() set_value(page.disable_pass, "123123") page.change.click() else: test = "off" page.off.click() time.sleep(3) page.save_btn.click() page = UniversityListPage(driver = driver.browser) wait(lambda: page.is_element_present('univer_add')) page.univer_links[0].click() page = UniverPage(driver = driver.browser) wait(lambda: page.is_element_present('add_admin')) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) if test == "on": assert page.status.get_attribute('checked') == None elif test == "off": assert page.status.get_attribute('checked') == 'true'
def test_add_faculty_custom(webdriver): user="******" passw = "123123" visit(url) #driver.browser.maximize_window() page = BasiliskPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.login(user, passw) wait(lambda: page.is_element_present('log_menu')) page.university.click() page = UniversityListPage(driver = driver.browser) wait(lambda: page.is_element_present('univer_add')) page.univer_links[9].click() page = UniverPage(driver = driver.browser) wait(lambda: page.is_element_present('add_admin')) page.faculty_dep.click() page = FacultyListPage(driver = driver.browser) wait(lambda: page.is_element_present('add')) time.sleep(1) page.add.click() time.sleep(2) page.all_faculties[0].click() wait(lambda: page.is_element_present('save')) faculty = fake.company() set_value(page.name, faculty) page.save.click() wait(lambda: page.is_element_present('add')) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert page.univer_faculties[-1].text == faculty
def test_add_faculty_from_list(webdriver): user="******" passw = "123123" visit(url) #driver.browser.maximize_window() page = BasiliskPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.login(user, passw) wait(lambda: page.is_element_present('log_menu')) page.university.click() page = UniversityListPage(driver = driver.browser) wait(lambda: page.is_element_present('univer_add')) page.univer_links[10].click() page = UniverPage(driver = driver.browser) wait(lambda: page.is_element_present('add_admin')) page.faculty_dep.click() page = FacultyListPage(driver = driver.browser) wait(lambda: page.is_element_present('add')) time.sleep(1) page.add.click() time.sleep(2) if len(page.all_faculties) > 1: faculty = page.all_faculties[1].text page.all_faculties[1].click() wait(lambda: page.is_element_present('add')) test = False for i in range(len(page.univer_faculties)): if page.univer_faculties[i].text == faculty: test = True allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert test else: pytest.fail("There is no more Faculties in the list")
def test_take_quiz_random(webdriver, q): file = open('users_1.txt', 'r') data = file.readlines() visit(url) driver.browser.maximize_window() page = BasiliskPage(driver = driver.browser) for u in range(len(data)): user = data[u].split() page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.login(user[0], user[1]) wait(lambda: page.is_element_present('log_menu')) page.explore.click() wait(lambda: page.is_element_present('quizes')) page.quizes.click() wait(lambda: page.is_element_present('quiz_fac')) time.sleep(1) page.quiz_fac.click() wait(lambda: page.is_element_present('take_dep')) time.sleep(1) page.take_dep.click() wait(lambda: page.is_element_present('quiz_header')) time.sleep(1) if len(page.quiz_list) !=0: page.quiz_list[-1].click() page.start_quiz.click() page = TakeQuizPage(driver = driver.browser) wait(lambda: page.is_element_present('next_question')) for i in range(q): #r = random.choice([0,1]) r = random.randrange(0, 2) page.variants[r].click() page.next_question.click() time.sleep(5) if u < len(data) - 1: page.login_link.click() page.logout.click()
def test_take_quiz(webdriver): user="******" passw = "789789" visit(url) driver.browser.maximize_window() page = BasiliskPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.login(user, passw) wait(lambda: page.is_element_present('log_menu')) page.explore.click() wait(lambda: page.is_element_present('quizes')) page.quizes.click() wait(lambda: page.is_element_present('quiz_fac')) time.sleep(1) page.quiz_fac.click() wait(lambda: page.is_element_present('take_quiz')) time.sleep(1) page.take_quiz.click() wait(lambda: page.is_element_present('quiz_header')) time.sleep(1) if len(page.quiz_list) !=0: page.quiz_list[1].click() page.start_quiz.click() page = TakeQuizPage(driver = driver.browser) wait(lambda: page.is_element_present('next_question')) for i in range(3): k = i*4 page.variants[k].click() page.next_question.click()
def test_addadmin2(webdriver): user="******" passw = "123123" '''name = "Mihail" lname = "Cherniavskiy" uname = "mihaadmin24" email = "*****@*****.**"''' name = fake.first_name() lname = fake.last_name() uname = fake.user_name() passwa = fake.password() email = fake.email() visit(url) #driver.browser.maximize_window() page = BasiliskPage(driver = driver.browser) page.login_link.click() wait(lambda: page.is_element_present('log_btn')) page.login(user, passw) wait(lambda: page.is_element_present('log_menu')) page.university.click() page = UniversityListPage(driver = driver.browser) wait(lambda: page.is_element_present('univer_add')) page.univer_links[5].click() page = UniverPage(driver = driver.browser) wait(lambda: page.is_element_present('add_admin')) time.sleep(3) page.add_admin.click() page = UniverAdminPage(driver = driver.browser) wait(lambda: page.is_element_present('name')) page.add_uadmin(name, lname, uname, email, passwa, passwa) page = UniverPage(driver = driver.browser) wait(lambda: page.is_element_present('add_admin')) time.sleep(3) allure.attach("Results", driver.browser.page_source, AttachmentType.HTML) assert email == page.email_list[-1].text