SeldomQA
seldom
Python

Seldom automation testing framework based on unittest

Last updated Jul 3, 2026
854
Stars
332
Forks
13
Issues
+1
Stars/day
Attention Score
65
Language breakdown
Python 100.0%
โ–ธ Files click to expand
README

GitHub | Gitee |

PyPI version PyPI - Python Version

Seldom is an automation testing framework based on unittest.

seldom ๆ˜ฏๅŸบไบŽunittest ็š„่‡ชๅŠจๅŒ–ๆต‹่ฏ•ๆก†ๆžถใ€‚

Features

โญ web/app/apiๅ…จๅŠŸ่ƒฝๆต‹่ฏ•ๆก†ๆžถ

โญ ๆไพ›่„šๆ‰‹ๆžถๅฟซ้€Ÿๅˆ›ๅปบ่‡ชๅŠจๅŒ–้กน็›ฎ

โญ ้›†ๆˆXTestRunnerๆต‹่ฏ•ๆŠฅๅ‘Š๏ผŒ็Žฐไปฃ็พŽ่ง‚

โญ ๆไพ›ไธฐๅฏŒ็š„ๆ–ญ่จ€

โญ ๆไพ›ๅผบๅคง็š„ๆ•ฐๆฎ้ฉฑๅŠจ

โญ ๅนณๅฐๅŒ–ๆ”ฏๆŒ

Install

pip install seldom

If you want to keep up with the latest version, you can install with GitHub/Gitee repository url:

> pip install -U git+https://github.com/SeldomQA/seldom.git@master
> pip install -U git+https://gitee.com/fnngj/seldom.git@master

๐Ÿค– Quick Start

1ใ€ๆŸฅ็œ‹ๅธฎๅŠฉ๏ผš

seldom --help
                                                                                                    
 Usage: seldom [OPTIONS]                                                                            
                                                                                                    
 seldom CLI.                                                                                        
                                                                                                    
                                                                                                    
โ•ญโ”€ Options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ --version             -v                 Show version.                                           โ”‚
โ”‚ --project-api         -api      TEXT     Create a project of API type. [default: None]           โ”‚
โ”‚ --project-app         -app      TEXT     Create a project of App type [default: None]            โ”‚
โ”‚ --project-web         -web      TEXT     Create a project of Web type [default: None]            โ”‚
โ”‚ --clear-cache         -cc                Clear all caches of seldom.                             โ”‚
โ”‚ --log-level           -ll       TEXT     Set the log level [TRACE |DEBUG | INFO | SUCCESS |      โ”‚
โ”‚                                          WARNING | ERROR].                                       โ”‚
โ”‚                                          [default: None]                                         โ”‚
โ”‚ --mod                 -m        TEXT     Run tests modules, classes or even individual test      โ”‚
โ”‚                                          methods from the command line.                          โ”‚
โ”‚                                          [default: None]                                         โ”‚
โ”‚ --path                -p        TEXT     Run test case file path. [default: None]                โ”‚
โ”‚ --env                 -e        TEXT     Set the Seldom run environment Seldom.env.            โ”‚
โ”‚                                          [default: None]                                         โ”‚
โ”‚ --browser             -b        TEXT     The browser that runs the Web UI automation tests       โ”‚
โ”‚                                          [chrome | edge | firefox | chromium]. Need the --path.  โ”‚
โ”‚                                          [default: None]                                         โ”‚
โ”‚ --base-url            -u        TEXT     The base-url that runs the HTTP automation tests. Need  โ”‚
โ”‚                                          the --path.                                             โ”‚
โ”‚                                          [default: None]                                         โ”‚
โ”‚ --debug               -d                 Debug mode. Need the --path/--mod.                      โ”‚
โ”‚ --rerun               -rr       INTEGER  The number of times a use case failed to run again.     โ”‚
โ”‚                                          Need the --path.                                        โ”‚
โ”‚                                          [default: 0]                                            โ”‚
โ”‚ --report              -r        TEXT     Set the test report for output. Need the --path.        โ”‚
โ”‚                                          [default: None]                                         โ”‚
โ”‚ --collect             -c                 Collect project test cases. Need the --path.            โ”‚
โ”‚ --level               -l        TEXT     Parse the level of use cases [data | case]. Need the    โ”‚
โ”‚                                          --path.                                                 โ”‚
โ”‚                                          [default: data]                                         โ”‚
โ”‚ --case-json           -j        TEXT     Test case files. Need the --path. [default: None]       โ”‚
โ”‚ --har2case            -h2c      TEXT     HAR file converts an seldom test case. [default: None]  โ”‚
โ”‚ --swagger2case        -s2c      TEXT     Swagger file converts an seldom test case.              โ”‚
โ”‚                                          [default: None]                                         โ”‚
โ”‚ --api-excel                     TEXT     Run the api test cases in the excel file.               โ”‚
โ”‚                                          [default: None]                                         โ”‚
โ”‚ --install-completion                     Install completion for the current shell.               โ”‚
โ”‚ --show-completion                        Show completion for the current shell, to copy it or    โ”‚
โ”‚                                          customize the installation.                             โ”‚
โ”‚ --help                                   Show this message and exit.                             โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

