示例#1
0
 def __init__(self, driver):
     self.username_field = TextField(driver,
                                     LoginPageElement.USERNAME_FIELD)
     self.password_field = TextField(driver,
                                     LoginPageElement.PASSWORD_FIELD)
     self.login_button = Button(driver, LoginPageElement.LOGIN_BUTTON)
     super(LoginPage, self).__init__(driver, self.username_field)
示例#2
0
 def __init__(self, driver):
     self.filter_button = Button(
         driver, CategoryCollectionPageElement.FILTER_BUTTON)
     self.ok_got_it_button = Button(
         driver, CategoryCollectionPageElement.OK_GOT_IT_BUTTON)
     self.dismiss_guide()
     super(CategoryCollectionPage, self).__init__(driver,
                                                  self.filter_button)
示例#3
0
 def __init__(self, driver):
     self.title = Text(driver, FilterAndSortPageElement.TITLE)
     self.sort_by_option = {
         SortBy.popular: RadioButton(driver, SortBy.popular),
         SortBy.recent: RadioButton(driver, SortBy.recent)
     }
     self.apply_button = Button(driver,
                                FilterAndSortPageElement.APPLY_BUTTON)
     super(FilterAndSortPage, self).__init__(driver, self.title)
示例#4
0
class StartupPage(BasePage):
    def __init__(self, driver):
        self.login_button = Button(driver, StartupPageElement.LOGIN_BUTTON)
        super(StartupPage, self).__init__(driver, self.login_button)

    def open_login_page(self):
        """
        Open login page.
        
        :return: PASSED or WebdriverException raised.
        """
        self.login_button.click()
示例#5
0
 def __init__(self, driver):
     self.title_field = TextField(driver, ListingDetailPageElement.TITLE_FIELD)
     self.price = TextField(driver, ListingDetailPageElement.PRICE_FIELD)
     self.new_radio_button = RadioButton(driver, ItemCondition.new)
     self.used_radio_button = RadioButton(driver, ItemCondition.used)
     self.meet_up_switch = Switch(driver, MeetUpOrDelivery.meet_up)
     self.choose_preferred_location = Button(driver, ListingDetailPageElement.PREFERRED_LOCATION)
     self.meet_up_detail_field = TextField(driver, ListingDetailPageElement.MEETUP_DETAIL_FIELD)
     self.mailing_and_delivery_switch = Switch(driver, MeetUpOrDelivery.mailing_and_delivery)
     self.mailing_detail_field = TextField(driver, ListingDetailPageElement.MAILING_DETAIL_FIELD)
     self.description_field = TextField(driver, ListingDetailPageElement.DESCRIPTION_FIELD)
     self.list_it_button = Button(driver, ListingDetailPageElement.LIST_IT_BUTTON)
     super(ListingDetailPage, self).__init__(driver, self.title_field)
示例#6
0
 def choose_photo(self, *args):
     """
     Choose photo
     
     :param args: photo index.
     :return: PASSED or WebdriverException raised.
     """
     for _, arg in enumerate(args):
         photo_element = construct_locator(PhotoPageElement.PHOTO,
                                           int(arg) + 1)
         photo = Button(self.driver, photo_element)
         photo.click()
     return PASSED
示例#7
0
class FilterAndSortPage(BasePage):
    def __init__(self, driver):
        self.title = Text(driver, FilterAndSortPageElement.TITLE)
        self.sort_by_option = {
            SortBy.popular: RadioButton(driver, SortBy.popular),
            SortBy.recent: RadioButton(driver, SortBy.recent)
        }
        self.apply_button = Button(driver,
                                   FilterAndSortPageElement.APPLY_BUTTON)
        super(FilterAndSortPage, self).__init__(driver, self.title)

    def choose_sorting_method(self, value=None):
        """
        Choose sorting method.
        
        :param value: sorting method.
        :return: PASSED or WebdriverException raised.
        """
        option = self.sort_by_option[value]
        return option.click()

    def apply(self):
        """
        Apply sort and filter.
        
        :return: PASSED or WebdriverException raised.
        """
        return self.apply_button.click()
示例#8
0
class PhotoPage(BasePage):
    def __init__(self, driver):
        photo_element = construct_locator(PhotoPageElement.PHOTO, 2)
        self.photo = Button(driver, photo_element)
        self.next_button = Button(driver, PhotoPageElement.NEXT_BUTTON)
        super(PhotoPage, self).__init__(driver, self.photo)

    def choose_photo(self, *args):
        """
        Choose photo
        
        :param args: photo index.
        :return: PASSED or WebdriverException raised.
        """
        for _, arg in enumerate(args):
            photo_element = construct_locator(PhotoPageElement.PHOTO,
                                              int(arg) + 1)
            photo = Button(self.driver, photo_element)
            photo.click()
        return PASSED

    def click_next_button(self):
        """
        Click next button.
        
        :return: PASSED or WebdriverException raised.
        """
        return self.next_button.click()
