Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/defnngj/unittest-extend
https://github.com/defnngj/unittest-extend
Last synced: 25 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/defnngj/unittest-extend
- Owner: defnngj
- License: apache-2.0
- Created: 2022-01-12T14:32:07.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-24T16:42:34.000Z (4 months ago)
- Last Synced: 2024-06-24T18:41:29.863Z (4 months ago)
- Language: Python
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# unittest-extend
## 安装
* 下载安装
```shell script
> git clone https://github.com/defnngj/unittest-extend
> cd unittest-extend
> pip install .
```* pip在线安装
```shell
> pip install -U https://github.com/defnngj/unittest-extend.git@master
```## 用法
`test_sample.py` 用例:
```python
import xtest
from selenium import webdriverclass MyTest(xtest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.name = self.get_namedef tearDown(self):
self.driver.quit()def test_case(self):
self.driver.get("https://www.baidu.com/")
search_input = self.driver.find_element("id", "kw")
search_input.send_keys(self.name)
search_input.submit()
self.sleep(2)
result_title = self.driver.find_elements("css selector", "div > h3.c-title > a")
for title in result_title:
self.assert_in_text(self.name, title.text)if __name__ == '__main__':
xtest.run()
```## 运行:
直接通过python 运行测试文件。
```shell
> pytest test_sample.py.
----------------------------------------------------------------------
Ran 1 test in 10.281sOK
```