2ใ€ๅˆ›ๅปบ้กน็›ฎ๏ผš

> seldom -api myapi  # API automation test project.
> seldom -app myapp  # or App automation test project.
> seldom -web myweb  # or Web automation test project.

็›ฎๅฝ•็ป“ๆž„ๅฆ‚ไธ‹๏ผš

myweb/
โ”œโ”€โ”€ test_dir/
โ”‚   โ”œโ”€โ”€ init.py
โ”‚   โ””โ”€โ”€ test_sample.py
โ”œโ”€โ”€ test_data/
โ”‚   โ””โ”€โ”€ data.json
โ”œโ”€โ”€ reports/
โ””โ”€โ”€ confrun.py
  • test_dir/ ๆต‹่ฏ•็”จไพ‹็›ฎๅฝ•ใ€‚
  • test_data/ ๆต‹่ฏ•ๆ•ฐๆฎๆ–‡ไปถ็›ฎๅฝ•ใ€‚
  • reports/ ๆต‹่ฏ•ๆŠฅๅ‘Š็›ฎๅฝ•ใ€‚
  • confrun.py ่ฟ่กŒ้…็ฝฎๆ–‡ไปถใ€‚
3ใ€่ฟ่กŒ้กน็›ฎ๏ผš
  • โŒ๏ธ ๅœจPyCharmไธญๅณ้”ฎๆ‰ง่กŒใ€‚
  • โœ”๏ธ ้€š่ฟ‡ๅ‘ฝไปค่กŒๅทฅๅ…ทๆ‰ง่กŒใ€‚
> seldom -p testdir # ่ฟ่กŒ testdir ๆต‹่ฏ•็›ฎๅฝ•

/ // / __ / / \/ / / \/ _/ ( ) / / // / // / / / / / / /_/\//\,/\_// // // v3.x.x


@itest.info ...

