Beispiel #1
0
def test_browser_xpath(target, html_text_conf):
    html_text_conf['transform'].insert(0, {
        'xpath': './/*[@class="footer"]',
    })
    ok, content = Checker(html_text_conf).check()
    assert ok is True
    assert content == 'Footer content'
Beispiel #2
0
def test_fill_form_sample(target):
    conf = {
        'name':
        'Test page',
        'url':
        "http://{0}:{1}/form.html".format(*target),
        'form': [{
            'id': 'name',
            'value': '{{ "name" | sort | join("") }}'
        }, {
            'css': '#pass',
            'creds': 'pass'
        }],
        'transform': [
            # {'python': 'print(ok, content); content = content or ""'},
            {
                'css': '.unclosed-tag > #params'
            },
            'text',
        ],
        # 'headless': False,
    }
    ok, content = Checker(conf).check()
    assert ok is True
    assert content == "\n".join([
        "name = aemn",
        "pass = password",
    ])
Beispiel #3
0
def test_valid_http_404(target, not_found_conf):
    not_found_conf.update({
        'valid_http': [404],
    })
    ok, content = Checker(not_found_conf).check()
    assert ok is True
    assert '404' in content
Beispiel #4
0
def test_browser_css(target, html_text_conf):
    html_text_conf['transform'].insert(0, {
        'css': '.footer',
    })
    ok, content = Checker(html_text_conf).check()
    assert ok is True
    assert content == 'Footer content'
Beispiel #5
0
def test_tag_transformer(target, html_text_conf):
    html_text_conf['transform'].insert(0, {
        'tag': 'div',
    })
    ok, content = Checker(html_text_conf).check()
    assert ok is True
    assert content == 'Hello world!'
Beispiel #6
0
def test_simple_fetcher_with_pretty_json(target, json_conf):
    ok, content = Checker(json_conf).check()
    assert ok is True
    assert content == ('{\n'
                       '  "first name": "Peter",\n'
                       '  "last name": "Demin"\n'
                       '}')
Beispiel #7
0
def test_fill_form_sample(target):
    conf = {
        'name':
        'Test page',
        'url':
        "http://{0}:{1}/form.html".format(*target),
        'form': [{
            'id': 'name',
            'value': '{{ "name" | sort | join("") }}'
        }, {
            'css': '#pass',
            'creds': 'pass'
        }],
        # 'scenario': 'import pdb; pdb.set_trace()',
        'transform': [{
            'css': '#params'
        }, 'text'],
        # 'headless': False,
    }
    ok, content = Checker(conf).check()
    assert ok is True
    assert content == "\n".join([
        "name = aemn",
        "pass = password",
    ])
Beispiel #8
0
def test_scenario(target, html_text_conf):
    html_text_conf.update({
        'scenario': 'driver.find_element_by_id("page-link").click()',
        'delay': 0.5,
    })
    ok, content = Checker(html_text_conf).check()
    assert ok is True
    assert content == 'Another page'
Beispiel #9
0
def test_python_script_sample(python_script_conf):
    ok, content = Checker(python_script_conf).check()
    assert ok is True
    assert content == "python"