示例#9
0
class AlertPage(BasePage):
    def __init__(self, driver):
        self.ok_button = Button(driver, AlertPageElement.OK_BUTTON)
        super(AlertPage, self).__init__(driver, self.ok_button)

    def dismiss(self):
        """
        Dismiss alert.
        
        :return: PASSED or WebdriverException raised.
        """
        return self.ok_button.click()
示例#10
0
class PostListingPage(BasePage):
    def __init__(self, driver):
        self.close_button = Button(driver,
                                   SuccessListingPageElement.CLOSE_BUTTON)
        super(PostListingPage, self).__init__(driver, self.close_button)

    def click_may_be_next_time_button(self):
        """
        Click may be next time button.
        
        :return: PASSED or WebdriverException raised.
        """
        return self.close_button.click()
示例#11
0
class CollectionPage(BasePage):
    def __init__(self, driver):
        self.header = HeaderPage(driver)
        self.sell_button = Button(driver, CollectionPageElement.SELL_BUTTON)
        self.everything_else_category = Button(
            driver, CollectionPageElement.EVERYTHING_ELSE_CATEGORY)
        super(CollectionPage, self).__init__(driver, self.sell_button)

    def open_sell_form(self):
        """
        Click sell button.
        
        :return: PASSED or WebdriverException raised.
        """
        return self.sell_button.click()

    def open_everything_else_category(self):
        """
        Open 'Everything Else' category.
        
        :return: PASSED or WebdriverException raised.
        """
        return self.everything_else_category.click()
示例#12
0
 def choose_category(self, category, sub_category):
     """
     Choose category.
     
     :param category: Category.
     :param sub_category: Sub Category.
     :return: PASSED or WebdriverException raised.
     """
     category_element = construct_locator(CategoryPageElement.CATEGORY,
                                          category)
     category = Button(self.driver, category_element)
     category.click()
     sub_category_element = construct_locator(CategoryPageElement.CATEGORY,
                                              sub_category)
     sub_category = Button(self.driver, sub_category_element)
     return sub_category.click()
示例#13
0
class LoginPage(BasePage):
    def __init__(self, driver):
        self.username_field = TextField(driver,
                                        LoginPageElement.USERNAME_FIELD)
        self.password_field = TextField(driver,
                                        LoginPageElement.PASSWORD_FIELD)
        self.login_button = Button(driver, LoginPageElement.LOGIN_BUTTON)
        super(LoginPage, self).__init__(driver, self.username_field)

    def login(self, username, password):
        """
        Login.
        
        :param username: Username.
        :param password: Password.
        :return: 
        """
        self.username_field.set_text(username)
        self.password_field.set_text(password)
        return self.login_button.click()
示例#14
0
 def __init__(self, driver):
     self.close_button = Button(driver,
                                SuccessListingPageElement.CLOSE_BUTTON)
     super(PostListingPage, self).__init__(driver, self.close_button)
示例#15
0
 def __init__(self, driver):
     self.login_button = Button(driver, StartupPageElement.LOGIN_BUTTON)
     super(StartupPage, self).__init__(driver, self.login_button)
示例#16
0
 def __init__(self, driver):
     self.header = HeaderPage(driver)
     self.sell_button = Button(driver, CollectionPageElement.SELL_BUTTON)
     self.everything_else_category = Button(
         driver, CollectionPageElement.EVERYTHING_ELSE_CATEGORY)
     super(CollectionPage, self).__init__(driver, self.sell_button)
示例#17
0
class CategoryCollectionPage(BasePage):
    def __init__(self, driver):
        self.filter_button = Button(
            driver, CategoryCollectionPageElement.FILTER_BUTTON)
        self.ok_got_it_button = Button(
            driver, CategoryCollectionPageElement.OK_GOT_IT_BUTTON)
        self.dismiss_guide()
        super(CategoryCollectionPage, self).__init__(driver,
                                                     self.filter_button)

    def dismiss_guide(self):
        """
        Dismiss guide pop up.
        
        :return: PASSED or WebdriverException raised.
        """
        try:
            self.ok_got_it_button.click(timeout=1, max_swipe=0)
        except WebDriverException:
            pass

    def change_filter(self):
        """
        Open filter page.
        
        :return: PASSED or WebdriverException raised.
        """
        return self.filter_button.click()

    def listing_is_exists(self,
                          username,
                          title,
                          price,
                          description=None,
                          item_condition=None):
        """
        Verify listing is exists.
        
        :param username: Username.
        :param title: Title.
        :param price: Price.
        :param description: Description.
        :param item_condition: New or Used.
        :return: PASSED or WebdriverException raised.
        """
        self.verify_listing_detail(username, title)
        self.verify_listing_detail(username, format_currency(price))
        if description is not None:
            self.verify_listing_detail(username, description)
        if item_condition is not None:
            self.verify_listing_detail(username, item_condition)
        return PASSED

    def verify_listing_detail(self, username, expected):
        """
        Verify listing detail.
        
        :param username: Username.
        :param expected: Expected.
        :return: PASSED or WebdriverException raised.
        """
        item_detail_locator = construct_locator(
            CategoryCollectionPageElement.ITEM_DETAIL, username, expected)
        item_detail = Text(self.driver, item_detail_locator)
        item_detail.wait_for_visible()
        return PASSED