2022-04-30 18:37:36 log.py | INFO | โœ… Find 1 element: id=sbformq -&gt; input &#39;seldom&#39;. 2022-04-30 18:37:39 log.py | INFO | ๐Ÿ‘€ assertIn title: seldom - ๆœ็ดข. .52022-04-30 18:37:39 log.py | INFO | ๐Ÿ“– https://cn.bing.com 2022-04-30 18:37:41 log.py | INFO | โœ… Find 1 element: id=sbformq -&gt; input &#39;poium&#39;. 2022-04-30 18:37:42 log.py | INFO | ๐Ÿ‘€ assertIn title: poium - ๆœ็ดข. .62022-04-30 18:37:42 log.py | INFO | ๐Ÿ“– https://cn.bing.com 2022-04-30 18:37:43 log.py | INFO | โœ… Find 1 element: id=sbformq -&gt; input &#39;XTestRunner&#39;. 2022-04-30 18:37:44 log.py | INFO | ๐Ÿ‘€ assertIn title: XTestRunner - ๆœ็ดข. .72022-04-30 18:37:44 log.py | INFO | ๐Ÿ“– http://www.itest.info 2022-04-30 18:37:52 log.py | INFO | ๐Ÿ‘€ assertIn url: http://www.itest.info/. .82022-04-30 18:37:52 log.py | SUCCESS | generated html file: file:///D:\mypro\reports\20220430183729result.html 2022-04-30 18:37:52 log.py | SUCCESS | generated log file: file:///D:\mypro\reports\seldom_log.log</code></pre>

4ใ€ๆŸฅ็œ‹ๆŠฅๅ‘Š

ไฝ ๅฏไปฅๅˆฐ mypro\reports\ ็›ฎๅฝ•ๆŸฅ็œ‹ๆต‹่ฏ•ๆŠฅๅ‘Šใ€‚

test report

๐Ÿ”ฌ Demo

> seldom็ปงๆ‰ฟunittestๅ•ๅ…ƒๆต‹่ฏ•ๆก†ๆžถ๏ผŒๅฎŒๅ…จ้ตๅพชunittest็ผ–ๅ†™็”จไพ‹่ง„่Œƒใ€‚

demo ๆไพ›ไบ†ไธฐๅฏŒๅฎžไพ‹๏ผŒๅธฎไฝ ๅฟซ้€Ÿไบ†่งฃseldom็š„็”จๆณ•ใ€‚

Web UI ๆต‹่ฏ•

<pre><code class="lang-python">import seldom from seldom import Steps

class BaiduTest(seldom.TestCase):

