0

I downloaded the latest Selenium add-on for Firefox and I recorded the following a couple of clicks through a web site. When I saved the test case, it saved like so …

<?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="https://subdomain.domain.com/" />
<title>selenium_test_case</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">selenium_test_case</td></tr>
</thead><tbody>
<tr>
        <td>open</td>
        <td>/users/login</td>
        <td></td>
</tr>
<tr>
        <td>click</td>
        <td>css=fieldset &gt; div.input.email &gt; #UserEmail</td>
        <td></td>
</tr>
<tr>
        <td>type</td>
        <td>css=fieldset &gt; div.input.email &gt; #UserEmail</td>
        <td>username</td>
</tr>
<tr>
        <td>type</td>
        <td>css=fieldset &gt; div.input.password &gt; #UserPassword</td>
        <td>password</td>
</tr>
<tr>
        <td>clickAndWait</td>
        <td>css=div.buttons &gt; div.submit &gt; input.button</td>
        <td></td>
</tr>
<tr>
        <td>type</td>
        <td>id=eventId</td>
        <td>AAA</td>
</tr>
<tr>
        <td>clickAndWait</td>
        <td>css=input.button</td>
        <td></td>
</tr>

</tbody></table>
</body>
</html>

Is there any way to insert logic into my recorded test case such that if I detect text on the screen after these steps …

<tr>
        <td>type</td>
        <td>id=eventId</td>
        <td>AAA</td>
</tr>
<tr>
        <td>clickAndWait</td>
        <td>css=input.button</td>
        <td></td>
</tr>

these steps will repeat with a different value for “AAA” but if the text on the screen isn’t present, the test case will finish?

1 Answers1

0

I guess you are talking about the Selenium IDE. If so, then answer is No, IDE, will not provide Conditional and Looping statements. But if you are just looking at copying the recorded code and use it in any development environment like Eclipse, Visual Studio, then you can do whatt you want provided, the programming language supports.

But there is way by adding Flow Control plugin. Please see these links https://stackoverflow.com/questions/22377980/conditional-check-in-selenium-ide,https://stackoverflow.com/questions/11275354/using-if-else-in-selenium-ide

Community
  • 1
  • 1
Siva
  • 1,129
  • 1
  • 8
  • 13
  • I am talking about Selenium IDE, yes, but come on man, you're saying there's no way to write conditional tests for the Selenium IDE? You know that's a wrong answer. –  Aug 24 '16 at 15:43