vmi / selenese-runner-java

Selenium IDE native format (selenese and side) interpreter.
Other
140 stars 83 forks source link

Command numbering and while loop #113

Open josepedrocorreia opened 10 years ago

josepedrocorreia commented 10 years ago

When using while loops, command numbering in the log is not so intuitive. When running the following example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://docs.seleniumhq.org" />
<title>MinimalExample1</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">MinimalExample1</td></tr>
</thead><tbody>
<tr>
    <td>open</td>
    <td>/</td>
    <td></td>
</tr>
<tr>
    <td>setSpeed</td>
    <td>200</td>
    <td></td>
</tr>
<tr>
    <td>storeElementPresent</td>
    <td>id=choice</td>
    <td>on_main_page</td>
</tr>
<tr>
    <td>while</td>
    <td>${on_main_page}</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>css=#menu_projects &gt; a</td>
    <td></td>
</tr>
<tr>
    <td>storeElementPresent</td>
    <td>id=choice</td>
    <td>on_main_page</td>
</tr>
<tr>
    <td>endWhile</td>
    <td></td>
    <td></td>
</tr>
<tr>
    <td>echo</td>
    <td></td>
    <td></td>
</tr>
</tbody></table>
</body>
</html>

one gets the following output:

[2014-04-30 14:16:39.477] [INFO] Start: Selenese Runner 1.4.4-SNAPSHOT
[2014-04-30 14:16:42.040] [INFO] Initial window size: 1024x768
[2014-04-30 14:16:42.040] [INFO] Initialized: FirefoxDriver
[2014-04-30 14:16:42.329] [INFO] Start: TestSuite[default-00]
[2014-04-30 14:16:42.334] [INFO] Start: TestCase[MinimalExample1] (/home/correia/Desktop/MinimalExample2.html)
[2014-04-30 14:16:42.334] [INFO] baseURL: http://docs.seleniumhq.org
[2014-04-30 14:16:42.346] [INFO] Command#1: open("/")
[2014-04-30 14:16:43.146] [INFO] - [Success] URL: [http://docs.seleniumhq.org/] / Title: [Selenium - Web Browser Automation]
[2014-04-30 14:16:43.146] [INFO] - Cookie: JSESSIONID=[gc1_JW7sisjNc80z0aM7Zg] (domain=docs.seleniumhq.org, path=/, expire=*)
[2014-04-30 14:16:43.146] [INFO] Command#2: setSpeed("200")
[2014-04-30 14:16:43.180] [INFO] - [Success]
[2014-04-30 14:16:43.380] [INFO] Command#3: storeElementPresent("id=choice", "on_main_page")
[2014-04-30 14:16:43.499] [INFO] - [true]
[2014-04-30 14:16:43.700] [INFO] Command#4: while("${on_main_page}")
[2014-04-30 14:16:43.753] [INFO] - [Success]
[2014-04-30 14:16:43.953] [INFO] Command#5: click("css=#menu_projects > a")
[2014-04-30 14:16:44.267] [INFO] - [Success] URL: [http://docs.seleniumhq.org/projects/] / Title: [Selenium Projects]
[2014-04-30 14:16:44.267] [INFO] - Cookie: JSESSIONID=[gc1_JW7sisjNc80z0aM7Zg] (domain=docs.seleniumhq.org, path=/, expire=*)
[2014-04-30 14:16:44.467] [INFO] Command#6: storeElementPresent("id=choice", "on_main_page")
[2014-04-30 14:16:44.517] [INFO] - [false]
[2014-04-30 14:16:44.718] [INFO] Command#7: endWhile()
[2014-04-30 14:16:44.745] [INFO] - [Success]
[2014-04-30 14:16:44.945] [INFO] Command#4: while("${on_main_page}")
[2014-04-30 14:16:44.978] [INFO] - [Success]
[2014-04-30 14:16:45.178] [INFO] Command#8: echo("")
[2014-04-30 14:16:45.202] [INFO] - []
[2014-04-30 14:16:45.404] [INFO] End(3.068sec): TestCase[MinimalExample1] (/home/correia/Desktop/MinimalExample2.html)
[2014-04-30 14:16:45.404] [INFO] End(0.000sec): TestSuite[default-00]
[2014-04-30 14:16:45.462] [INFO] Quit: FirefoxDriver

As you can see the numbering goes 1-2-3-4-5-6-7-4-8. What I find not intuitive is that the numbering should reflect either the logical structure of the test case, in which case they could go something like 1-2-3-4-4.1-4.2-4.3-4-5, or they should reflect the execution order, in which case I would expect them to just go sequentially.

This is not a major issue of course, but I'm mentioning it since I'm parsing this log and this raises problems for me.

vmi commented 10 years ago

I added loop count information to log message. For example, it is as follows:

#1@1 while
#2@1-1 while
#3@1-1 ...
#4@1-1 endWhile
#2@1-2 while
#3@1-2 ...
#4@1-2 endWhile
#5@1 endWhile
#1@2 while
#2@2-1 while
#3@2-1 ...
#4@2-1 endWhile
#2@2-2 while
#3@2-2 ...
#4@2-2 endWhile
#5@2 endWhile
#6 ...

the loop counter is incremented at next loop, and reset at exiting loop.

josepedrocorreia commented 10 years ago

Hmm, this is not exactly what I had in mind. In general, I don't like the fact that command numbers still go back, as in your example 1-2-3-4-2-3-4-5-... I would prefer that the numbering would reflect the execution order, and you could use indentation for the commands inside the loop body, like what is done for rollup rules.

Anyway, this is just my opinion, so if you prefer the way it is, feel free to close the ticket, since what you made already helps.

vmi commented 10 years ago

I am sorry, I misunderstood your proposal. Please let me think just for a moment.