Ejemplo n.º 1
0
def should_not_see_id(step, element_id):
    try:
        elem = world.browser.find_element_by_xpath(str('id("%s")' %
                                                   element_id))
        assert_true(step, not elem.is_displayed())
    except NoSuchElementException:
        pass
Ejemplo n.º 2
0
def select_multi_items(step, selectId):
    with AssertContextManager(step):
    	# show dropdown
    	dd = world.browser.find_element_by_xpath(
    		str('(//fieldset[@class="propertyType"]//img[@class="LMIDDArrow"])[2]')
    	)
    	dd.click()
    	time.sleep(5)
    	# parse desired options
        options = step.multiline.split('\n')
        # make sure dropdown is present
        dropdown = world.browser.find_element_by_id(selectId)
        assert_true(step, dropdown)
        # clear before selecting
        clear = world.browser.find_element_by_link_text("clear all")
        clear.click()

        for opt in options:
            try:
                world.browser.find_element_by_xpath(
                	str('//div[@id="'+selectId+'"]//input[@value="'+opt+'"]')
                ).click()
            except NoSuchElementException:
                print "\tERROR: no such option in "+selectId+" dropdown"
                return False
Ejemplo n.º 3
0
def wait_for_content(step, browser, content, timeout=15):
    start = time.time()
    while time.time() - start < timeout:
        if content in world.browser.page_source:
            return
        time.sleep(0.2)
    assert_true(step, content in world.browser.page_source)
Ejemplo n.º 4
0
def check_fields_class_by_css(step):
    with AssertContextManager(step):
        assert_true(step, "text-red" in bo.get_grouped_column_css(world.browser, "Group1"))
        assert_true(step, "text-blue" in bo.get_grouped_column_css(world.browser, "Activity"))
        assert_true(step, "bg-gray" in bo.get_grouped_column_css(world.browser, "Activity"))
        assert_true(step, "text-blue" in bo.get_grouped_column_css(world.browser, "status"))
        assert_true(step, "bg-lightgray" in bo.get_grouped_column_css(world.browser, "status"))
Ejemplo n.º 5
0
def get_reorder_indicator(step, pixel):
    with AssertContextManager(step):
        style = world.browser.execute_script(
            "return $('.ember-table-column-sortable-indicator.active').attr(\"style\")")
        indicator = str(style).split("left:")[1].split("px")[0].strip()

        assert_true(step, int(indicator) == int(pixel))
Ejemplo n.º 6
0
def should_not_see_id(step, element_id):
    try:
        elem = world.browser.find_element_by_xpath(str('id("%s")' %
                                                       element_id))
        assert_true(step, not elem.is_displayed())
    except NoSuchElementException:
        pass
def wait_for_content(step, browser, content, timeout=15):
    start = time.time()
    while time.time() - start < timeout:
        if contains_content(world.browser, content):
            return
        time.sleep(0.2)
    assert_true(step, contains_content(world.browser, content))
Ejemplo n.º 8
0
def wait_for_content(step, browser, content, timeout=15):
    start = time.time()
    while time.time() - start < timeout:
        if contains_content(world.browser, content):
            return
        time.sleep(0.2)
    assert_true(step, contains_content(world.browser, content))
Ejemplo n.º 9
0
def wait_for_content(step, browser, content, timeout=15):
    start = time.time()
    while time.time() - start < timeout:
        if content in world.browser.page_source:
            return
        time.sleep(0.2)
    assert_true(step, content in world.browser.page_source)
 def test_raise_assertion(self):
     self.stub.will_return_after_timeout()
     try:
         self.stub.decodated_method(PING)
         assert_true(False, "should raise Assertion Error")
     except AssertionError as e:
         assert_equal(ASSERTION_ERROR, e.__str__())
     assert_equal(CALL_WITH_TIMEOUT, self.stub.calls_counter, "Should call only %s time(s)" % CALL_WITH_TIMEOUT)
