Пример #1
0
def test(data):
    actions.navigate(data.env.url + 'elements/')
    checkbox = ('id', 'unselected-checkbox')
    actions.click(checkbox)
    actions.assert_element_checked(checkbox)
    actions.refresh_page()
    golem_steps.assert_last_step_message('Refresh page')
    actions.assert_element_not_checked(checkbox)
Пример #2
0
def test(data):
    actions.navigate(data.env.url + 'special-elements/')
    actions.verify_page_contains_text('Special Elements')
    golem_steps.assert_last_step_message(
        "Verify 'Special Elements' is present in the page")
    actions.verify_page_contains_text('THIS TEXT IS NOT PRESENT')
    golem_steps.assert_last_error(
        "text 'THIS TEXT IS NOT PRESENT' not found in the page")
def test(data):
    actions.navigate(data.env.url + 'elements/')
    actions.verify_element_has_attribute('#button-one', 'onclick')
    golem_steps.assert_last_step_message(
        'Verify element #button-one has attribute onclick')
    actions.verify_element_has_attribute('#button-one', 'not-this-one')
    golem_steps.assert_last_error(
        'element #button-one does not have attribute not-this-one')
Пример #4
0
def test(data):
    actions.navigate(data.env.url + 'alert/')
    actions.verify_alert_present()
    golem_steps.assert_last_step_message('Verify an alert is present')
    golem_steps.assert_last_error('an alert was not present')
    actions.click('#alert-button')
    actions.verify_alert_present()
    actions.dismiss_alert()
Пример #5
0
def test(data):
    actions.navigate(data.env.url + 'elements/')
    actions.assert_element_has_not_focus('#input-one')
    golem_steps.assert_last_step_message(
        'Assert element #input-one does not have focus')
    actions.focus_element('#input-one')
    with expected_exception(AssertionError, 'element #input-one has focus'):
        actions.assert_element_has_not_focus('#input-one')
Пример #6
0
def test(data):
    actions.navigate(data.env.url + 'elements/')
    actions.verify_element_text_contains('#link1', 'this is a link')
    golem_steps.assert_last_step_message(
        "Verify element #link1 contains text 'this is a link'")
    actions.verify_element_text_contains('#link1', 'not-contained')
    exp = "expected element #link1 text 'this is a link to index' to contain 'not-contained'"
    golem_steps.assert_last_error(exp)
Пример #7
0
def test_assert_element_has_not_attribute(data):
    actions.navigate(data.env.url + 'elements/')
    actions.assert_element_has_not_attribute('#button-one', 'not-this-one')
    golem_steps.assert_last_step_message(
        'Assert element #button-one has not attribute not-this-one')
    with expected_exception(AssertionError,
                            'element #button-one has attribute onclick'):
        actions.assert_element_has_not_attribute('#button-one', 'onclick')
Пример #8
0
def test(data):
    actions.navigate(data.env.url + 'elements/')
    actions.assert_element_text_is_not('#link1', 'incorrect text')
    golem_steps.assert_last_step_message(
        "Assert element #link1 text is not 'incorrect text'")
    msg = "expected element #link1 text to not be 'this is a link to index'"
    with expected_exception(AssertionError, msg):
        actions.assert_element_text_is_not('#link1', 'this is a link to index')
Пример #9
0
def test(data):
    url = data.env.url + 'elements/'
    actions.navigate(url)
    actions.verify_url_contains('elements')
    golem_steps.assert_last_step_message("Verify URL contains 'elements'")
    actions.verify_url_contains('incorrect-partial-url')
    msg = "expected URL '{}' to contain 'incorrect-partial-url'".format(url)
    golem_steps.assert_last_error(msg)
Пример #10
0
def test_dismiss_alert(data):
    actions.navigate(data.env.url+'alert/')
    actions.click('#alert-button')
    actions.verify_alert_present()
    actions.dismiss_alert()
    golem_steps.assert_last_step_message('Dismiss alert')
    actions.verify_alert_not_present()
    actions.verify_element_text('#result', '1')
def test(data):
    actions.navigate(data.env.url + 'elements/')
    actions.verify_element_text_is_not('#link1', 'incorrect text')
    golem_steps.assert_last_step_message(
        "Verify element #link1 text is not 'incorrect text'")
    actions.verify_element_text_is_not('#link1', 'this is a link to index')
    golem_steps.assert_last_error(
        "expected element #link1 text to not be 'this is a link to index'")