示例#18
0
 def __init__(self, driver):
     self.get_google_play_service = Button(
         driver, GetGooglePlayServiceElement.GET_GOOGLE_PLAY_SERVICE)
     super(GetGooglePlayServicePage,
           self).__init__(driver, self.get_google_play_service)
示例#19
0
 def __init__(self, driver):
     self.maybe_next_time_button = Button(
         driver, PostListingPageElement.MAYBE_NEXT_TIME_BUTTON)
     super(PostListingPage, self).__init__(driver,
                                           self.maybe_next_time_button)
示例#20
0
 def __init__(self, driver):
     self.ok_button = Button(driver, AlertPageElement.OK_BUTTON)
     super(AlertPage, self).__init__(driver, self.ok_button)
示例#21
0
 def __init__(self, driver):
     photo_element = construct_locator(PhotoPageElement.PHOTO, 2)
     self.photo = Button(driver, photo_element)
     self.next_button = Button(driver, PhotoPageElement.NEXT_BUTTON)
     super(PhotoPage, self).__init__(driver, self.photo)
示例#22
0
class ListingDetailPage(BasePage):

    def __init__(self, driver):
        self.title_field = TextField(driver, ListingDetailPageElement.TITLE_FIELD)
        self.price = TextField(driver, ListingDetailPageElement.PRICE_FIELD)
        self.new_radio_button = RadioButton(driver, ItemCondition.new)
        self.used_radio_button = RadioButton(driver, ItemCondition.used)
        self.meet_up_switch = Switch(driver, MeetUpOrDelivery.meet_up)
        self.choose_preferred_location = Button(driver, ListingDetailPageElement.PREFERRED_LOCATION)
        self.meet_up_detail_field = TextField(driver, ListingDetailPageElement.MEETUP_DETAIL_FIELD)
        self.mailing_and_delivery_switch = Switch(driver, MeetUpOrDelivery.mailing_and_delivery)
        self.mailing_detail_field = TextField(driver, ListingDetailPageElement.MAILING_DETAIL_FIELD)
        self.description_field = TextField(driver, ListingDetailPageElement.DESCRIPTION_FIELD)
        self.list_it_button = Button(driver, ListingDetailPageElement.LIST_IT_BUTTON)
        super(ListingDetailPage, self).__init__(driver, self.title_field)

    def fill_out_form(self, title=None, price=None, item_condition=None, meet_up=False,
                      preferred_location=None, meet_up_detail=None, mailing_and_delivery=False,
                      mailing_detail=None, description=None):
        """
        Fill out listing form.
        
        :param title: Title.
        :param price: Price.
        :param item_condition: Item condition.
        :param meet_up: Met_up.
        :param preferred_location: Preferred location.
        :param meet_up_detail: meet up detail.
        :param mailing_and_delivery: Mailing and delivery.
        :param mailing_detail: Mailing detail.
        :param description: Description.
        :return: 
        """
        if title is not None:
            self.title_field.set_text(title)
        if price is not None:
            self.price.set_text(price)
        if item_condition is not None:
            self.choose_item_condition(item_condition)
        if meet_up:
            self.meet_up_switch.click()
            self.fill_out_meet_up_detail(preferred_location, meet_up_detail)
        if mailing_and_delivery:
            self.mailing_and_delivery_switch.click()
            self.fill_out_mailing_detail(mailing_detail)
        if description is not None:
            self.description_field.set_text(description)
        return PASSED

    def choose_item_condition(self, value):
        """
        Choose item condition.
        
        :param value: value.
        :return: 
        """
        if value == ItemCondition.new:
            return self.new_radio_button.click()
        if value == ItemCondition.used:
            return self.used_radio_button.click()
        else:
            raise WebDriverException('Invalid value {0}'.format(value))

    def fill_out_meet_up_detail(self, preferred_location=None, meet_up_detail=None):
        """
        Fill out meet up detail.
        
        :param preferred_location: 
        :param meet_up_detail: 
        :return: 
        """
        if preferred_location is not None:
            pass
        if meet_up_detail is not None:
            return self.meet_up_detail_field.set_text(meet_up_detail)

    def fill_out_mailing_detail(self, mailing_detail=None):
        """
        Fill out mailing detail.
        
        :param mailing_detail: 
        :return: 
        """
        if mailing_detail is not None:
            return self.mailing_detail_field.set_text(mailing_detail)

    def click_list_it_button(self):
        """
        Click list it button.
        
        :return: 
        """
        return self.list_it_button.click()