Ejemplo n.º 11
0
def createSgClient(step):
	world.sgc = sendgrid.SendGridClient(world.username, world.password)
	# established sendgrid client
	assert_true(step, world.sgc.host == 'https://api.sendgrid.com')
	assert_true(step, world.sgc.port == '443')
	assert_true(step, world.sgc.endpoint == '/api/mail.send.json')
	assert_true(step, world.sgc.username == world.username)
	assert_true(step, world.sgc.password == world.password)
Ejemplo n.º 12
0
def check_grouped_row_wrap(step, col_name):
    with AssertContextManager(step):
        indicator_offset = world.browser.execute_script(
            "return $('.grouping-column-cell .ember-table-content:contains(" + col_name + ")').siblings().eq(1).offset().left")
        name_offset = world.browser.execute_script(
            "return $('.grouping-column-cell .ember-table-content:contains(" + col_name + ")').offset().left")

        assert_true(step, int(indicator_offset) < int(name_offset))
Ejemplo n.º 13
0
def check_column_is_fixed(step, col_name):
    with AssertContextManager(step):
        col_names = world.browser.execute_script(
            "return $('.ember-table-table-fixed-wrapper > div:eq(0) span').text()")
        if str(col_name) == "GroupingColumn":
            assert_true(step, str("") in str(col_names))
        else:
            assert_true(step, str(col_name) in str(col_names))
Ejemplo n.º 14
0
def check_row_indicator(step, row_name, indicator):
    with AssertContextManager(step):
        row = world.browser.execute_script(
            "return $('.ember-table-content:contains(" + str(row_name) + ")').siblings()")
        if indicator == "expand":
            assert_true(step, ("unfold" not in row[0].get_attribute("class")) and is_the_row_custom(row_name))
        else:
            assert_true(step, ("unfold" in row[0].get_attribute("class")) and is_the_row_custom(row_name))
Ejemplo n.º 15
0
def element_focused(step, id):
    """
    Check if the element is focused
    """

    elem = world.browser.find_element_by_xpath(str('id("{id}")'.format(id=id)))
    focused = world.browser.switch_to_active_element()

    assert_true(step, elem == focused)
def select_by_selector(step, selector):
    option = find_element_by_jquery(step, world.browser, selector)
    selectors = find_parents_by_jquery(world.browser, selector)
    assert_true(step, len(selectors) > 0)
    selector = selectors[0]
    selector.click()
    time.sleep(0.3)
    option.click()
    assert_true(step, option.is_selected())
Ejemplo n.º 17
0
def no_see_tooltip(step, tooltip):
    """
    Press a button having a given tooltip.
    """
    elem = world.browser.find_elements_by_xpath(
        str('//*[@title="%(tooltip)s" or @data-original-title="%(tooltip)s"]' % dict(tooltip=tooltip))
    )
    elem = [e for e in elem if e.is_displayed()]
    assert_true(step, not elem)
Ejemplo n.º 18
0
def check_loaded_chunk(step, num):
    with AssertContextManager(step):
        get_url(world.browser, "http://localhost:4200/lazy-loaded-loans?totalCount=" + str(num))
        text = requests.get("http://localhost:2525/imposters/8888").json()
        dump_text = json.dumps(text)
        to_json = json.loads(dump_text)['requests']

        assert_true(step, len(to_json) == 1)
        assert_true(step, to_json[0]['query']['section'] == "1")
Ejemplo n.º 19
0
def element_focused(step, id):
    """
    Check if the element is focused
    """

    elem = world.browser.find_element_by_xpath(str('id("{id}")'.format(id=id)))
    focused = world.browser.switch_to_active_element()

    assert_true(step, elem == focused)
def select_by_selector(step, selector):
    option = find_element_by_jquery(step, world.browser, selector)
    selectors = find_parents_by_jquery(world.browser, selector)
    assert_true(step, len(selectors) > 0)
    selector = selectors[0]
    selector.click()
    sleep(0.3)
    option.click()
    assert_true(step, option.is_selected())
