用于selenium webdriver测试执行的python模块
shishito的Python项目详细描述
shishito
shishito是使用selenium webdriver&python进行web和移动应用程序功能测试的模块。 它使用包含的库运行测试,并生成良好的测试结果输出。
文档-http://shishito.readthedocs.org/en/latest/index.html(托管在阅读文档上)
功能
- 通过pytest运行python selenium webdriver测试
- 轻松配置本地和远程(BrowserStack、Appium等)测试执行
- 包含有用的测试库
- 生成HTML测试结果报告(带有失败测试的屏幕截图)
- 设计用作一个模块(如果需要,可由多个项目使用)
先决条件
从requirements.txt安装python moodules
pip install-r requirements.txt
需要设置webdriver驱动程序(chromedriver、internetexplorerdriver等)
快速启动
- 克隆shishito仓库。
git clone git@github.com:salsita/shishito.git
- 将shishito目录添加到pythonpath环境变量中
- 克隆示例测试项目存储库https://github.com/salsita/shishito-sample project
git clone git@github.com:salsita/shishito sample project.git
- 如果要使用BrowserStack运行测试,请在shishito sample project/config/server-config.properties中用凭据替换"bs-username"、"bs-password"值 或者使用flag--browserstack username:token将其作为命令行参数传递给runner python文件
- 如果要使用saucelabs运行测试,请将凭据添加到shishito sample project/config/server_config.properties中的saucelabs变量 或者使用flag--saucelabs username:token将其作为命令行参数传递给runner python文件
- 在shishito sample project/config/web/(browserstack local).properties或shishito sample project/config/mobile/appium.properties中的移动应用程序中设置首选浏览器设置
- 在示例项目文件夹中运行google_test_runner.py!
如果您使用本地驱动程序,您现在应该看到浏览器正在启动并且测试正在运行。 控制台输出中显示了有关进度的信息。 测试完成后,可以在以下位置找到HTML报告:
shishito-sample-project/results folder # HTML report
shishito-sample-project/results_archive folder # zipped HTML report
连续积分
使用Shishito和持续集成解决方案,如Jenkins,很容易! 您只需克隆shishito repo并将其添加到pythonpath中即可。
下面的脚本示例(jenkins"execute shell"构建步骤):
#!/bin/bash####################### clone Shishito #######################cd$WORKSPACE git clone git@github.com:salsita/shishito.git ####################### VARIABLES #######################exportPYTHONPATH=${PYTHONPATH}:/$WORKSPACE/shishito ####################### SCRIPT ####################### python google_test_runner.py
命令行选项
--platformweb# define platform on which run tests (currently supported: web, mobile, generic)--environmnetlocal# define environment in which run tests (currently supported: local, browserstack, appium, remote)--test_directorytests# define directory where to lookup for tests (project_root + test_directory)# supported platform/environment combinations:# generic/local# generic/remote# web/local# web/browserstack# web/remote# mobile/appium (can run on local/remote appium server or on saucelabs)# node_webkit/node_webkit--smoke# runs only tests with fixture "@pytest.mark.smoke"--browserstacktestuser1:p84asd21d15asd454# authenticate on BrowserStack using user "testuser1" and token "p84asd21d15asd454"--saucelabstestuser1:p84asd21d15asd454# authenticate on Saucelabs using user "testuser1" and token "p84asd21d15asd454"--test_railuser@email.com:1AVFS51AS# authenticate on TestRail using user email "user@email.com" and password "1AVFS51AS"
如果没有指定参数,shishito默认情况下会在(server local).properties文件中搜索设置组合,并根据它们运行测试。
配置文件
服务器配置属性
- 带有测试变量的默认配置文件
- 对变量的更改应该在VCS中维护;这样配置就可以被重用,以便自动执行测试
# modules
test_platform=web
test_environment=local
# test dir
test_directory=tests
# General
base_url=http://www.google.com
environment_configuration=Chrome
- 测试平台-在哪个平台上运行测试(Web、移动)
- test_environment-在哪个环境中运行测试(local、browserstack、appium)
- test_目录-在哪个目录中查找测试
- 基本URL-在每次测试开始时默认加载的URL
- environment_configuration-哪个配置使用<;environment>;.properties文件(在没有运行程序的情况下运行测试时使用)
- 远程驱动程序URL-远程驱动程序集线器。Selenium服务器需要在此URL上运行。
本地配置属性> <;平台>;/<;环境>;。属性 conftest.py 可以使用命令行参数和配置文件配置shishito。一些配置值也作为参数添加到pytest(取决于测试环境)。
根据这些优先级查找配置值: shishito能够对node webkit应用程序运行测试。当前的实现不允许tester指定基于url的url,只允许从应用程序中直接指定的url运行应用程序。
创建webdriver驱动程序对象是由特定的chromedriverchromedriver完成的,它必须与node webkit application放在同一目录中。
chromedriver将搜索节点webkit二进制文件并启动应用程序。二进制文件必须有特定的名称,否则chromedriver找不到它们。 由于节点webkit chromedriver中的问题;已添加
使用pyscreenshot模块的故障时的临时屏幕截图功能。此功能拍摄整个桌面的截图,而不仅仅是节点webkit
应用程序窗口。此问题应在Chromedriver 2.15中修复。node webkit chromedriver v2.15有alpha版本。
一旦问题解决,此功能将被删除。 注意:ubuntu:还需要安装python imaging
如果您看到与下面类似的异常 您需要检查chromedriver文件的访问权限,主要是在linux或os x上,windows应该没问题。 shishito支持将测试结果上传到testrail测试管理应用程序。
必须填写服务器/本地配置中的以下属性: 有关更多信息,请参见testrail api文档http://docs.gurock.com/testrail-api2/start" rel="nofollow">http://docs.gurock.com/testrail-api2/start配置
节点WebKit配置
节点WebKit二进制文件必须具有名称:nw
nw.exe
node webkit.app
故障时的临时屏幕截图功能
sudo apt get install python imaging
节点WebKit平台故障排除
raise WebDriverException(
\"\'\" + os.path.basename(self.path) + \"\' executable needs to be \
available in the path. Please look at \
http://docs.seleniumhq.org/download/#thirdPartyDrivers \
and read up at \
\> http://code.google.com/p/selenium/wiki/ChromeDriver")
E WebDriverException: Message: 'chromedriver' executable needs to be available in the path. Please look at http://docs.seleniumhq.org/download/#thirdPartyDrivers and read up at http://code.google.com/p/selenium/wiki/ChromeDriver
/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/service.py:70: WebDriverException
测试管理支持
历史记录
3.1.10(2019-08-12)
3.1.9(2019-07-18)
shi
script未将新添加的包更新到requirements.txt的小修复
3.1.8(2019-07-03)
3.1.7(2019-07-01)
3.1.6(2019-06-18)
3.1.5(2019-05-22)
3.1.4(2019-05-21)
3.1.3(2019-03-07)
3.1.2(2019-01-14)
3.1.1(2019-01-09)
3.1.0(2018-11-27)
3.0.7(2018-10-25)
3.0.6(2018-10-25)
3.0.5(2018-09-10)
3.0.4(2018-08-15)
3.0.3(2018-08-14)
pip install shishito
推荐PyPI第三方库