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'
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", ])
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
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'
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!'
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' '}')
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", ])
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'
def test_python_script_sample(python_script_conf): ok, content = Checker(python_script_conf).check() assert ok is True assert content == "python"