Ejemplo n.º 21
0
def no_see_tooltip(step, tooltip):
    """
    Press a button having a given tooltip.
    """
    elem = world.browser.find_elements_by_xpath(
        str('//*[@title="%(tooltip)s" or @data-original-title="%(tooltip)s"]' %
            dict(tooltip=tooltip)))
    elem = [e for e in elem if e.is_displayed()]
    assert_true(step, not elem)
 def test_raise_timeout(self):
     self.stub.will_return_after_first_call()
     self.stub.will_execute_one_call_longer_than_timeout()
     try:
         self.stub.decodated_method(PING)
         assert_true(False, "should raise Timeout Error")
     except TimeoutError as e:
         assert_equal(TIMEOUT_OCCURRED, e.__str__())
     assert_equal(FIRST_CALL, self.stub.calls_counter, "Should call only %s time(s)" % FIRST_CALL)
Ejemplo n.º 23
0
def verify_cell_content(row_index, name, value):
    col_index, is_fixed = find_col_index(name)
    block_selector = '.ember-table-right-table-block'
    if is_fixed:
        block_selector = '.ember-table-left-table-block'

    col_value = world.browser.execute_script(
        "return $('.ember-table-body-container " + block_selector + " .ember-table-table-row:eq(" + str(row_index) +
        ") .ember-table-cell:eq(" + str(col_index) + ") span').text().trim()")
    assert_true(step, str(col_value) == str(value))
Ejemplo n.º 24
0
def check_sort_indicator(step, column_name, sort):
    with AssertContextManager(step):
        class_content = world.browser.execute_script(
            "return $('.ember-table-header-container .ember-table-content:contains(" + column_name + ")').parent().parent().attr(\'class\')")
        options = {"none": "",
                   "asc": "sort-indicator-icon sort-indicator-icon-up",
                   "desc": "sort-indicator-icon sort-indicator-icon-down", }
        if options.get(sort) == "none":
            assert_true(step, "sort-indicator-icon" not in class_content)
        assert_true(step, options.get(sort) in class_content)
Ejemplo n.º 25
0
def check_header_scroll_left(step, name):
    with AssertContextManager(step):
        start = time.time()
        flag = False
        while time.time() - start < 20:
            if int(bo.get_head_block_scroll_left(world.browser)) == int(bo.get_body_scroll_left(world.browser)):
                flag = flag or True
                break
            time.sleep(0.2)
        assert_true(step, flag)
Ejemplo n.º 26
0
def drag_element_offset(step, className, index, rightOrLeft, offsetx):
    with AssertContextManager(step):
        originalWidth = bo.get_column_width_by_class_name(world.browser, index)
        drag_element_by_offset_class_name(world.browser, className, index, rightOrLeft, offsetx)
        changedWidth = bo.get_column_width_by_class_name(world.browser, index)

        if str(rightOrLeft) == "left":
            assert_true(step, (int(changedWidth) - int(originalWidth)) == (-int(offsetx) - int(spanWidthPix)))
        else:
            assert_true(step, (int(changedWidth) - int(originalWidth)) == (int(offsetx) - int(spanWidthPix)))
Ejemplo n.º 27
0
 def placeholder_contains(self, step, element_id, value):
     """
     Check that the element identified but the given id
     contains the placeholder given.
     :param step: current Lettuce step.
     :param id_element: id of the element to be checked.
     :param value: expected placeholder of the element to be checked.
     """
     elem = world.browser.find_element_by_xpath('//*[@id="%s"]' %
                                                element_id)
     assert_true(step, value in elem.get_attribute('placeholder'))
Ejemplo n.º 28
0
def checkResults(step, location):
	results = world.browser.find_elements_by_xpath("//div[@id='searchResultsTbl']//div[@class='vcard']//a")
	for title in results:
		try:
			assert_true(step, title.text.index(location) > -1)
		except ValueError:
			print "\tNote: found a result with location cut-off: '" + title.text + "'"
			print "\tChecking for partial match ..."
			keywords = [x.lstrip() for x in location.split(',')]
			confirmed = filter(lambda x: x in title.text, keywords)
			assert_true(step, len(confirmed) > 0)
			print "\tMatch found for search keyword '" + ", ".join(confirmed) + "'"
