简体   繁体   English

PHP SimpleTest:如何从网页获取价值?

[英]PHP SimpleTest: How to get a value from webpage?

I use SimpleTest for testing my pages written in PHP. 我使用SimpleTest来测试用PHP编写的页面。

I have a form where you can enter several names at once. 我有一个表格,您可以一次输入多个名称。 Then you click on "Generate Usernames and Passwords". 然后单击“生成用户名和密码”。

My test can set the names using setField('txtname', 'test user') and my test can click on the submit button. 我的测试可以使用setField('txtname','test user')设置名称,我的测试可以单击Submit按钮。 But how do I get the values of a generated username and password so that I can use this information to check if the login works? 但是,如何获取生成的用户名和密码的值,以便可以使用此信息检查登录是否有效?

The generated html code I want to retrieve the username and password from looks like this: 我想要从中检索用户名和密码的生成的html代码如下所示:

<table border="1" cellpadding="2" cellspacing="0">
<thead>
<tr bgcolor="EEEEEE">
<th align=left>Last Name</th><th align=left>First Name</th><th align=left>Username</th>       
<th align=left>Password</th></tr>
</thead>
<tbody>
<tr>
    <td>Test</td><td>User</td><td  id=username1>UserTest</td>
    <td id=password1>1a818</td></tr>
<tr>
    <td>Gates</td><td>Bill</td><td  id=username2>BillGates1</td>
    <td id=password2>aa37c</td></tr>
</tbody>
</table>

Thanks for any tips. 感谢您的提示。

Philip 菲利浦

You can use Selenium to test user interfaces: 您可以使用Selenium测试用户界面:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM