Commit 30df125b authored by Rafael Monnerat's avatar Rafael Monnerat

Use page template instead a python script to render the selenium test

parent e920ddfd
...@@ -110,44 +110,22 @@ def urlread(url): ...@@ -110,44 +110,22 @@ def urlread(url):
import urllib import urllib
return urllib.urlopen(url).read() return urllib.urlopen(url).read()
""" """
Remove everything but the test in a webpage Remove everything but the test in a webpage
""" """
def extractTest(title, text): def extractTest(text):
import lxml.html import lxml.html
from lxml import etree from lxml import etree
root = lxml.html.fromstring(text) root = lxml.html.fromstring(text)
table_list = root.xpath('//test') table_list = root.xpath('//test')
html = """ testcode = ""
<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: for table in table_list:
table = table[0] table = table[0]
if len(table) > 0: if len(table) > 0:
for row in table[-1]: for row in table[-1]:
if len(row) == 1: if len(row) == 1:
# Include Macros as it is defined by the user. # Include Macros as it is defined by the user.
html += row[0].text testcode += row[0].text
else: else:
html += lxml.html.tostring(row) testcode += lxml.html.tostring(row)
html +=""" return testcode
</tbody>
</table>
</body>
</html>"""
return html
\ No newline at end of file
...@@ -51,15 +51,20 @@ ...@@ -51,15 +51,20 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""\n
Launch Test Embedded at the Test Page.\n
"""\n """\n
reference = context.getReference()\n reference = context.getReference()\n
if reference not in [None, \'\']:\n if reference not in [None, \'\']:\n
zuite_id = reference\n zuite_id = reference\n
\n \n
return context.Zuite_createAndLaunchSeleniumTest(text=context.TestPage_getSeleniumTest(),\n test_script = getattr(context, \'Zuite_createAndLaunchSeleniumTest\', None)\n
title=context.getTitle(), \n if test_script is None:\n
zuite_id=zuite_id,\n raise ValueError("Unable to Launch the Test. Please install erp5_test_ui_core business template.")\n
test_id=test_id)\n \n
return test_script(text=context.TestPage_viewSeleniumTest(),\n
title=context.getTitle(), \n
zuite_id=zuite_id,\n
test_id=test_id)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -2,14 +2,10 @@ ...@@ -2,14 +2,10 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/> <global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
...@@ -24,18 +20,6 @@ ...@@ -24,18 +20,6 @@
<key> <string>_asgns</string> </key> <key> <string>_asgns</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item> <item>
<key> <string>name_subpath</string> </key> <key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value> <value> <string>traverse_subpath</string> </value>
...@@ -49,17 +33,50 @@ ...@@ -49,17 +33,50 @@
</value> </value>
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_text</string> </key>
<value> <string>return context.TestPage_extractTest(context.getTitle(), context.getTextContent())\n <value> <unicode encoding="cdata"><![CDATA[
</string> </value>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"\n
xmlns:metal="http://xml.zope.org/namespaces/metal">\n
<head>\n
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n
<title tal:content="context/title">The title</title>\n
</head>\n
<body>\n
<table name="SELENIUM-TEST" cellpadding="1" cellspacing="1" border="1">\n
<thead>\n
<tr class="title">\n
<td colspan="3" tal:content="context/title">title</td>\n
</tr>\n
</thead>\n
<tbody>\n
<tal:block tal:replace="structure python:context.TestPage_extractTest(context.getTextContent())" />\n
</tbody>\n
</table>\n
</body>\n
</html>
]]></unicode> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>expand</string> </key>
<value> <string></string> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>TestPage_getSeleniumTest</string> </value> <value> <string>TestPage_viewSeleniumTest</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
53 54
\ 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