Ejemplo n.º 29
0
def check_grouping_column_should_not_scroll(step, column_name):
    with AssertContextManager(step):
        columns = world.browser.execute_script(
            "return $('.ember-table-header-container .ember-table-content').parent().parent()")
        for index, col in enumerate(columns):
            name = world.browser.execute_script(
                "return $('.ember-table-header-container .ember-table-content:eq(" + str(index) + ")').text().trim()")
            if name == column_name:
                num = index
        grouping_column_scroll_left = world.browser.execute_script(
            "return $('.lazy-list-container:eq(" + str(num) + ")').scrollLeft()")

        assert_true(step, int(grouping_column_scroll_left) == 0)
Ejemplo n.º 30
0
def fill_in_textfield(step, field_name, value):
    with AssertContextManager(step):
        date_field = find_any_field(world.browser, DATE_FIELDS, field_name)
        if date_field:
            field = date_field
        else:
            field = find_any_field(world.browser, TEXT_FIELDS, field_name)

        assert_true(step, field, 'Can not find a field named "%s"' % field_name)
        if date_field:
            field.send_keys(Keys.DELETE)
        else:
            field.clear()
        field.send_keys(value)
Ejemplo n.º 31
0
def assert_multi_selected(step, select_name):
    with AssertContextManager(step):
        # Ensure its not selected unless its one of our options
        option_names = step.multiline.split('\n')
        select_box = find_field(world.browser, 'select', select_name)
        option_elems = select_box.find_elements_by_xpath(str('./option'))
        for option in option_elems:
            if option.get_attribute('id') in option_names or \
               option.get_attribute('name') in option_names or \
               option.get_attribute('value') in option_names or \
               option.text in option_names:
                assert_true(step, option.is_selected())
            else:
                assert_true(step, not option.is_selected())
Ejemplo n.º 32
0
def get_column_cursor(step, column_name):
    with AssertContextManager(step):
        cursor_css = "body.ember-application"

        action_chains = ActionChains(world.browser)
        element = world.browser.execute_script(
            "return $('.ember-table-header-container .ember-table-content:contains(" + column_name + ")').parent().parent().children()[1]")
        action_chains.drag_and_drop_by_offset(element, 10, 0).release().perform()

        cursor = find_elements_by_css(world.browser, cursor_css)
        style = cursor[0].get_attribute("style")
        assert_true(step, ("auto" in style) or ("resize" in style) or ("pointer" in style))
        action_chains.release()
        world.browser.refresh()
Ejemplo n.º 33
0
def assert_multi_selected(step, select_name):
    with AssertContextManager(step):
        # Ensure its not selected unless its one of our options
        option_names = step.multiline.split('\n')
        select_box = find_field(world.browser, 'select', select_name)
        option_elems = select_box.find_elements_by_xpath('./option')
        for option in option_elems:
            if option.get_attribute('id') in option_names or \
               option.get_attribute('name') in option_names or \
               option.get_attribute('value') in option_names or \
               option.text in option_names:
                assert_true(step, option.is_selected())
            else:
                assert_true(step, not option.is_selected())
Ejemplo n.º 34
0
def fill_in_textfield(step, field_name, value):
    with AssertContextManager(step):
        date_field = find_any_field(world.browser, DATE_FIELDS, field_name)
        if date_field:
            field = date_field
        else:
            field = find_any_field(world.browser, TEXT_FIELDS, field_name)

        assert_true(step, field,
                    'Can not find a field named "%s"' % field_name)
        if date_field:
            field.send_keys(Keys.DELETE)
        else:
            field.clear()
        field.send_keys(value)
Ejemplo n.º 35
0
def assert_multi_selected(step, select_name):
    with AssertContextManager(step):
        # Ensure its not selected unless its one of our options
        option_names = step.multiline.split("\n")
        select_box = find_field(world.browser, "select", select_name)
        option_elems = select_box.find_elements_by_xpath("./option")
        for option in option_elems:
            if (
                option.get_attribute("id") in option_names
                or option.get_attribute("name") in option_names
                or option.get_attribute("value") in option_names
                or option.text in option_names
            ):
                assert_true(step, option.is_selected())
            else:
                assert_true(step, not option.is_selected())
Ejemplo n.º 36
0
def then_page_title_should_be(step, text):
    try:
        WebDriverWait(world.driver, 120).until(EC.title_contains(text))
        assert_true(step, text in world.driver.title)
        assert_true(step, world.driver.find_element_by_id("id_username"))
        assert_true(step, world.driver.find_element_by_id("id_password"))
    finally:
        world.driver.quit()
Ejemplo n.º 37
0
def check_row_indicator(step, index, indicator):
    with AssertContextManager(step):
        if indicator == 'collapse':
            assert_true(step, is_the_row_expanded(index))
        elif indicator == 'expand':
            assert_true(step, (not is_the_row_expanded(index)) and (not is_the_leaf_node(index)))
        else:
            assert_true(step, is_the_leaf_node(index))
Ejemplo n.º 38
0
def then_page_title_should_be(step, text):
    try:
        WebDriverWait(world.driver, 120).until(EC.title_contains(text))
        assert_true(step, text in world.driver.title)
        assert_true(step, world.driver.find_element_by_id("id_username"))
        assert_true(step, world.driver.find_element_by_id("id_password"))
    finally:
        world.driver.quit()
Ejemplo n.º 39
0
def checkResponse(step, result, message):
	if result == "success":
		print "\tRESPONSE: " + world.response + " | CODE: " + str(world.status)
		assert_true(step, world.status == 200 and "success" in world.response)
	else:
		print "\tRESPONSE: " + world.response + " | CODE: " + str(world.status)
		assert_true(step, world.status == 400 and "error" in world.response)
		# check message for error
		assert_true(step, message in world.response)
Ejemplo n.º 40
0
def check_sort_column(step, record_index, record_content):
    with AssertContextManager(step):
        if record_index == "first":
            result = bo.get_record_content(world.browser, 0)
            assert_true(step, str(result) == record_content)
        elif record_index == "last":
            result = bo.get_record_content(world.browser, 1)
            assert_true(step, str(result) == record_content)
        else:
            result = bo.get_record_content(world.browser, 3)
            assert_true(step, str(result) == record_content)
Ejemplo n.º 41
0
def verify_grouped_row(index, row):
    indicator = row['indicator']
    if indicator == '-':
        assert_true(step, is_the_row_expanded(index))
    elif indicator == '+':
        assert_true(step, not is_the_row_expanded(index))
    elif indicator == '':
        assert_true(step, is_the_leaf_node(index))

    for field in row:
        if field != 'indicator':
            verify_cell_content(index, field, row[field])
Ejemplo n.º 42
0
def check_column_width(step, column_name, pixel):
    with AssertContextManager(step):
        if str(column_name) == "GroupingColumn":
            assert_true(step, int(bo.get_col_width_by_index(world.browser, 0)) == int(pixel))
        else:
            assert_true(step, int(bo.get_col_width(world.browser, column_name)) == int(pixel))
Ejemplo n.º 43
0
def check_reorder_column(step, index, name):
    with AssertContextManager(step):
        if name == "GroupingColumn":
            assert_true(step, bo.get_col_name_by_index(world.browser, index) == "")
        else:
            assert_true(step, bo.get_col_name_by_index(world.browser, index) == name)
Ejemplo n.º 44
0
def check_grouping_fixed_num(step, num):
    with AssertContextManager(step):
        grouping_fixed_col_num = world.browser.execute_script(
            "return $('.ember-table-table-fixed-wrapper > div:eq(0) span').length")
        assert_true(step, int(num) == int(grouping_fixed_col_num))
Ejemplo n.º 45
0
def check_grouping_fixed_should_not_scroll(step):
    with AssertContextManager(step):
        grouping_fixed_scroll_left = world.browser.execute_script(
            "return $('.lazy-list-container:eq(0)').scrollLeft()")
        assert_true(step, int(grouping_fixed_scroll_left) == 0)
Ejemplo n.º 46
0
def check_columns_numbers(step, num):
    with AssertContextManager(step):
        col_count = world.browser.execute_script(
            "return $('.ember-table-content-container .ember-table-content').length")
        assert_true(step, int(col_count) == int(num))