def testcaseone(self): &quot;&quot;&quot;a simple test case &quot;&quot;&quot; self.open(&quot;https://www.baidu.com&quot;) self.type(id_=&quot;kw&quot;, text=&quot;seldom&quot;) self.click(css=&quot;#su&quot;) self.assertTitle(&quot;seldom_็™พๅบฆๆœ็ดข&quot;)

def testcasetwo(self): &quot;&quot;&quot;method chaining &quot;&quot;&quot; Steps().open(&quot;https://www.baidu.com&quot;).find(&quot;#kw&quot;).type(&quot;seldom&quot;).find(&quot;#su&quot;).click() self.assertTitle(&quot;seldom_็™พๅบฆๆœ็ดข&quot;)

if name == &#39;main&#39;: seldom.main(browser=&quot;chrome&quot;)</code></pre>

่ฏดๆ˜Ž๏ผš

  • seldom.main() ้€š่ฟ‡ browser ๆŒ‡ๅฎš่ฟ่กŒ็š„ๆต่งˆๅ™จใ€‚

HTTP ๆต‹่ฏ•

seldom 2.0 ๆ”ฏๆŒHTTPๆต‹่ฏ•

<pre><code class="lang-python">import seldom

class TestRequest(seldom.TestCase):

def testputmethod(self): self.put(&#39;/put&#39;, data={&#39;key&#39;: &#39;value&#39;}) self.assertStatusCode(200)

def testpostmethod(self): self.post(&#39;/post&#39;, data={&#39;key&#39;: &#39;value&#39;}) self.assertStatusCode(200)

def testgetmethod(self): payload = {&#39;key1&#39;: &#39;value1&#39;, &#39;key2&#39;: &#39;value2&#39;} self.get(&quot;/get&quot;, params=payload) self.assertStatusCode(200)

def testdeletemethod(self): self.delete(&#39;/delete&#39;) self.assertStatusCode(200)

if name == &#39;main&#39;: seldom.main(base_url=&quot;http://httpbin.org&quot;)</code></pre>

่ฏดๆ˜Ž๏ผš

  • seldom.main() ้€š่ฟ‡ base_url ๆŒ‡ๅฎšๆŽฅๅฃ้กน็›ฎๅŸบๆœฌURLๅœฐๅ€ใ€‚

App ๆต‹่ฏ•

seldom 3.0 ๆ”ฏๆŒAppๆต‹่ฏ•

<pre><code class="lang-python">import seldom from seldom.appium_lab.keyboard import KeyEvent from seldom.appium_lab.android import UiAutomator2Options

class TestBingApp(seldom.TestCase):

def start(self): self.ke = KeyEvent(self.driver)

def testbingsearch(self): &quot;&quot;&quot; test bing App search &quot;&quot;&quot; self.sleep(2) self.click(id=&quot;com.microsoft.bing:id/sahpheadersearch_box&quot;) self.type(id=&quot;com.microsoft.bing:id/sapphiresearchheaderinput&quot;, text=&quot;seldomQA&quot;) self.ke.press_key(&quot;ENTER&quot;) self.sleep(1) elem = self.get_elements(xpath=&#39;//android.widget.TextView&#39;) self.assertIn(&quot;seldom&quot;, elem[0].text.lower())

if name == &#39;main&#39;: capabilities = { &#39;deviceName&#39;: &#39;ELS-AN00&#39;, &#39;automationName&#39;: &#39;UiAutomator2&#39;, &#39;platformName&#39;: &#39;Android&#39;, &#39;appPackage&#39;: &#39;com.microsoft.bing&#39;, &#39;appActivity&#39;: &#39;com.microsoft.sapphire.app.main.MainSapphireActivity&#39;, &#39;noReset&#39;: True, } options = UiAutomator2Options().load_capabilities(capabilities) seldom.main(appserver=&quot;http://127.0.0.1:4723&quot;, appinfo=options, debug=True)</code></pre>

่ฏดๆ˜Ž๏ผš

  • seldom.main() ้€š่ฟ‡ appinfo ๆŒ‡ๅฎšAppไฟกๆฏ๏ผ› appserver` ๆŒ‡ๅฎšappium server ๅœฐๅ€ใ€‚

๐Ÿ“– Document

ไธญๆ–‡ๆ–‡ๆกฃ

้กน็›ฎๅฎžไพ‹

B็ซ™ๅฎžๆˆ˜่ง†้ข‘๏ผš

https://www.bilibili.com/video/BV1QHQVYoEHC

ๅŸบไบŽseldom็š„web UI่‡ชๅŠจๅŒ–้กน็›ฎ๏ผš

https://github.com/SeldomQA/seldom-web-testing

ๅŸบไบŽseldom็š„ๆŽฅๅฃ่‡ชๅŠจๅŒ–้กน็›ฎ:

https://github.com/defnngj/seldom-api-testing

ๅพฎไฟก๏ผˆWeChat๏ผ‰

็›ธๅ…ณไนฆ็ฑๆŽจ่๏ผŒ ๅŸบไบŽ SeldomQA ็›ธๅ…ณๅผ€ๆบ้กน็›ฎ๏ผŒ่™ซๅธˆ ็ผ–่‘—ใ€‚

ไบฌไธœ้“พๆŽฅ

ๆฌข่ฟŽๆทปๅŠ ๅพฎไฟก๏ผŒไบคๆตๅ’Œๅ้ฆˆ้—ฎ้ข˜ใ€‚

ๅพฎไฟก

Star History

Star History Chart

ๆ„Ÿ่ฐข

ๆ„Ÿ่ฐขไปŽไปฅไธ‹้กน็›ฎไธญๅพ—ๅˆฐๆ€่ทฏๅ’ŒๅธฎๅŠฉใ€‚

่ดก็Œฎ่€…

ไบคๆต

QQ็พค๏ผš948994709

ยฉ 2026 GitRepoTrend ยท SeldomQA/seldom ยท Updated daily from GitHub