介绍:
pyse基于selenium(webdriver)进行了简单的二次封装,比selenium所提供的方法操作更简洁。
特点:
安装说明:
进入pyse/目录,执行:
> python setup.py install
例子:
请查看demo/test_case.py目录
- import pyse
-
- class BaiduTest(pyse.TestCase):
-
- def test_baidu(self):
- ''' baidu search key : pyse '''
- self.open("https://www.baidu.com/")
- self.type("#kw", "pyse")
- self.click("#su")
- self.assertTitle("pyse_百度搜索")
-
- if __name__ == '__main__':
- runner = pyse.TestRunner()
- runner.run()
运行测试用例说明:
支持的浏览器及驱动:
指定运行的浏览器:
- import pyse
-
- class YouTest(pyse.TestCase):
-
- @classmethod
- def setUpClass(cls):
- cls.driver = Pyse("chrome")
-
- def test_case(self):
- #……
支持的浏览器:
- cls.driver = Pyse("firefox") #Firefox
- cls.driver = Pyse("chrome") # Chrome
- cls.driver = Pyse("ie") #IE
- cls.driver = Pyse("opera") #Opera
- cls.driver = Pyse("edge") #Edge
- cls.driver = Pyse("chrome_headless") #Chrome headless模式
浏览器驱动下载地址:
geckodriver(Firefox):https://github.com/mozilla/geckodriver/releases
Chromedriver(Chrome):https://sites.google.com/a/chromium.org/chromedriver/home
IEDriverServer(IE):http://selenium-release.storage.googleapis.com/index.html
operadriver(Opera):https://github.com/operasoftware/operachromiumdriver/releases
MicrosoftWebDriver(Edge):https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver
==========================================================
#### 元素定位:
pyse支持多种定位方式,id、name、class、link text、xpath和css。把定位方法与定位内容一体,写起更加简洁。