コード例 #1
0
 class SimplePage(Page):
     el_list = Elements(Locators.CLASS_NAME, "element")
     el_list_wait = Elements(Locators.CLASS_NAME, "elements", timeout=1)
     el_list_only_if = Elements(Locators.CLASS_NAME,
                                "elements",
                                timeout=1,
                                only_if=lambda els: len(els) == 1)
コード例 #2
0
class SauceDemoTest(Page):
    """
    This class is use for defining all the page source objects.
    Args : Page
    """
    user_name_input = Element(Locators.ID,
                              form_pageobjects.USER_NAME,
                              only_if=conditions.VISIBLE(),
                              timeout=60)
    password_input = Element(Locators.ID,
                             form_pageobjects.PASSWORD,
                             only_if=conditions.VISIBLE(),
                             timeout=60)
    login_button = Element(Locators.ID,
                           form_pageobjects.LOGIN_BUTTON,
                           only_if=conditions.VISIBLE(),
                           timeout=60)
    product_label = Element(Locators.CSS_SELECTOR,
                            form_pageobjects.PRODUCT_LABEL,
                            only_if=conditions.VISIBLE(),
                            timeout=60)
    product_list = Elements(Locators.CSS_SELECTOR,
                            form_pageobjects.PRODUCTS_LIST,
                            only_if=lambda el: el[0].is_displayed(),
                            timeout=60)
    product_info_label = Element(Locators.CSS_SELECTOR,
                                 form_pageobjects.PRODUCT_INFO_LABEL,
                                 only_if=conditions.VISIBLE(),
                                 timeout=60)
    product_cart_list = Elements(Locators.CSS_SELECTOR,
                                 form_pageobjects.PRODUCT_CART_LIST,
                                 only_if=lambda el: el[0].is_displayed(),
                                 timeout=60)
    cart = Element(Locators.CSS_SELECTOR,
                   form_pageobjects.CART,
                   only_if=conditions.VISIBLE(),
                   timeout=60)
    cart_items = Elements(Locators.CSS_SELECTOR,
                          form_pageobjects.CART_ITEMS,
                          only_if=lambda el: el[0].is_displayed(),
                          timeout=60)
    remote_items = Elements(Locators.CSS_SELECTOR,
                            form_pageobjects.REMOVE_ITEMS,
                            only_if=lambda el: el[0].is_displayed(),
                            timeout=60)
    menu_button = Element(Locators.CSS_SELECTOR,
                          form_pageobjects.MENU,
                          only_if=conditions.VISIBLE(),
                          timeout=60)
    logout_user = Element(Locators.ID,
                          form_pageobjects.LOGOUT,
                          only_if=conditions.VISIBLE(),
                          timeout=60)
コード例 #3
0
 class SimplePage(Page):
     el_list_default = Elements(Locators.CLASS_NAME, "simple_class")
     el_list_valuemapper = Elements(
         Locators.CLASS_NAME,
         "simple_class",
         value=lambda el: el.find_element_by_tag_name("a").text)
     el_list_valuemapper_complex = Elements(
         Locators.CLASS_NAME,
         "simple_class",
         value=lambda el: {
             "link": el.find_element_by_tag_name("a").get_attribute(
                 "href"),
             "text": el.find_element_by_tag_name("a").text
         })
     first_el = Element(Locators.TAG_NAME,
                        "a",
                        base_element=el_list_default[0])
コード例 #4
0
 class ExhaustivePage(Page):
     element = Element(Locators.NAME, "e1")
     element_invalid = Element(Locators.NAME, "3e")
     elements = Elements(Locators.NAME, "e2")
     elements_invalid = Elements(Locators.NAME, "3e")
     elementmap = ElementMap(Locators.NAME, "e3")
     elementmap_for_ref = ElementMap(Locators.NAME, "e2")
     elementmap_invalid = ElementMap(Locators.NAME, "3e")
     elementmap_raw = {
         "e4": Element(Locators.NAME, "e4"),
         "e2": Elements(Locators.NAME, "e2"),
         "e3": ElementMap(Locators.NAME, "e3")
     }
     elements_raw = [
         Element(Locators.NAME, "e4"),
         Elements(Locators.NAME, "e2"),
         ElementMap(Locators.NAME, "e3")
     ]
     element_list_raw = [
         Element(Locators.NAME, "e4"),
         Element(Locators.NAME, "e6")
     ]
     element_map_raw = {
         "e4": Element(Locators.NAME, "e4"),
         "e6": Element(Locators.NAME, "e6")
     }
     element_second = Element(Locators.NAME, "e2")
     element_ref = Element(
         Locators.NAME, "e6", base_element=elements[0]
     )
     element_map_ref = Element(
         Locators.NAME, "e6",
         base_element=elementmap_for_ref["e2 - 1\ne6"]
     )
     element_ref_direct = Element(
         Locators.NAME, "e6", base_element=element_second
     )
     element_ref_webelement = Element(
         Locators.NAME, "e6", base_element=web_element
     )
     element_ref_invalid = Element(
         Locators.NAME, "e6", base_element=42
     )
コード例 #5
0
ファイル: pages.py プロジェクト: sajnikanth/holmium.core
class GoogleMain(Page):
    search_box = Element( Locators.NAME, "q", timeout = 1)
    google_buttons = ElementMap ( Locators.CLASS_NAME, "gbts" , timeout = 1 )
    search_results = Elements( Locators.CSS_SELECTOR, "li.g>div.rc", timeout = 1, value = lambda el : {
        "link":el.find_element_by_css_selector("h3.r>a").get_attribute("href"),
        "title":el.find_element_by_css_selector("h3.r>a").text
        })

    def search ( self, query ):
        self.google_buttons["Search"].click() # self.google_buttons behaves just like a dictionary
        self.search_box.clear() # self.search_box is now evaluated directly to a WebElement
        self.search_box.send_keys(query)
        self.search_box.submit()
コード例 #6
0
ファイル: steps.py プロジェクト: zehua/holmium.core
class TestPage(Page):
    el = Element(Locators.NAME, "el")
    els = Elements(Locators.NAME, "els")
    elmap = ElementMap(Locators.NAME, "elmap")
    sections = TestSections(Locators.NAME, "sections")
    section  = TestSection(Locators.NAME, "section")
    def do_stuff(self, a, b):
        return a+b

    def do_stuff_no_args(self):
        return True

    def do_stuff_var_args(self, *args, **kwargs):
        return args, kwargs
コード例 #7
0
class GoogleMain(Page):
    search_box = Element(Locators.NAME, "q", timeout=2)
    search_results = Elements(
        Locators.CSS_SELECTOR, "div.rc", timeout=2,
        value=lambda el: {
            "link": el.find_element_by_css_selector(
                "div.r>a"
            ).get_attribute("href"),
            "title": el.find_element_by_css_selector("div.r>a>h3").text
        }
    )

    def search(self, query):
        self.search_box.clear()
        self.search_box.send_keys(query)
        self.search_box.submit()
コード例 #8
0
 class P(Page):
     e = Element(Locators.CLASS_NAME, "el")
     es = Elements(Locators.CLASS_NAME, "el")
     em = ElementMap(Locators.CLASS_NAME, "el")
コード例 #9
0
class TestSection(Section):
    el = Element(Locators.NAME, "el")
    els = Elements(Locators.NAME, "els")
    elmap = ElementMap(Locators.NAME, "elmap")
コード例 #10
0
ファイル: facet_tests.py プロジェクト: zehua/holmium.core
class BadNavSection(Section):
    links = Elements(Locators.CSS_SELECTOR, "ul>bi", facet=True)
コード例 #11
0
ファイル: facet_tests.py プロジェクト: zehua/holmium.core
class BadNavSectionStrictDebug(Section):
    links = Elements(Locators.CSS_SELECTOR, "ul>li")
    junk = Element(Locators.CLASS_NAME, "junk")
コード例 #12
0
ファイル: iframe_tests.py プロジェクト: kejkz/holmium.core
class BasicPageIframe(Page):
    element = Element(Locators.CLASS_NAME, "frame_el")
    elements = Elements(Locators.CLASS_NAME, "frame_el")
    frame_1 = BasicSectionIframe(Locators.CLASS_NAME, "section", "frame_1")
    frame_2 = BasicSectionIframe(Locators.CLASS_NAME, "section", "frame_2")
コード例 #13
0
class BasicSection(Section):
    tokens = Elements(Locators.CSS_SELECTOR, "div.token")
コード例 #14
0
class BasicPage(Page):
    section = BasicSection(Locators.ID, "section")
    section_2 = BasicSection(Locators.ID, "section_2")
    tokens = Elements(Locators.CLASS_NAME, "token")
コード例 #15
0
 class SimplePage(Page):
     el_list_filter_by = Elements(
         Locators.CLASS_NAME,
         "elements",
         filter_by=lambda el: el.text != "element_text")
コード例 #16
0
 class P(Page):
     e = Elements(Locators.CLASS_NAME,
                  "stale",
                  timeout=1,
                  only_if=lambda els: rem() or any(e.is_displayed()
                                                   for e in els))
コード例 #17
0
ファイル: facet_tests.py プロジェクト: zehua/holmium.core
class NavSection(Section):
    links = Elements(Locators.CSS_SELECTOR, "ul>li")