Commit 4e478cef authored by Rafael Monnerat's avatar Rafael Monnerat

Do not parse the URL content, expect always a pure selenium test

The parse code were moved to run my docs business template, the responsability to parse it's own content are now from TestPage_getSeleniumTest.

This drop the dependency from this feature to Run My Docs.
parent 8996cda2
...@@ -8,46 +8,6 @@ def urlread(url): ...@@ -8,46 +8,6 @@ def urlread(url):
def editZPT(zpt, text): def editZPT(zpt, text):
zpt.pt_edit(text, 'text/html') zpt.pt_edit(text, 'text/html')
"""
Remove everything but the test in a webpage
"""
def parseTutorial(text, title):
import lxml.html
from lxml import etree
root = lxml.html.fromstring(text)
table_list = root.xpath('//test')
html = """
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>"""+ title + """</title>
</head>
<body>
<table name="SELENIUM-TEST" cellpadding="1" cellspacing="1" border="1">
<thead>
<tr class="title">
<td colspan="3">"""+ title + """</td>
</tr>
</thead>
<tbody>
"""
for table in table_list:
table = table[0]
if len(table) > 0:
for row in table[-1]:
if len(row) == 1:
html += row[0].text
else:
html += lxml.html.tostring(row)
html +="""
</tbody>
</table>
</body>
</html>"""
return html
""" """
Add the test at the end of the webpage (overwrite the current test if there's already one) and hide it Add the test at the end of the webpage (overwrite the current test if there's already one) and hide it
""" """
......
...@@ -61,7 +61,7 @@ zuite = context.getPortalObject().portal_tests.Zuite_addZuite(zuite_id)\n ...@@ -61,7 +61,7 @@ zuite = context.getPortalObject().portal_tests.Zuite_addZuite(zuite_id)\n
\n \n
test = zuite.Zuite_addTest(test_id, \n test = zuite.Zuite_addTest(test_id, \n
title, \n title, \n
context.Zuite_extractTest(text, title))\n text)\n
\n \n
return zuite.Base_redirect("core/TestRunner.html?auto=true&test=..%2Ftest_suite_html&resultsUrl=..%2FpostResults")\n return zuite.Base_redirect("core/TestRunner.html?auto=true&test=..%2Ftest_suite_html&resultsUrl=..%2FpostResults")\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>parseTutorial</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ERP5Zuite</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Zuite_extractTest</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Extract Zelenium Test from tutorial</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
<key> <string>center</string> </key> <key> <string>center</string> </key>
<value> <value>
<list> <list>
<string>your_description</string>
<string>your_url</string> <string>your_url</string>
<string>your_zuite_id</string> <string>your_zuite_id</string>
<string>your_test_id</string> <string>your_test_id</string>
......
51 52
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment