Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ecommerce-ui
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
ecommerce-ui
Commits
92606298
Commit
92606298
authored
Mar 28, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: updated Qunit/Selenium test parser
parent
84efef89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
773 additions
and
42 deletions
+773
-42
test/index.html
test/index.html
+773
-42
No files found.
test/index.html
View file @
92606298
...
...
@@ -11,8 +11,8 @@
<script
type=
"text/javascript"
src=
"ext/qunit/qunit.js"
></script>
<script
type=
"text/javascript"
src=
"
ext
/jquery/jquery.js"
></script>
<script
type=
"text/javascript"
src=
"
ext
/jquery-mobile/jquery-mobile.js"
></script>
<script
type=
"text/javascript"
src=
"
../ext/libs
/jquery/jquery.js"
></script>
<script
type=
"text/javascript"
src=
"
../ext/libs
/jquery-mobile/jquery-mobile.js"
></script>
<script
type=
"text/javascript"
src=
"setup/jquery.testHelper.js"
></script>
<script
type=
"text/javascript"
>
...
...
@@ -160,49 +160,782 @@
d
=
el
.
contentDocument
;
j
=
el
.
contentWindow
.
$
;
helper
=
$
.
testHelper
;
// ======================= start here ===========================
trigger
=
function
(
window
,
d
,
$
,
testHelper
)
{
var
i
,
instruction
,
madeJS
,
add
;
var
menu_button
;
var
string
=
'
<table cellspacing="1" cellpadding="1" border="1">
'
+
'
<thead>
'
+
'
<tr class="title">
'
+
'
<td colspan="3">Basic UI Interaction Test</td>
'
+
'
</tr>
'
+
'
</thead>
'
+
'
<tbody>
'
+
'
<tr>
'
+
'
<td>Module</td>
'
+
'
<td>We also want to test something else</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//div[@id="global-panel"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>verifyText</td>
'
+
'
<td>//div[@id="global-panel"]</td>
'
+
'
<td>Menu</td>
'
+
'
</tr>
'
+
'
</tbody>
'
+
'
</table>
'
;
var
tableToParse
=
tableToJSON
(
$
(
string
),
{
"
ignoreHiddenRows
"
:
false
});
console
.
log
(
tableToParse
)
madeJS
=
''
;
for
(
i
=
0
;
i
<
tableToParse
.
length
;
i
+=
1
)
{
instruction
=
tableToParse
[
i
];
switch
(
instruction
[
i
])
{
case
"
Module
"
:
madeJS
+=
'
module("
'
+
instruction
.
Selector
+
'
");
'
;
// oh lord
var
another_string
=
'
<table cellspacing="1" cellpadding="1" border="1" name="SELENIUM-TEST">
'
+
'
<thead>
'
+
'
<tr class="title">
'
+
'
<td>command</td>
'
+
'
<td>selector</td>
'
+
'
<td>value</td>
'
+
//'
<
td
colspan
=
"
3
"
>
SlapOS
UI
Basic
Interaction
<
/td>'
+
'
</tr>
'
+
'
</thead>
'
+
'
<tbody>
'
+
'
<tr>
'
+
'
<td>store</td>
'
+
'
<td><urltool portal_url="" at=""></urltool></td>
'
+
'
<td>base_url</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>store</td>
'
+
'
<!-- ERP5TypeTestCase is the default for any UnitTest -->
'
+
'
<td></td>
'
+
'
<td>base_user</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>store</td>
'
+
'
<td></td>
'
+
'
<td>base_password</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>openAndWait</td>
'
+
'
<td>${base_url}</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForPageToLoad</td>
'
+
'
<td><br></td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//div[@id="global-panel"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Login"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//h1[.="Networks"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//a[.="Add network"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Add network"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//input[@id="network_new_title"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>type</td>
'
+
'
<td>id=network_new_title</td>
'
+
'
<td>Bazbam</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//input[@type="submit"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>10000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[@href="#networks"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Bazbam"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Delete"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>verifyText</td>
'
+
'
<td>//div[@class="info"]</td>
'
+
'
<td>1-3/3 Records</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>openAndWait</td>
'
+
'
<td>${base_url}</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForPageToLoad</td>
'
+
'
<td><br></td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//div[@id="global-panel"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Menu"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//h1[.="Person"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//input[@id="user_sample_password"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>type</td>
'
+
'
<td>id=user_sample_password</td>
'
+
'
<td>topsecret</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>type</td>
'
+
'
<td>id=user_sample_default_fax_text</td>
'
+
'
<td>Foo</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//input[@type="submit"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Home"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>2000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Menu"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//h1[.="Person"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//input[@id="user_sample_password"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>verifyAttribute</td>
'
+
'
<td>//input[@id="user_sample_default_fax_text"]@value</td>
'
+
'
<td>Foo</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>openAndWait</td>
'
+
'
<td>${base_url}</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForPageToLoad</td>
'
+
'
<td><br></td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//div[@id="global-panel"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Menu"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//h1[.="Invoices"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//a[.="Download"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>openAndWait</td>
'
+
'
<td>${base_url}</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForPageToLoad</td>
'
+
'
<td><br></td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//div[@id="global-panel"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Menu"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//h1[.="Services"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//a[.="Zabbix Agent"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Zabbix Agent"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//textarea[@id="service_instance_overview_xml_recipe"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>type</td>
'
+
'
<td>id=service_instance_overview_xml_recipe</td>
'
+
'
<td>Bar</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//input[@type="submit"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Destroy"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//a[.="Install new service"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>verifyText</td>
'
+
'
<td>//div[@class="info"]</td>
'
+
'
<td>1-3/3 Records</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>openAndWait</td>
'
+
'
<td>${base_url}</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForPageToLoad</td>
'
+
'
<td><br></td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//div[@id="global-panel"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Menu"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//h1[.="Services"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Install new service"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>type</td>
'
+
'
<td>id=search_software_list</td>
'
+
'
<td>Zabbix</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>link=[EXPERIMENTAL] Zabbix Agent</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>link=slapos-0.5</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>select</td>
'
+
'
<td>id=install_release_reference_computer</td>
'
+
'
<td>label=Cortana</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//input[@value="Request"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Menu"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//h1[.="Services"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>verifyText</td>
'
+
'
<td>//div[@class="info"]</td>
'
+
'
<td>1-5/5 Records</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>openAndWait</td>
'
+
'
<td>${base_url}</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForPageToLoad</td>
'
+
'
<td><br></td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//div[@id="global-panel"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Menu"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//h1[.="Servers"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>10000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>type</td>
'
+
'
<td>id=search_server_list</td>
'
+
'
<td>Cortana</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>2000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>link=Cortana</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//a[.="Set Configuration"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Set Configuration"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>2000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>type</td>
'
+
'
<td>id=computer_sample_reference</td>
'
+
'
<td>Foo-123</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>type</td>
'
+
'
<td>id=computer_sample_translated_validation_state_title</td>
'
+
'
<td>Dead</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//input[@type="submit"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>goBack</td>
'
+
'
<td></td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>verifyAttribute</td>
'
+
'
<td>//input[@id="computer_status_reference"]@value</td>
'
+
'
<td>Foo-123</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>link=servers</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>type</td>
'
+
'
<td>id=search_server_list</td>
'
+
'
<td>Cortana</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>2000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>link=Dead</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Delete"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>verifyText</td>
'
+
'
<td>//div[@class="info"]</td>
'
+
'
<td>1-8/73 Records</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>openAndWait</td>
'
+
'
<td>${base_url}</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForPageToLoad</td>
'
+
'
<td><br></td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//div[@id="global-panel"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Menu"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//h1[.="Servers"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>10000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Add Server"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>type</td>
'
+
'
<td>id=computer_new_title</td>
'
+
'
<td>Quantum</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>type</td>
'
+
'
<td>id=computer_new_description</td>
'
+
'
<td>Im the fastest</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//input[@type="submit"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Delete"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>verifyText</td>
'
+
'
<td>//div[@class="info"]</td>
'
+
'
<td>1-8/74 Records</td>
'
+
'
</tr>
'
+
'
</tbody>
'
+
'
</table>
'
;
// normally:
// (1) load a testpage
// (2) text_content contains the above table
// (3) clean = replace " with ', etc.
// (4) convert header into column as needed
// (5) use old header as Module Title
// (6) add extra column for the comments = QUNIT comment
// (7)
var
tableToParse
,
tag
,
selector
,
val
,
ins
,
find
,
close_async
,
i
,
instruction
,
madeJS
,
add
,
menu_button
,
testForElement
,
countDown
;
// parse table into objcet
tableToParse
=
tableToJSON
(
$
(
another_string
),
{
"
ignoreHiddenRows
"
:
false
});
// extract selector tag
tag
=
function
(
str
)
{
return
str
.
split
(
"
[
"
)[
0
].
replace
(
"
//
"
,
""
);
};
// extract selector identifier (class, id, :contains...)
selector
=
function
(
str
)
{
var
base
=
str
.
split
(
"
[
"
)[
1
].
split
(
"
=
"
)[
0
].
replace
(
"
@
"
,
""
);
switch
(
base
)
{
case
"
id
"
:
return
[
"
#
"
,
""
];
case
"
.
"
:
return
[
"
:contains('
"
,
"
')
"
];
}
};
// extract selector value
val
=
function
(
str
)
{
return
str
.
split
(
"
=
"
)[
1
]
.
replace
(
"
]
"
,
""
)
.
replace
(
'
"
'
,
''
,
"
g
"
)
.
replace
(
"
'
"
,
""
,
"
g
"
);
};
// lets go
madeJS
=
''
;
// set reference, because what we do is not working
madeJS
=
'
var frame = document.getElementsByTagName("iframe")[0];
'
+
'
var d = frame.contentDocument;
'
+
'
var w = frame.contentWindow;
'
+
'
var $i = $( d );
'
;
// dump all testmethods here, because they need to be available
// inside the iFrame...
madeJS
+=
'
$.testHelper.countDown = function(test, iteration) {
'
+
'
var ticker = iteration || 0;
'
+
'
if (ticker > 10) {
'
+
'
return false;
'
+
'
}
'
+
'
window.setTimeout(function() {
'
+
'
if (test === true) {
'
+
'
return true;
'
+
'
}
'
+
'
ticker += 1;
'
+
'
$.testHelper.countDown(test, ticker);
'
+
'
}, 1000);
'
+
'
};
'
+
'
$.testHelper.testForElement = function(element) {
'
+
'
return $.testHelper.countDown(
'
+
'
$i.find(element).length > 0
'
+
'
);
'
+
'
};
'
;
madeJS
+=
'
module("
'
+
'
SlapOS UI Basic Interaction
'
+
'
");
'
;
len
=
tableToParse
.
length
;
// loop table rows
for
(
i
=
0
;
i
<
8
;
i
+=
1
)
{
instruction
=
tableToParse
[
i
];
// parse instructions
console
.
log
(
instruction
.
command
)
switch
(
instruction
.
command
)
{
case
"
openAndWait
"
:
// close previous async block
if
(
close_async
)
{
madeJS
+=
'
function() {start();} ]) });
'
;
madeJS
=
madeJS
.
replace
(
/__number__/
,
count
.
toString
());
close_asyn
=
undefined
;
count
=
undefined
;
}
// start a new block
close_async
=
true
;
count
=
0
;
madeJS
+=
'
asyncTest( "
'
+
instruction
.
selector
+
'
", function() { expect( __number__ );
'
;
madeJS
+=
'
$.testHelper.pageSequence([
'
;
break
;
case
"
click
"
:
ins
=
instruction
.
selector
;
wrap
=
selector
(
ins
);
find
=
tag
(
ins
)
+
wrap
[
0
]
+
val
(
ins
)
+
wrap
[
1
];
madeJS
+=
'
function () {
'
+
'
console.log($("
'
+
find
+
'
"));$("
'
+
find
+
'
").trigger("click");
'
+
'
},
'
;
break
;
case
"
waitForElementPresent
"
:
ins
=
instruction
.
selector
;
wrap
=
selector
(
ins
);
find
=
tag
(
ins
)
+
wrap
[
0
]
+
val
(
ins
)
+
wrap
[
1
];
count
+=
1
;
madeJS
+=
'
function () {
'
+
'
var t = $.testHelper.testForElement("
'
+
find
+
'
");
'
+
'
}, function (t) {
'
+
'
ok(t, "element present");
'
+
'
},
'
;
break
;
}
}
madeJS
+=
'
asyncTest( "Number 2", function() {expect( 0 ); start(); });
'
;
if
(
close_async
)
{
madeJS
+=
'
function() {start();} ]) });
'
;
madeJS
=
madeJS
.
replace
(
/__number__/
,
count
.
toString
());
close_asyn
=
undefined
;
count
=
undefined
;
}
// inject
add
=
d
.
createElement
(
"
script
"
);
...
...
@@ -211,8 +944,6 @@
document
.
body
.
appendChild
(
add
);
console
.
log
(
"
so...
"
)
$
.
testHelper
=
testHelper
;
...
...
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