示例#1
0
class MainScreen:

    ZOOM_IN_BUTTON = "vZoomIn"
    ZOOM_OUT_BUTTON = "vZoomOut"
    FOCUS_TO_USER_BUTTON = "vFocusToUser"

    def __init__(self, driver):
        self.element = Element(driver)
        self.driver = driver

    def get_zoom_in_button_enabled_state(self):
        return self.element.get_element_by_id(MainScreen.ZOOM_IN_BUTTON).get_attribute("enabled")

    def get_zoom_out_button_enabled_state(self):
        return self.element.get_element_by_id(MainScreen.ZOOM_OUT_BUTTON).get_attribute("enabled")

    def get_focus_to_user_button_enabled_state(self):
        return self.element.get_element_by_id(MainScreen.FOCUS_TO_USER_BUTTON).get_attribute("enabled")
class LoginPage(BasePage):

    URL = 'www.phptravels.net/login'

    def __init__(self, context):
        super().__init__(context)
        self.username_field = Element(By.XPATH, ".//input[@name='username']",
                                      context)
        self.password_field = Element(By.XPATH, ".//input[@name='password']",
                                      context)
        self.login_button = Element(By.XPATH, "//button[@type='submit']",
                                    context)

    def login_as(self, username=None, password=None):
        self.username_field.value = DataGenerator.generate_random_string(
        ) if username is None else username
        self.password_field.value = DataGenerator.generate_random_string(
        ) if password is None else password
        self.login_button.click()
示例#3
0
class HomePage(BasePage):
    URL = 'www.phptravels.net/home'

    def __init__(self, context):
        super().__init__(context)
        self.my_account_button = Element(
            By.XPATH, "/html[1]/body[1]/div[2]/header[1]/div[1]/div[1]/div[1]/div[2]/div[1]/ul[1]/li[3]/div[1]/a[1]",
            context)
        self.login_button = Element(
            By.XPATH, "//a[@class='dropdown-item active tr']", context)
        self.currency_dropdown = Dropdown(
            By.ID, "dropdownCurrency", context)
        self.currency_choice = Dropdown(
            By.XPATH, '//div[@class="dropdown-menu-inner"]/a[2]', context)
        self.flight_tab = Element(
            By.LINK_TEXT, "Flights", context)


    def go_to_login_page(self):
        self.my_account_button.click()
        self.login_button.click()

    def select_from_dropdown(self):
        self.currency_dropdown.click()
        self.currency_choice.click()
        time.sleep(5)
        assert_that(self.currency_dropdown.text, equal_to("GBP"))

    def press_flight_tab(self):
        self.flight_tab.click()


    #def enter_flight_data(self):
        #self.
class GooglePage(BasePage):

    URL = 'www.google.pl'

    def __init__(self, context):
        super().__init__(context)
        self.search_field = Element(By.ID, "lst-ib", context)
        self.search_suggestion = Element(
            By.XPATH, ".//ul[@role='listbox']/li//div[string(.)='{argument}']",
            context)
        self.sign_in = Element(By.XPATH, ".//a[@id='gb 70']", context)
        self.password_field = Element(By.XPATH, ".//input[@name='password']",
                                      context)
        self.email_field = Element(By.XPATH, "", context)
        self.login_next_button = Element(By.XPATH, ".//*[text()='Next']",
                                         context)
        self.logged_user_icon = Element(By.XPATH, ".//span[@id='gb_7a']",
                                        context)
        self.logged_user_email_info = Element(
            By.XPATH, ".//*[contains(@class,'gb_xb')]", context)

    def fill_search_field(self, search_phrase):
        self.search_field.value = search_phrase

    def select_search_suggestion(self, suggestion):
        self.search_suggestion.set_parameters(suggestion).click()

    def login_as(self, email, password):
        self.email_field.value = email
        self.password_field.value = password
        self.login_next_button.click()

    def is_logged_user(self, name):
        self.logged_user_icon.click()
        return self.logged_user_email_info.text == name
示例#5
0
 def __init__(self, context):
     super().__init__(context)
     self.my_account_button = Element(
         By.XPATH, "/html[1]/body[1]/div[2]/header[1]/div[1]/div[1]/div[1]/div[2]/div[1]/ul[1]/li[3]/div[1]/a[1]",
         context)
     self.login_button = Element(
         By.XPATH, "//a[@class='dropdown-item active tr']", context)
     self.currency_dropdown = Dropdown(
         By.ID, "dropdownCurrency", context)
     self.currency_choice = Dropdown(
         By.XPATH, '//div[@class="dropdown-menu-inner"]/a[2]', context)
     self.flight_tab = Element(
         By.LINK_TEXT, "Flights", context)
