def make_login(login, password): _login_field.set_value(login) _password_field.set_value(password) _log_in_button.click() #element(by_css(".loading-bar")).should(be.visible) sleep(1) element(by_css(".loading-bar")).should_not(be.visible)
def add_choice(): # re-write this code using selene.elements __work_area.should(be.visible) element(by_css(".loading-bar")).should_not(be.visible) chain = ActionChains(browser.driver()) chain.click_and_hold(__choice_interaction_btn).move_to_element(__work_area).perform() chain.release().perform()
def is_user_in_list(user, role=None): user_pattern = "//td[@class='login' and text()='{}']".format(user) if role: user_pattern = "{}/following-sibling::td[@class='roles' and text()='{}']".format( user_pattern, role) try: element(by_xpath(user_pattern)).should(be.visible) return True except TimeoutException: return False
def wait_page_reloaded(timeout=10): #element(by_css(".loading-bar")).should(be.visible) sleep(1) element(by_css(".loading-bar")).should_not(be.visible, timeout=timeout) element(by_css(".loading")).should_not(be.visible, timeout=timeout)
def open_authoring(): element(__authoring_btn).click()
def is_object_in_list(item_name): try: return element(by_xpath( "//li[@title='{}']/a".format(item_name))).is_displayed() except TimeoutException: return False
from time import sleep from allure import step from selene.bys import * from selene.support.conditions import be, have from framework.ui.elements import element, elements from selenium.common.exceptions import TimeoutException # Main and navigates elements for page __username = element(by_css(".username")) __popup_message = element(by_xpath("//div[@id='feedback-1']//div")) __groups_btn = element( by_xpath( "//a[@title='Group test takers according to global features and classifications.']" )) __delivery_btn = element( by_xpath("//a[@title='Prepare, publish deliveries sessions.']")) __items_btn = element( by_xpath("//a[@title='Create and design items and exercises.']")) __results_btn = element( by_xpath("//a[@title='View and format the collected results.']")) __tests_btn = element( by_xpath("//a[@title='Combine a selection of items into tests.']")) __test_takers_btn = element( by_xpath("//a[@title='Record and manage test-takers.']")) __language_select_patter = "//option[text()='{}']" #__save_btn = element(by_name("Save")) __save_btn = elements(by_xpath("//button[contains(text(), 'Save')]"))[0] __create_btn = element("a>.icon-save") __setting_btn = element("#settings") __users_btn = element("#users")
from os.path import realpath from allure import step from selene.bys import * from selene.support.conditions import be, have from framework.ui.elements import element # Import options area __browse_file_btn = element(by_xpath("//input[@type='file']")) __content_package_radio_btn = element("#importHandler_1") __file_success_status_icon = element(".status.success") __file_type_label = element('#file') __import_button = element(".form-submitter") __import_continue_btn = element("#import-continue") __status_message = element(".feedback-success") __success_dialog_icon = element(".icon-success") __import_format_pattern = "//label[contains(text(), '{}')]" IMPORT_TYPES = { "rdf": "RDF", "zip": "QTI/APIP" } IMPORT_TYPES_MESSAGE = { "rdf": "Import Metadata from RDF file", "zip": "Import a QTI/APIP Content Package" }
def fill_launch_url(url): element(by_name("endpoint")).set_value(url)
def fill_lti_secret(secret): element("#id_secret").set_value(secret)
def fill_lti_key(key): element("#id_key").set_value(key)
def select_correct_choice(num=1): __response_btn.click() element(by_xpath(__choice_checkbox_pattern.format(num))).click()
def select_item(item_obj): element(by_link_text(item_obj.label)).click()
def save_items(): element(by_xpath("//span[contains(text(), 'Save')]")).click()
def check_choice_selected(num=1): element(by_xpath(__choice_checkbox_pattern.format(num))).should_have(have.css_class("user-selected"))
from time import sleep from allure import step from selene.bys import * from selene.support.conditions import be from framework.ui.elements import element _login_field = element(by_name("login")) _password_field = element(by_name("password")) _log_in_button = element(by_name("connect")) @step("Make login with target account") def make_login(login, password): _login_field.set_value(login) _password_field.set_value(password) _log_in_button.click() #element(by_css(".loading-bar")).should(be.visible) sleep(1) element(by_css(".loading-bar")).should_not(be.visible)
def set_learner_role(): element("#id_roles").clear() element("#id_a_role").click() element(by_xpath("//option[@value='Learner']")).click()
def save_and_launch(): element("#save_bottom").click() element("#launchw_bottom").click()
def __select_import_type(import_type): element(by_xpath(__import_format_pattern.format(IMPORT_TYPES[import_type]))).click() __file_type_label.should(have.text(IMPORT_TYPES_MESSAGE[import_type]))
from allure import step from selene import browser # TODO: remove it letter from selenium.webdriver.common.action_chains import ActionChains # TODO: remove it letter from selene.bys import * from selene.support.conditions import be, have from framework.ui.elements import element __add_selection_btn = element(by_css(".itemref-placeholder")) __save_btn = element("#saver") __work_area = element(by_css(".item-editor-drop-area")) __choice_interaction_btn = element(by_css(".icon-choice")) __delete_interaction_btn = element(by_xpath("//span[@title='Choice Interaction']/following::div[@title='delete']")) __widget_interaction = element(by_css(".widget-blockInteraction")) __response_btn = element(by_xpath("//span[@data-state='answer']")) __choice_checkbox_pattern = "//li[@data-identifier='choice_{}']" @step("Add choice to item") def add_choice(): # re-write this code using selene.elements __work_area.should(be.visible) element(by_css(".loading-bar")).should_not(be.visible) chain = ActionChains(browser.driver()) chain.click_and_hold(__choice_interaction_btn).move_to_element(__work_area).perform() chain.release().perform() @step("Add selected items to test")