我为Firefox下载了最新的Selenium插件,我通过网站点击了以下几点。当我保存测试用例时,它就像这样保存了......
<?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 > div.input.email > #UserEmail</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>css=fieldset > div.input.email > #UserEmail</td>
<td>username</td>
</tr>
<tr>
<td>type</td>
<td>css=fieldset > div.input.password > #UserPassword</td>
<td>password</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=div.buttons > div.submit > 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>
有没有办法在我记录的测试用例中插入逻辑,这样如果我在这些步骤后检测到屏幕上的文字......
<tr>
<td>type</td>
<td>id=eventId</td>
<td>AAA</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=input.button</td>
<td></td>
</tr>
这些步骤将以“AAA”的不同值重复,但如果屏幕上的文字不存在,测试用例将完成?
答案 0 :(得分:0)
我猜你在谈论Selenium IDE。如果是这样,那么答案是否,IDE,将不提供条件和循环语句。但是如果你只是想复制录制的代码并在Eclipse,Visual Studio等任何开发环境中使用它,那么你可以做你想要的,编程语言支持。
但是有一种方法可以添加Flow Control插件。 请参阅这些链接https://stackoverflow.com/questions/22377980/conditional-check-in-selenium-ide,https://stackoverflow.com/questions/11275354/using-if-else-in-selenium-ide