Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5_fork
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5_fork
Commits
30df125b
Commit
30df125b
authored
Mar 01, 2012
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use page template instead a python script to render the selenium test
parent
e920ddfd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
32 deletions
+99
-32
bt5/erp5_run_my_doc/ExtensionTemplateItem/ERP5RunMyDocs.py
bt5/erp5_run_my_doc/ExtensionTemplateItem/ERP5RunMyDocs.py
+5
-27
bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_runSeleniumTest.xml
...portal_skins/erp5_run_my_doc/TestPage_runSeleniumTest.xml
+9
-4
bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_viewSeleniumTest.xml
...ortal_skins/erp5_run_my_doc/TestPage_viewSeleniumTest.xml
+84
-0
bt5/erp5_run_my_doc/bt/revision
bt5/erp5_run_my_doc/bt/revision
+1
-1
No files found.
bt5/erp5_run_my_doc/ExtensionTemplateItem/ERP5RunMyDocs.py
View file @
30df125b
...
...
@@ -110,44 +110,22 @@ def urlread(url):
import
urllib
return
urllib
.
urlopen
(
url
).
read
()
"""
Remove everything but the test in a webpage
"""
def
extractTest
(
t
itle
,
t
ext
):
def
extractTest
(
text
):
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>
"""
testcode
=
""
for
table
in
table_list
:
table
=
table
[
0
]
if
len
(
table
)
>
0
:
for
row
in
table
[
-
1
]:
if
len
(
row
)
==
1
:
# Include Macros as it is defined by the user.
html
+=
row
[
0
].
text
testcode
+=
row
[
0
].
text
else
:
html
+=
lxml
.
html
.
tostring
(
row
)
html
+=
"""
</tbody>
</table>
</body>
</html>"""
return
html
\ No newline at end of file
testcode
+=
lxml
.
html
.
tostring
(
row
)
return
testcode
bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_runSeleniumTest.xml
View file @
30df125b
...
...
@@ -51,15 +51,20 @@
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
"""\n
Launch Test Embedded at the Test Page.\n
"""\n
reference = context.getReference()\n
if reference not in [None, \'\']:\n
zuite_id = reference\n
\n
return context.Zuite_createAndLaunchSeleniumTest(text=context.TestPage_getSeleniumTest(),\n
title=context.getTitle(), \n
zuite_id=zuite_id,\n
test_id=test_id)\n
test_script = getattr(context, \'Zuite_createAndLaunchSeleniumTest\', None)\n
if test_script is None:\n
raise ValueError("Unable to Launch the Test. Please install erp5_test_ui_core business template.")\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>
</item>
<item>
...
...
bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_
get
SeleniumTest.xml
→
bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_
view
SeleniumTest.xml
View file @
30df125b
...
...
@@ -2,14 +2,10 @@
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"
PythonScript"
module=
"Products.PythonScripts.PythonScript
"
/>
<global
name=
"
ZopePageTemplate"
module=
"Products.PageTemplates.ZopePageTemplate
"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
...
...
@@ -24,18 +20,6 @@
<key>
<string>
_asgns
</string>
</key>
<value>
<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>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
...
...
@@ -49,17 +33,50 @@
</value>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
return context.TestPage_extractTest(context.getTitle(), context.getTextContent())\n
</string>
</value>
<key>
<string>
_text
</string>
</key>
<value>
<unicode
encoding=
"cdata"
>
<![CDATA[
<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>
<key>
<string>
_params
</string>
</key>
<value>
<
string></string
>
</value>
<key>
<string>
expand
</string>
</key>
<value>
<
int>
0
</int
>
</value>
</item>
<item>
<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>
</dictionary>
</pickle>
...
...
bt5/erp5_run_my_doc/bt/revision
View file @
30df125b
53
\ No newline at end of file
54
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment