技术宅,fat-man

增加语言的了解程度可以避免写出愚蠢的代码

导航

Selenium第一个例子

#!/usr/bin/env python
#
-*- coding: utf-8 -*-

from selenium import selenium
import unittest, time, re

class CreateProjectTestCase(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", 4444, "*chrome", "http://127.0.0.1/")
self.selenium.start()

def runTest(self):
sel = self.selenium
sel.open("/static/test.html")
sel.click("id=list2")
sel.mouse_move_at("id=list", "")
sel.click("id=z1")
sel.mouse_over("id=list")

def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)


if __name__ == "__main__":
unittest.main()

注意:Selenium的python WebDriver版本是不支持鼠标操作的!!!因此有鼠标操作只能上RM版本了

 

官方下载地址:

http://seleniumhq.org/download/

posted on 2012-01-13 18:32  codestyle  阅读(299)  评论(0编辑  收藏  举报