def test(data):
    actions.navigate(data.env.url + 'elements/')
    actions.verify_element_attribute('#input-one', 'class', 'form-control')
    expected = "Verify element #input-one attribute class value is 'form-control'"
    golem_steps.assert_last_step_message(expected)
    actions.verify_element_attribute('#input-one', 'class', 'incorrect')
    expected = "expected element #input-one attribute class to be 'incorrect' but was 'form-control'"
    golem_steps.assert_last_error(expected)
Пример #13
0
def test(data):
    actions.navigate('https://google.com')
    actions.add_cookie({'name': 'foo', 'value': 'bar'})
    actions.add_cookie({'name': 'baz', 'value': 'qux'})
    actions.delete_all_cookies()
    golem_steps.assert_last_step_message('Delete all cookies')
    assert actions.get_cookie('foo') is None
    assert actions.get_cookie('baz') is None
Пример #14
0
def test(data):
    actions.navigate(data.env.url)
    actions.add_cookie({'name': 'foo', 'value': 'bar'})
    actions.verify_cookie_value('foo', 'bar')
    golem_steps.assert_last_step_message(
        "Verify that cookie 'foo' value is 'bar'")
    actions.verify_cookie_value('foo', 'baz')
    expected = "Expected cookie 'foo' value to be 'baz' but was 'bar'"
    golem_steps.assert_last_error(expected)
Пример #15
0
def test(data):
    actions.navigate(data.env.url+'elements/')
    actions.focus_element('#input-one')
    actions.verify_element_has_focus('#input-one')
    golem_steps.assert_last_step_message('Verify element #input-one has focus')
    actions.focus_element('#textarea-1')
    actions.verify_element_has_focus('#textarea-1')
    actions.verify_element_has_focus('#input-one')
    golem_steps.assert_last_error('element #input-one does not have focus')
Пример #16
0
def test(data):
    actions.navigate(data.env.url + 'elements/')
    actions.assert_element_attribute('#button-one', 'id', 'button-one')
    expected = "Assert element #button-one attribute id value is 'button-one'"
    golem_steps.assert_last_step_message(expected)
    msg = ("expected element #button-one attribute id "
           "value to be 'not-this-one' was 'button-one'")
    with expected_exception(AssertionError, msg):
        actions.assert_element_attribute('#button-one', 'id', 'not-this-one')
Пример #17
0
def test(data):
    actions.navigate(data.env.url + 'tabs/')
    actions.click("#openTab")
    actions.wait_for_window_present_by_title('Tab')
    actions.verify_amount_of_windows(2)
    golem_steps.assert_last_step_message('Verify amount of open windows is 2')
    actions.switch_to_window_by_title('Tab')
    actions.close_window()
    actions.verify_amount_of_windows(1)
Пример #18
0
def test(data):
    actions.navigate(data.env.url)
    script = 'return arguments[0] + arguments[1]'
    args = ('a', 'b')
    result = actions.execute_javascript(script, 'a', 'b')
    expected = "Execute javascript code '{}' with args '{}'".format(
        script, args)
    golem_steps.assert_last_step_message(expected)
    assert result == 'ab'
Пример #19
0
def test(data):
    actions.navigate(data.env.url + 'dynamic-elements/?delay=3')
    actions.wait_for_element_text('#button-seven', 'New Text', 10)
    golem_steps.assert_last_step_message(
        "Wait for element #button-seven text to be 'New Text'")
    actions.navigate(data.env.url + 'dynamic-elements/?delay=5')
    msg = "Timeout waiting for element #button-seven text to be 'New Text'"
    with expected_exception(TimeoutException, msg):
        actions.wait_for_element_text('#button-seven', 'New Text', 3)
Пример #20
0
def test(data):
    url = data.env.url + 'elements/'
    actions.navigate(url)
    actions.verify_url_not_contains('incorrect')
    golem_steps.assert_last_step_message(
        "Verify URL does not contain 'incorrect'")
    actions.verify_url_not_contains('elem')
    golem_steps.assert_last_error(
        "expected URL '{}' to not contain 'elem'".format(url))
Пример #21
0
def test(data):
    actions.navigate(data.env.url + 'elements/')
    actions.assert_title_is_not('incorrect title')
    golem_steps.assert_last_step_message(
        "Assert page title is not 'incorrect title'")
    with expected_exception(
            AssertionError,
            "expected title to not be 'Web Playground - Elements'"):
        actions.assert_title_is_not('Web Playground - Elements')
