使用开源工具测试 Web 应用程序
2010-02-04 00:00:00 来源:WEB开发网清单 4. 示例 Selenium 测试
from selenium import selenium
import unittest, time, re
class NewTest(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost",
4444, "*chrome", "http://shell.appspot.com")
self.selenium.start()
def test_new(self):
sel = self.selenium
sel.open("/")
sel.click("link=source")
sel.wait_for_page_to_load("30000")
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
您可以启动 Selenium RC,它在多个浏览器上充当测试的代理,然后运行功能测试。清单 5 给出了 Selenium RC 的输出结果。
清单 5. 示例 Selenium RC 输出
# java -jar selenium-server.jar
01:18:47.909 INFO - Java: Apple Inc. 1.5.0_16-133
01:18:47.910 INFO - OS: Mac OS X 10.5.6 i386
01:18:47.915 INFO - v1.0-beta-1 [2201], [1994]
01:18:48.044 INFO - Version Jetty/5.1.x
01:18:48.045 INFO - Started HttpContext[/,/]
01:18:48.047 INFO - Started HttpContext[/selenium-server]
01:18:48.047 INFO - Started HttpContext[/selenium-server/driver]
01:18:48.055 INFO - Started SocketListener on 0.0.0.0:4444
[output suppressed for space]
更多精彩
赞助商链接