1

I have recorded the log-in into some page with FireFox Plugin Selenium IDE. The recorded result looks like this:

..
....
</thead><tbody>
<tr>
    <td>open</td>
    <td>/libs/cq/core/content/welcome.html</td>
    <td></td>
</tr>
<tr>
    <td>open</td>
    <td>/libs/cq/core/content/login.html?resource=%2Fcontent%2Fvrbp%2Fde%2Fpage%2home.html&amp;$$login$$=%24%24login%24%24</td>
    <td></td>
</tr>
<tr>
    <td>storeElementPresent</td>
    <td>id=input-submit</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>id=input-submit</td>
    <td></td>
</tr>
<tr>
    <td>assertElementPresent</td>
    <td>id=searchbox__form-text</td>
    <td></td>
</tr>
...
.....

I have saved this Test-case and started it with Selenium IDE. It works fine. It opens the welcome page and then opens the login page and then do the log in.

The problem is now in the case if I am already loged in the page. the Test process hangs on the line ClickAndWait. It does not find the login fields, because I am already loged in.

My Question is: How to tell that it should ignore this step, if I am already loged in?

Ronald
  • 2,721
  • 8
  • 33
  • 44

2 Answers2

0

Is there any unique element you can look at from the log-in page? For example, password and username fields. If they are visible, do a log in, if they are not, you are already logged in.

Hope it helps.

Yu Zhang
  • 2,037
  • 6
  • 28
  • 42
0

First of all you have to download the plugin flow control for the selenium ide.(https://addons.mozilla.org/en-US/firefox/addon/flow-control/) Then you have to add some commands to your code to check if the button login exist. So the final code should look like this:

</thead><tbody>
<tr>
    <td>open</td>
    <td>/libs/cq/core/content/welcome.html</td>
    <td></td>
</tr>
<tr>
    <td>open</td>
    <td>/libs/cq/core/content/login.html?resource=%2Fcontent%2Fvrbp%2Fde%2Fpage%2home.html&amp;$$login$$=%24%24login%24%24</td>
    <td></td>
</tr>
<tr>
    <td>storeElementPresent</td>
    <td>id=input-submit</td>
    <td>present</td>
</tr>
<tr>
    <td>gotoIf</td>
    <td>present!=true</td>
    <td>label1</td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>id=input-submit</td>
    <td></td>
</tr>
<tr>
    <td>label</td>
    <td>label1</td>
</tr>
<tr>
    <td>assertElementPresent</td>
    <td>id=searchbox__form-text</td>
    <td></td>
</tr>
george
  • 84
  • 2