class PacklinkLoginActions(object): """ Class to perform "Login" actions. """ def __init__(self, driver): self.driver = driver self.utils = SeleniumUtils(self.driver) self.login_xpath = PacklinkLoginXpath() def input_email(self, email): """ Input email :param email: :return: boolean """ return True if self.utils.fill_input(self.login_xpath.input_email_login, email) else False def input_password(self, password): """ Input password :param password: :return: boolean """ return True if self.utils.fill_input(self.login_xpath.input_pass_login, password) else False def click_submit_button(self): """ Click on submit button :return: """ return True if self.utils.click_by_css(self.login_xpath.submit_button) else False
class PacklinkSearchActions(object): """ Class to perform "Search" actions. """ def __init__(self, driver): self.driver = driver self.utils = SeleniumUtils(self.driver) self.register_xpath = PacklinkRegisterXpath() self.search_xpath = PacklinkSearchXpath() def is_shipments_void(self): """ Check if the shipment list is empty :return: """ return True if self.utils.is_element_present( self.search_xpath.div_shipment_empty) else False def input_item_search(self, item): """ Input item searched :param item: :return: """ return True if self.utils.fill_input(self.search_xpath.input_search, item) else False def click_search_button(self): """ Click on complete button :return: """ return True if self.utils.click_by_css( self.search_xpath.button_search) else False def click_complete_button(self): """ Click on complete button :return: """ return True if self.utils.click_by_css( self.search_xpath.button_complete) else False
def before_scenario(context, scenario): # Setup webdriver. context.browser = setup_test_driver( environment=context.conf['webdriver']['environment'], browser=context.conf['webdriver']['browser']) # Selenium utils. SeleniumUtils(context.browser) # REGISTER: context.packlink_register_actions = PacklinkRegisterActions( context.browser) # LOGIN context.packlink_login_actions = PacklinkLoginActions(context.browser) # SHIPMENTS SEARCH context.packlink_search_actions = PacklinkSearchActions(context.browser) # DRAFT SHIPMENT context.packlink_draft_actions = PacklinkDraftActions(context.browser)
class PacklinkDraftActions(object): """ Class to perform "Draft" actions. """ def __init__(self, driver): self.driver = driver self.utils = SeleniumUtils(self.driver) self.draft_xpath = PacklinkDraftXpath() def click_new_shipment(self): """ :return: boolean """ return True if self.utils.click_by_css( self.draft_xpath.button_new_shipment) else False def is_in_details_new_shipment(self, app_url): """ Check if the user is details of new shipment :return: """ self.utils.wait_for_displayed(self.draft_xpath.details_new_shipment) if self.utils.get_current_url() == "".join( [app_url, "/private/shipments/create/info"]): return True else: logging.info( "The user is not in Details of new shipment view. The user is in : " + self.utils.get_current_url()) return False def count_items(self): count = self.driver.find_elements_by_css_selector( self.draft_xpath.number_items) return len(count) def input_weight(self, weight): return True if self.utils.fill_input(self.draft_xpath.input_weight, weight) else False def input_length(self, length): return True if self.utils.fill_input(self.draft_xpath.input_length, length) else False def input_width(self, width): return True if self.utils.fill_input(self.draft_xpath.input_width, width) else False def input_height(self, height): return True if self.utils.fill_input(self.draft_xpath.input_height, height) else False def click_save_button(self): return True if self.utils.click_by_css( self.draft_xpath.button_save_draft) else False def return_shipment_view(self): return True if self.utils.wait_for_not_displayed_xpath( self.draft_xpath.button_save_draft) else False
def __init__(self, driver): self.driver = driver self.utils = SeleniumUtils(self.driver) self.draft_xpath = PacklinkDraftXpath()
def __init__(self, driver): self.driver = driver self.utils = SeleniumUtils(self.driver) self.login_xpath = PacklinkLoginXpath()
class PacklinkRegisterActions(object): """ Class to perform "Register" actions. """ def __init__(self, driver): self.driver = driver self.utils = SeleniumUtils(self.driver) self.register_xpath = PacklinkRegisterXpath() self.search_xpath = PacklinkSearchXpath() def is_in_register_view(self, app_url): """ Check if the user is in demo view :return: """ if self.utils.get_current_url() == "".join([app_url, "/registro"]): return True else: logging.info( "The user is not in Register view. The user is in : " + self.utils.get_current_url()) return False def input_email(self, email): """ Input email :param email: :return: boolean """ return True if self.utils.fill_input(self.register_xpath.input_email, email) else False def input_password(self, password): """ Input password :param password: :return: boolean """ return True if self.utils.fill_input(self.register_xpath.input_pass, password) else False def input_telephone(self, telephone): """ Input telephone :param telephone: :return: boolean """ return True if self.utils.fill_input( self.register_xpath.input_telephone, telephone) else False def select_shipments(self): """ :return: boolean """ # self.utils.click_by_css(self.register_xpath.span_poblacion) return True if self.utils.click_by_css( self.register_xpath.select_shipments) else False def select_platform(self): """ :return: boolean """ return True if self.utils.click_by_css( self.register_xpath.select_platform) else False def select_ecommerce(self): """ :return: boolean """ return True if self.utils.click_by_css( self.register_xpath.select_ecommerce) else False def click_terms(self): """ :return: boolean """ return True if self.utils.click_by_css( self.register_xpath.checkbox_terms) else False def click_data(self): """ :return: boolean """ return True if self.utils.click_by_css( self.register_xpath.checkbox_data) else False def click_register(self): """ :return: boolean """ return True if self.utils.click_by_css( self.register_xpath.button_register) else False def is_in_shipments_view(self, app_url): """ Check if the user is in demo view :return: """ self.utils.is_element_present(self.search_xpath.button_new_shipment) if self.utils.get_current_url() == "".join( [app_url, "/private/shipments/all"]): return True else: logging.info( "The user is not in Shipments view. The user is in : " + self.utils.get_current_url()) return False def get_text_error(self): """ Given a type text obtain the text of this css(xpath) :param type_text: :return: """ return True if self.driver.find_element_by_css_selector( self.register_xpath.text_error_register) else False
def __init__(self, driver): self.driver = driver self.utils = SeleniumUtils(self.driver) self.register_xpath = PacklinkRegisterXpath() self.search_xpath = PacklinkSearchXpath()