def test(data):
    actions.navigate(data.env.url+'dynamic-elements/?delay=3')
    actions.wait_for_element_text_not_contains('#button-seven', 'Initial', 5)
    msg = "Wait for element #button-seven to not contain text 'Initial'"
    golem_steps.assert_last_step_message(msg)
    actions.navigate(data.env.url + 'dynamic-elements/?delay=5')
    msg = "Timeout waiting for element #button-seven text to not contain 'Initial'"
    with expected_exception(TimeoutException, msg):
        actions.wait_for_element_text_not_contains('#button-seven', 'Initial', 3)
def test_assert_element_attribute_is_not(data):
    actions.navigate(data.env.url + 'elements/')
    actions.assert_element_attribute_is_not('#button-one', 'id', 'incorrect')
    expected = "Assert element #button-one attribute id value is not incorrect"
    golem_steps.assert_last_step_message(expected)
    msg = "expected element #button-one attribute id value to not be button-one"
    with expected_exception(AssertionError, msg):
        actions.assert_element_attribute_is_not('#button-one', 'id',
                                                'button-one')
Пример #24
0
def test(data):
    url = data.env.url + 'elements/'
    actions.navigate(url)
    actions.assert_url_not_contains('incorrect')
    golem_steps.assert_last_step_message(
        "Assert page title does not contain 'incorrect'")
    msg = "expected URL '{}' to not contain 'elem'".format(url)
    with expected_exception(AssertionError, msg):
        actions.assert_url_not_contains('elem')
Пример #25
0
def test(data):
    actions.navigate(data.env.url + 'elements/')
    start = time.time()
    actions.send_keys_with_delay('#input-one', 'abc', delay=0.5)
    end = time.time()
    golem_steps.assert_last_step_message(
        "Write 'abc' in element #input-one with delay")
    actions.assert_element_value('#input-one', 'abc')
    assert end - start >= 1.5
Пример #26
0
def test(data):
    actions.navigate(data.env.url+'dynamic-elements/?delay=3')
    actions.wait_for_element_not_enabled('#button-four', timeout=5)
    golem_steps.assert_last_step_message('Wait for element #button-four to be not enabled')
    actions.verify_element_not_enabled('#button-four')
    actions.navigate(data.env.url + 'dynamic-elements/?delay=5')
    msg = "Timeout waiting for element #button-four to be not enabled"
    with expected_exception(TimeoutException, msg):
        actions.wait_for_element_not_enabled('#button-four', timeout=3)
def test(data):
    actions.navigate(data.env.url + 'tabs/')
    actions.send_keys('#title', 'lorem ipsum')
    actions.click('#goButtonCustom')
    actions.assert_amount_of_windows(2)
    actions.close_window_by_partial_title('lorem')
    golem_steps.assert_last_step_message(
        "Close window by partial title 'lorem'")
    actions.assert_amount_of_windows(1)
Пример #28
0
def test(data):
    url = data.env.url + 'elements/'
    actions.navigate(url)
    actions.assert_url_is_not('http://incorrect')
    golem_steps.assert_last_step_message(
        "Assert URL is not 'http://incorrect'")
    msg = "expected URL to not be '{}'".format(url)
    with expected_exception(AssertionError, msg):
        actions.assert_url_is_not(url)
def test(data):
    actions.navigate(data.env.url+'tabs/')
    actions.send_keys('#urlInput', '/elements/')
    actions.click("#goButton")
    actions.switch_to_window_by_partial_title('Ele')
    golem_steps.assert_last_step_message("Switch to window with partial title 'Ele'")
    actions.verify_title('Web Playground - Elements')
    msg = "Window with partial title 'incorrect title' was not found"
    with expected_exception(Exception, msg):
        actions.switch_to_window_by_partial_title('incorrect title')
Пример #30
0
def test_assert_element_checked(data):
    actions.navigate(data.env.url+'elements/')
    actions.assert_element_checked('#selected-checkbox')
    golem_steps.assert_last_step_message('Assert element #selected-checkbox is checked')
    with expected_exception(AssertionError, 'element #unselected-checkbox is not checked'):
        actions.assert_element_checked('#unselected-checkbox')
    # radio button
    actions.assert_element_checked('#exampleRadios1')
    with expected_exception(AssertionError, 'element #exampleRadios2 is not checked'):
        actions.assert_element_checked('#exampleRadios2')