示例#6
0
class LoginScreen:

    PHONE_NUMBER_TEXTBOX_ID = "vLogin"
    PASSWORD_TEXTBOX_ID = "vPassword"
    LOGIN_BUTTON = "btnLogin"
    USE_FAST_CHECKBOX = "vUseFastLogin"

    def __init__(self, driver):
        self.element = Element(driver)

    def get_phone_number_textbox_enabled_state(self):
        return self.element.get_element_by_id(
            LoginScreen.PHONE_NUMBER_TEXTBOX_ID).get_attribute("enabled")

    def get_password_textbox_enabled_state(self):
        return self.element.get_element_by_id(
            LoginScreen.PASSWORD_TEXTBOX_ID).get_attribute("enabled")

    def type_phone_number(self, number):
        phone_number_textbox = self.element.get_element_by_id(
            LoginScreen.PHONE_NUMBER_TEXTBOX_ID)
        phone_number_textbox.clear()
        phone_number_textbox.send_keys(number)

    def type_password(self, password):
        password_textbox = self.element.get_element_by_id(
            LoginScreen.PASSWORD_TEXTBOX_ID)
        password_textbox.clear()
        password_textbox.send_keys(password)

    def click_login_button(self):
        login_button = self.element.get_element_by_id(LoginScreen.LOGIN_BUTTON)
        login_button.click()

    def set_fast_login_checkbox_state(self, state):
        fast_login_checkbox = self.element.get_element_by_id(
            LoginScreen.USE_FAST_CHECKBOX)
        current_state = fast_login_checkbox.get_attribute("checked")
        if current_state != state:
            fast_login_checkbox.click()
示例#7
0
 def perform_action_on_row_with_text(self, row_text: list, action_name):
     action_for_row_with_text = Element(
         By.XPATH,
         self._get_selector_with_text(row_text) +
         "//a[contains(@href,'{}')]".format(action_name), self.context)
     action_for_row_with_text.click()
示例#8
0
 def select_row_with_text(self, row_text: list):
     row_with_text = Element(By.XPATH,
                             self._get_selector_with_text(row_text),
                             self.context)
     row_with_text.click()
示例#9
0
 def get_number_of_visible_rows(self):
     table_rows = Element(By.XPATH, self.selector + "//tbody//tr",
                          self.context)
     return len(table_rows.get_elements())
示例#10
0
 def does_first_row_contains_text(self, row_text: list) -> bool:
     row_with_text = Element(By.XPATH,
                             self._get_selector_with_text(row_text, 1),
                             self.context)
     return row_with_text.is_element_present()
示例#11
0
 def wait_for_row_to_be_not_present(self, text):
     row_with_text = Element(By.XPATH, self._get_selector_with_text(text),
                             self.context)
     row_with_text.wait_for_element_to_be_not_present()
示例#12
0
 def is_row_with_text_present(self, row_text: list) -> bool:
     row_with_text = Element(By.XPATH,
                             self._get_selector_with_text(row_text),
                             self.context)
     return row_with_text.is_element_present()
 def _create_subelements(self):
     self.option = Element(By.XPATH, self.selector + "...", self.context)
示例#14
0
 def __init__(self, driver):
     self.element = Element(driver)
 def __init__(self, context):
     super().__init__(context)
     self.date = Element(
         By.XPATH, "//span[@class='h4']", context)
     self.home_page_header= Element(
         By.XPATH, "//div[@class='header-logo go-right']//a//img", context)
 def __init__(self, context):
     super().__init__(context)
     self.username_field = Element(By.XPATH, ".//input[@name='username']",
                                   context)
     self.password_field = Element(By.XPATH, ".//input[@name='password']",
                                   context)
 def __init__(self, context):
     super().__init__(context)
     self.search_field = Element(By.ID, "lst-ib", context)
     self.search_suggestion = Element(
         By.XPATH, ".//ul[@role='listbox']/li//div[string(.)='{argument}']",
         context)
     self.sign_in = Element(By.XPATH, ".//a[@id='gb 70']", context)
     self.password_field = Element(By.XPATH, ".//input[@name='password']",
                                   context)
     self.email_field = Element(By.XPATH, "", context)
     self.login_next_button = Element(By.XPATH, ".//*[text()='Next']",
                                      context)
     self.logged_user_icon = Element(By.XPATH, ".//span[@id='gb_7a']",
                                     context)
     self.logged_user_email_info = Element(
         By.XPATH, ".//*[contains(@class,'gb_xb')]", context)
 def __init__(self, context):
     self.result_stats = Element(By.ID, "resultStats", context)
     super().__init__(context)